FsGrpc 0.9.6
See the version list below for details.
dotnet add package FsGrpc --version 0.9.6
NuGet\Install-Package FsGrpc -Version 0.9.6
<PackageReference Include="FsGrpc" Version="0.9.6" />
paket add FsGrpc --version 0.9.6
#r "nuget: FsGrpc, 0.9.6"
// Install FsGrpc as a Cake Addin #addin nuget:?package=FsGrpc&version=0.9.6 // Install FsGrpc as a Cake Tool #tool nuget:?package=FsGrpc&version=0.9.6
FsGrpc
Idiomatic F# code generation for Protocol Buffers and gRPC
⚠️ this is currently a work in progress. See the "Status" section for more info
Generate idiomatic F# records from proto3 message definitions, complete with oneofs as discriminated unions, and serialize/deserialize to and from protocol buffer wire format.
Getting Started
If using buf.build, simply add the following "remote" line to your buf.gen.yaml:
version: v1
plugins:
- remote: buf.build/divisions-maintenance-group/plugins/fsharp
out: gen
Using buf generate
with the above example will generate .fs files in the "gen" directory, and also a Protobuf.targets file in that directory which includes those files in correct dependency order.
You then add the following line to your .fsproj:
<Import Project="gen/Protobuf.targets" />
And run
dotnet add package fsgrpc --prerelease
or
Install-Package FsGrpc -Version -IncludePrerelease
Usage in F#
You can create a record by specifying all of the fields or using with
syntax as follows:
let message =
{ MyMessage.empty with
Name = "a name value"
Description = "some string here" }
Serializing a message to bytes looks like this:
let bytes = message |> FsGrpc.Protobuf.encode
And deserializing looks like this:
let message: MyMessage = bytes |> FsGrpc.Protobuf.decode
You can also serialize/deserialize from a CodedOutputStream/CodedInputStream using:
// decode from a CodedInputStream named cis
let message = MyMessage.Proto.Decode cis
// encode to a CodedOutputStream named cos
MyMessage.Proto.Encode cos message
Status
Note: This is currently a work in progress. Code generation for protocol buffers is currently working but considered an alpha version. gRPC and other features (such as code comments and reflection) are not complete.
The major features intended are:
- Protobuf Messages as immutable F# record types
- Oneofs as Discriminated Unions
- proto3 optional keyword support
- Support for optional wrapper types (e.g. google.protobuf.UInt32Val)
- Support for well-known types Duration and Timestamp (represented using NodaTime types)
- Automatic dependency-sorted inclusion of generated .fs files
- Buf.build integration
- Comment pass-through
- Protocol Buffer reflection
- Idiomatic functional implementation for gRPC endpoints
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
-
net6.0
- FSharp.Core (>= 6.0.5)
- Google.Protobuf (>= 3.19.4)
- NodaTime (>= 3.0.9)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on FsGrpc:
Package | Downloads |
---|---|
FsGrpc.Tools
gRPC and Protocol Buffer compiler for F# projects |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
1.0.6 | 2,369 | 4/2/2024 |
1.0.5 | 6,271 | 5/12/2023 |
1.0.3 | 286 | 4/20/2023 |
1.0.2 | 991 | 3/9/2023 |
1.0.1 | 982 | 1/16/2023 |
1.0.0 | 763 | 11/18/2022 |
0.9.9 | 357 | 11/9/2022 |
0.9.8 | 437 | 10/7/2022 |
0.9.7 | 1,744 | 9/13/2022 |
0.9.6 | 418 | 9/1/2022 |
0.9.5 | 424 | 8/23/2022 |
0.9.4 | 412 | 8/22/2022 |
0.9.3 | 438 | 7/12/2022 |
0.9.2 | 459 | 7/8/2022 |
0.9.1-beta | 169 | 7/7/2022 |
0.9.0-alpha-2 | 202 | 3/21/2022 |
0.9.0-alpha-1 | 187 | 3/19/2022 |