csgrpc

package
v0.0.0-...-202847b Latest Latest
Warning

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

Go to latest
Published: Jan 1, 2023 License: Apache-2.0 Imports: 8 Imported by: 2

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

func NewStatusBadRequestError(c codes.Code, msg string, FieldDescription ...string) error

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

type AbstractServer struct {
	Log log.Logger
	// contains filtered or unexported fields
}

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/corestoreio/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

func WithErrorMetrics(name string) Option

WithErrorMetrics enables OpenCensus error counting.

func WithLogger

func WithLogger(l log.Logger) Option

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.

Jump to

Keyboard shortcuts

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