protoc-gen-go-di/

directory
v0.1.91 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 11, 2021 License: Apache-2.0

README

gRPC DotNetGo ProtoCGen

Dependencies

sarulabsdi
Modified DI library that accounts for registering many of a given type.

grpcdotnetgo
Core library that relies on sarulabsdi as it DI. grpcdotnetgo brings in shared services that are similar to asp.net core;

IServiceProvier
ILogger
ClaimsPrincipal
IContextAccessor (similar to IHttpRequestAccessor)
etc.

This protoc plugin builds out the grpc implementation of a given grpc server. The concept is that an application registers an implementation of a published interface based on the proto server.

In short the design mirrors how asp.net core works. A request comes in, a container is created that only offers up scoped registered objects, and removes the need to pass context.Context into every method. You can still get the context by pulling the scoped IContextAccessor from the container.

Individual outputs

protoc --go_out=. --go_opt=paths=source_relative --go-grpc_out=. --go-grpc_opt=paths=source_relative helloworld/helloworld.proto
go get -u github.com/fluffy-bunny/protoc-gen-go-di/cmd/protoc-gen-go-di
protoc --go_out=. --go_opt=paths=source_relative --go-di_out=. --go-di_opt=paths=source_relative helloworld/helloworld.proto 

One hit wonder

go get -u github.com/fluffy-bunny/protoc-gen-go-di/cmd/protoc-gen-go-di
protoc --go_out=. --go_opt=paths=source_relative --go-grpc_out=. --go-grpc_opt=paths=source_relative --go-di_out=. --go-di_opt=paths=source_relative helloworld/helloworld.proto 

Example project

grpcdotnetgo example

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL