Documentation ¶
Overview ¶
Package cobragrpc implements a builder for registering flags and producing a Cobra RunFunc that configures a gRPC server.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Builder ¶
type Builder struct {
// contains filtered or unexported fields
}
Builder is used to configure a gRPC server via Cobra.
func (*Builder) ListenFromFlags ¶
ListenFromFlags listens on the provided gRPC server using values configured in the provided command.
func (*Builder) RegisterFlags ¶
RegisterFlags adds flags for configuring a gRPC server.
The following flags are added: - "$PREFIX-addr" - "$PREFIX-tls-cert-path" - "$PREFIX-tls-key-path" - "$PREFIX-max-conn-age"
func (*Builder) ServerFromFlags ¶
func (b *Builder) ServerFromFlags(cmd *cobra.Command, opts ...grpc.ServerOption) (*grpc.Server, error)
ServerFromFlags creates an *grpc.Server as configured by the flags from RegisterFlags().
type Option ¶
type Option func(*Builder)
Option is function used to configure a gRPC server within a Cobra RunFunc.
func WithDefaultAddress ¶
WithDefaultAddress configures the default value of the address the server will listen at.
Defaults to ":50051"
func WithDefaultEnabled ¶
WithDefaultEnabled defines whether the server is enabled by default.
Defaults to "false".
func WithFlagPrefix ¶
WithFlagPrefix defines prefix used with the generated flags.
Defaults to "grpc".
func WithLogger ¶
WithLogger configures logging of the configured gRPC server environment.
func WithPreRunLevel ¶
WithPreRunLevel defines the logging level used for pre-run log messages.
Defaults to "debug".