-
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
Getting started documentation for ocaml-grpc #25
Conversation
Thank you for this initiative! This kind of tutorial was sorely missing. Given that we have an Eio port in the making that has feature parity with the Lwt implementation (we haven't battle-tested it yet), we can easily port this tutorial too so we can offer it in two flavors (or even three including Async). |
examples/helloworld-tutorial.md
Outdated
let greeter_service = | ||
Server.Service.( | ||
v () |> add_rpc ~name:"SayHello" ~rpc:(Unary say_hello) |> handle_request) | ||
|
||
let server = | ||
Server.( | ||
v () |> add_service ~name:"helloworld.Greeter" ~service:greeter_service) |
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.
Relating to my above comment, with ocaml-protoc-plugin
one can actually get the RPC and service names from the .proto
file which is quite neat. (Mentioning this as a sidenote, not necessarily for inclusion in the tutorial -- we were considering writing a somewhat opinionated wrapper that would remove a lot of boilerplate)
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.
we were considering writing a somewhat opinionated wrapper that would remove a lot of boilerplate.
That would be a good improvement for the API in my opinion, however I've only recently started using this library and don't have a considered opinion on how that should look.
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.
The service name and function name are squashed into the val name
field on the generated code. eg
module GetFeature = struct
let name = "/routeguide.RouteGuide/GetFeature"
module Request = Point
module Response = Feature
end
What about making a change to the Message
module type to include returning the components?
module type Message = sig
type t
val name : () -> string (* returning GetFeature*)
val service_name: () -> string (* returning routeguide.RouteGuide *)
val from_proto: Reader.t -> t Result.t
val to_proto: t -> Writer.t
end
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.
What about making a change to the
Message
module type to include returning the components?
This is a good idea, and it's not hard to do. In fact, we already did something like that in our fork. I could have sworn it was part of the changes that have been merged recently, but alas it wasn't. Here's the commit for reference:
dialohq/ocaml-protoc-plugin@beeffb2
There have been a few changes upstream so it won't merge cleanly anymore. I'll try to rebase it and open a new PR.
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.
That would be great, let me know if I can help with it.
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.
That would be great, let me know if I can help with it.
Feel free to give it a shot if you have some time to spare. Otherwise I'll get back to it next week as I'm still on vacation this week.
issuu/ocaml-protoc-plugin#28 is the PR we branched off of. It later got merged with some more changes, and some more cleanup was done in issuu/ocaml-protoc-plugin#43.
It's probably quickest to make these changes starting from the current trunk though.
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.
Testing the EIO version and writing up the code for that is on my list. |
aa631a1
to
f129e08
Compare
hey, amazing work. thanks for this! |
fbc4628
to
0c5fc86
Compare
Mis-matches can result in ocamlformat reformatting your code to be incompatible with the lowest OCaml versions.
0c5fc86
to
7e1bddd
Compare
1e65c74
to
c6a2e74
Compare
233486f
to
b1e26be
Compare
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.
A few fixes as I worked through the tutorial.
As discussed, dune-project
requires an update -- currently dune build
fails.
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.
Just a couple of nitpicks. I think we should just merge this PR after these small fixes. It will be good for visibility!
Please don't forget to add your name to the list of authors :)
One more thing: You converted the greeter examples to use ocaml-protoc-plugin
instead of ocaml-protoc
. I'm okay with that but it means we the README in the root directory is not accurate anymore.
<!-- $MDX skip --> | ||
```shell | ||
{ | ||
"message": "Hello Tonic!" |
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.
"message": "Hello Tonic!" | |
"message": "Hello OCaml!" |
84fd1de
to
d2c7a25
Compare
I've done the smaller fixes, so it is ok to merge. The tutorial pages don't flow the way I would like but I can fix that up in another PR this week. |
Examples
Fixing the GRPC documentation one tutorial at a time.
TODO
Based off the Diátaxis framework for technical documentation writing.