gomicro

package module
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: May 11, 2023 License: Apache-2.0 Imports: 21 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewLogger

func NewLogger(serviceName string, level zerolog.Level) grpclog.LoggerV2

NewLogger creates a grpc logger using zerolog

Types

type Options

type Options struct {
	ServiceName             string
	HttpPort                int
	GrpcPort                int
	Logger                  grpclog.LoggerV2
	RuntimeMuxEndpoint      string
	ServerReadTimeout       time.Duration
	ServerWriteTimeout      time.Duration
	ServerReadHeaderTimeout time.Duration
	NowFunc                 func() time.Time
	TLSEnabled              bool
	TlSCertFile             string
	TlSKeyFile              string
	TLSServerName           string
}

type Service

type Service struct {
	// contains filtered or unexported fields
}

Service contains API clients, connections and options for bootstrapping a micro-service.

func NewService

func NewService(opt *Options) (*Service, error)

NewService create a micro-service utility store by parsing data from config. Pass nil logger to use default logger

func (*Service) AddEndpoint

func (service *Service) AddEndpoint(pattern string, handler http.Handler)

AddEndpoint registers the handler for the given pattern. If a handler already exists for pattern, Handle panics.

func (*Service) AddEndpointFunc

func (service *Service) AddEndpointFunc(pattern string, handleFunc http.HandlerFunc)

AddEndpointFunc registers the handler function for the given pattern.

func (*Service) AddGRPCDialOptions

func (service *Service) AddGRPCDialOptions(dialOptions ...grpc.DialOption)

AddGRPCDialOptions adds dial options to the service gRPC reverse proxy client

func (*Service) AddGRPCServerOptions

func (service *Service) AddGRPCServerOptions(serverOptions ...grpc.ServerOption)

AddGRPCServerOptions adds server options to the service gRPC server

func (*Service) AddGRPCStreamClientInterceptors

func (service *Service) AddGRPCStreamClientInterceptors(
	streamInterceptors ...grpc.StreamClientInterceptor,
)

AddGRPCStreamClientInterceptors adds stream interceptors to the service gRPC reverse proxy client

func (*Service) AddGRPCStreamServerInterceptors

func (service *Service) AddGRPCStreamServerInterceptors(
	streamInterceptors ...grpc.StreamServerInterceptor,
)

AddGRPCStreamServerInterceptors adds stream interceptors to the service gRPC server

func (*Service) AddGRPCUnaryClientInterceptors

func (service *Service) AddGRPCUnaryClientInterceptors(
	unaryInterceptors ...grpc.UnaryClientInterceptor,
)

AddGRPCUnaryClientInterceptors adds unary interceptors to the service gRPC reverse proxy client

func (*Service) AddGRPCUnaryServerInterceptors

func (service *Service) AddGRPCUnaryServerInterceptors(
	unaryInterceptors ...grpc.UnaryServerInterceptor,
)

AddGRPCUnaryServerInterceptors adds unary interceptors to the service gRPC server

func (*Service) AddHTTPMiddlewares

func (service *Service) AddHTTPMiddlewares(middlewares ...func(http.Handler) http.Handler)

AddHTTPMiddlewares adds http middlewares to the service

func (*Service) AddRuntimeMuxOptions

func (service *Service) AddRuntimeMuxOptions(serveMuxOptions ...runtime.ServeMuxOption)

AddRuntimeMuxOptions adds ServeMuxOption options to service gRPC reverse proxy client The options will be applied to the service runtime mux at startup

func (*Service) ClientConn

func (service *Service) ClientConn() *grpc.ClientConn

ClientConn returns the underlying client connection to gRPC server used by reverse proxy

func (*Service) GRPCServer

func (service *Service) GRPCServer() *grpc.Server

GRPCServer returns the grpc server for the service

func (*Service) Initialize

func (service *Service) Initialize(ctx context.Context)

Initialize initializes service without starting it.

func (*Service) RuntimeMux

func (service *Service) RuntimeMux() *runtime.ServeMux

RuntimeMux returns the HTTP request multiplexer for the service reverse proxy server gRPC services and methods are registered on this multiplxer. DO NOT register your anything on the returned muxer Use AddRuntimeMuxOptions method to register custom options

func (*Service) Start

func (service *Service) Start(ctx context.Context, initFn func() error)

Start starts grpc and http server to serve requests.

Directories

Path Synopsis
pkg
grpc/auth
`grpcauth` is an authentication and authorization gRPC server side authentication wrappers.
`grpcauth` is an authentication and authorization gRPC server side authentication wrappers.
utils

Jump to

Keyboard shortcuts

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