Abstract gRPC server
The github.com/go-nacelle/grpcbase
package provides an abstract gRPC server process.
This library supplies an abstract gRPC server process whose behavior can be configured by implementing a ServerInitializer
interface. For a more full-featured gRPC server framework built on nacelle, see scarf.
A gRPC process is created by supplying an initializer, described below, that controls its behavior.
|
|
A server initializer is a struct with an Init
method that takes a context and an grpc.Server as parameters. This method may return an error value, which signals a fatal error to the process that runs it. This method provides an extension point to register services to the server instance before the process accepts connections.
The following example registers a gRPC service to the server that will atomically increment a request counter and return it in a payload defined in the proto
package that also contains the service definition.
|
|
A simple server initializer stuct that does not need additional methods, state, or dependency instances injected via a service container can use the server initializer function wrapper instead.
|
|
You can see an additional example of a gRPC process in the example repository, specifically the server initializer.