Documentation ¶
Overview ¶
Package csgrpc provides basics types for grpc servers and clients.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewStatusBadRequestError ¶
NewStatusBadRequestError creates a new GRPC status code error with optional advanced BadRequest_FieldViolation hints. The argument slice FieldDescription must be a balanced slice, where index = Field named and index+1 = Description. If msg should parse arguments, use fmt.Sprintf.
Types ¶
type AbstractServer ¶
AbstractServer provides general functions and options for a concrete service. A AbstractServer type must be embedded into other services. For example see the Store gRPC service.
func NewAbstractServer ¶
func NewAbstractServer(opts ...Option) (AbstractServer, error)
NewAbstractServer creates a new abstract service for embedding into other services.
func (AbstractServer) AuthFuncOverride ¶
func (s AbstractServer) AuthFuncOverride(ctx context.Context, fullMethodName string) (context.Context, error)
AuthFuncOverride calls the custom authentication function provided by ServerRPCOptions. AuthFuncOverride gets called by the middleware of package "github.com/weiwolves/pkg/net/csgrpc/auth". When implementing, make sure that `grpc_auth.UnaryServerInterceptor(nil)` has the nil argument.
func (AbstractServer) RecordError ¶
func (s AbstractServer) RecordError(ctx context.Context)
RecordError records an error if WithErrorMetrics has been applied.
type Option ¶
type Option func(*AbstractServer) error
Option applies various options to the AbstractServer.
func WithErrorMetrics ¶
WithErrorMetrics enables OpenCensus error counting.
func WithLogger ¶
WithLogger adds a logger otherwise logging would be completely disabled.
func WithServerAuthFuncOverrider ¶
func WithServerAuthFuncOverrider(a ServerAuthFuncOverrider, err error) Option
WithServerAuthFuncOverrider adds a custom authentication type. If not set, there will be no authentication. In the subpackage `auth` a couple of authentication methods are provided like JWT or basic auth.
type ServerAuthFuncOverrider ¶
type ServerAuthFuncOverrider interface {
AuthFuncOverride(ctx context.Context, fullMethodName string) (context.Context, error)
}
ServerAuthFuncOverrider allows a given gRPC service implementation to override the global `AuthFunc`.
If a service implements the AuthFuncOverride method, it takes precedence over the `AuthFunc` method, and will be called instead of AuthFunc for all method invocations within that service.
Directories ¶
Path | Synopsis |
---|---|
Package grpc_auth a generic server-side auth middleware for gRPC.
|
Package grpc_auth a generic server-side auth middleware for gRPC. |
Package grpc_scope handles setting and retrieving the store/scope for clients and servers.
|
Package grpc_scope handles setting and retrieving the store/scope for clients and servers. |