FsGrpc 0.9.9

There is a newer version of this package available.
See the version list below for details.
dotnet add package FsGrpc --version 0.9.9                
NuGet\Install-Package FsGrpc -Version 0.9.9                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="FsGrpc" Version="0.9.9" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add FsGrpc --version 0.9.9                
#r "nuget: FsGrpc, 0.9.9"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install FsGrpc as a Cake Addin
#addin nuget:?package=FsGrpc&version=0.9.9

// Install FsGrpc as a Cake Tool
#tool nuget:?package=FsGrpc&version=0.9.9                

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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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,409 4/2/2024
1.0.5 6,293 5/12/2023
1.0.3 289 4/20/2023
1.0.2 994 3/9/2023
1.0.1 985 1/16/2023
1.0.0 766 11/18/2022
0.9.9 358 11/9/2022
0.9.8 440 10/7/2022
0.9.7 1,747 9/13/2022
0.9.6 421 9/1/2022
0.9.5 427 8/23/2022
0.9.4 415 8/22/2022
0.9.3 441 7/12/2022
0.9.2 462 7/8/2022
0.9.1-beta 172 7/7/2022
0.9.0-alpha-2 205 3/21/2022
0.9.0-alpha-1 190 3/19/2022