Closed panesofglass closed 3 years ago
@purkhusid do you have a working sample that might help me?
@panesofglass I got your server working. It was just a matter of wrong namespace/types being used.
In the greet.proto you have option csharp_namespace = "GrpcSample";
which makes it so that all the generated types are under the GrpcSample
namespace.
I saw that you can actually see the generated .fs
files under obj/Debug/net5.0/Protos/Greet.fs
If you want editor support you could also skip the MSBuild integration and create a helper that generates the files and then have a separate .fsproj
for it.
It would just be a matter of:
protoc
(https://grpc.io/docs/protoc-installation/#install-pre-compiled-binaries-any-os)dotnet tool install -g grpc-fsharp
protoc -I ./ ./Protos/greet.proto --fsharp_out=./output_folder
But here is the patch with the changes I needed to do with the server project. I'm pretty sure that the same applies for the client project:
diff --git a/GrpcSample/Services/GreeterService.fs b/GrpcSample/Services/GreeterService.fs
index 51db870..c8b5897 100644
--- a/GrpcSample/Services/GreeterService.fs
+++ b/GrpcSample/Services/GreeterService.fs
@@ -3,11 +3,11 @@ namespace GrpcSample
open System
type GreeterService() =
- inherit Greet.GreeterService.GreeterServiceBase()
+ inherit GrpcSample.Greeter.GreeterBase()
override _.SayHello req ctx =
let resp =
- { Greet.HelloReply.empty() with
+ { GrpcSample.HelloReply.empty() with
// Notice how we're immediately forced to handle missing fields.
// The language itself protects you from the binary protocol's quirks.
// How cool is THAT?
diff --git a/GrpcSample/Startup.fs b/GrpcSample/Startup.fs
index b90b0e5..4b18796 100644
--- a/GrpcSample/Startup.fs
+++ b/GrpcSample/Startup.fs
@@ -23,6 +23,5 @@ type Startup() =
.UseEndpoints(fun endpoints ->
endpoints
.MapGrpcService<GreeterService>()
- .MapGet("/", (fun context -> context.Response.WriteAsync("Hello World!")))
|> ignore)
|> ignore
I also tested the server to see if it works and it works fine. Not sure how used to gRPC you are but you can use tools like https://github.com/uw-labs/bloomrpc to test the service.
I'm trying to create a small sample. However, I'm not able to get the server app to compile with:
The client app fails to compile with:
NOTE: I'm compiling on the CLI.
Do you happen to have a small sample to show how to correctly build the app?
Here are my initial attempts:
Can you point out what I've missed?