blob: 10897f33d10daf8d3df468cb114cf5508e76e578 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
namespace HelloLib
open System.Threading.Tasks
open System
open Hopac
open Google.Protobuf
open Grpc.Core
module Greeting =
let private Hello name =
printfn "Hello %s from F#!" name
type private HelloSayerImpl () =
inherit HelloNet.Api.HelloSayer.HelloSayerBase()
override this.SayHello(request: HelloNet.Api.HelloRequest, context : ServerCallContext) : Task<HelloNet.Api.HelloResponse> =
Hello request.Greetee
new HelloNet.Api.HelloResponse() |> Hopac.Job.result |> Hopac.queueAsTask
let Serve () =
let port = 10000
let server = new Server()
server.Services.Add(HelloNet.Api.HelloSayer.BindService(new HelloSayerImpl()))
server.Ports.Add(new ServerPort("localhost", port, ServerCredentials.Insecure)) |> ignore
server.Start()
server
let MakeClient () =
let channel = new Channel("127.0.0.1:10000", ChannelCredentials.Insecure)
new HelloNet.Api.HelloSayer.HelloSayerClient(channel)
|