FsGrpc 0.9.0-alpha-2

This is a prerelease version of FsGrpc.
There is a newer version of this package available.
See the version list below for details.
dotnet add package FsGrpc --version 0.9.0-alpha-2                
NuGet\Install-Package FsGrpc -Version 0.9.0-alpha-2                
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.0-alpha-2" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add FsGrpc --version 0.9.0-alpha-2                
#r "nuget: FsGrpc, 0.9.0-alpha-2"                
#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.0-alpha-2&prerelease

// Install FsGrpc as a Cake Tool
#tool nuget:?package=FsGrpc&version=0.9.0-alpha-2&prerelease                

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" />
<ItemGroup>
    <PackageReference Include="FsGrpc" Version="0.9.0-alpha-1" />
</ItemGroup>

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.encode

And deserializing looks like this:

let message: MyMessage = bytes |> FsGrpc.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,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