diff options
Diffstat (limited to 'HelloLib')
-rw-r--r-- | HelloLib/HelloLib.fsproj | 19 | ||||
-rw-r--r-- | HelloLib/Library.fs | 32 |
2 files changed, 51 insertions, 0 deletions
diff --git a/HelloLib/HelloLib.fsproj b/HelloLib/HelloLib.fsproj new file mode 100644 index 0000000..2ce9913 --- /dev/null +++ b/HelloLib/HelloLib.fsproj @@ -0,0 +1,19 @@ +<Project Sdk="Microsoft.NET.Sdk">
+ <PropertyGroup>
+ <TargetFramework>netstandard2.0</TargetFramework>
+ </PropertyGroup>
+ <ItemGroup>
+ <Compile Include="Library.fs" />
+ </ItemGroup>
+ <ItemGroup>
+ <PackageReference Include="Expecto" Version="5.1.2" />
+ <PackageReference Include="Grpc" Version="1.9.0" />
+ <PackageReference Include="Grpc.Core" Version="1.9.0" />
+ <PackageReference Include="Google.Protobuf" Version="3.5.1" />
+ <PackageReference Include="Hopac" Version="0.3.23" />
+ <PackageReference Include="Hopac.IO" Version="1.3.0" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="..\HelloGrpc\HelloGrpc.csproj" />
+ </ItemGroup>
+</Project>
\ No newline at end of file diff --git a/HelloLib/Library.fs b/HelloLib/Library.fs new file mode 100644 index 0000000..10897f3 --- /dev/null +++ b/HelloLib/Library.fs @@ -0,0 +1,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)
|