-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Scala greeter example #95
Conversation
gvdongen
commented
Feb 1, 2024
•
edited
Loading
edited
- Adds a Scala keyed greeter examples
|
||
name := "hello-world-http" | ||
version := "1.0" | ||
scalaVersion := "2.13.12" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isn't scala 2.13 legacy? shouldn't we provide an example for scala 3?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't scala 2.13 still used more? I can switch though. Probably it matter little here, if all dependencies support Scala 3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IDK the data about usage of scala 2.13 but I would rather prefer to show an example with the latest Scala version. If someone is stuck on 2.13, they'll probably find a way to make it working.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll merge this one and try adding a Scala 3 example as well
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll merge this one and try adding a Scala 3 example as well
+1 for this approach.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot for creating this PR @gvdongen. This is really good for helping users who are interested in Scala and SBT :-) +1 for merging and tackling Scala 3 as a potential follow-up.
import io.grpc.stub.StreamObserver | ||
|
||
class Greeter extends GreeterImplBase with RestateService { | ||
private val COUNT = StateKey.of[Integer]("count", CoreSerdes.INT) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't statics go into a companion object usually in Scala?
val count = ctx.get(COUNT).orElse(Integer.valueOf(1)) | ||
ctx.set(COUNT, Integer.valueOf(count + 1)) | ||
|
||
responseObserver.onNext(GreetResponse.newBuilder.setMessage("Hello " + request.getName + " for the " + count + " time!").build) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
responseObserver.onNext(GreetResponse.newBuilder.setMessage("Hello " + request.getName + " for the " + count + " time!").build) | |
responseObserver.onNext(GreetResponse.newBuilder.setMessage(s"Hello ${request.getName} for the ${count} time!").build) |