mgrpc

package module
v0.0.0-...-e560599 Latest Latest
Warning

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

Go to latest
Published: Jan 3, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

README

mgrpc

封装grpc功能

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LocalIPv4

func LocalIPv4(name ...string) (ipAddr string, err error)

Types

type ClientOptionFunc

type ClientOptionFunc func(o *ClientOptions)

func WithClientAddress

func WithClientAddress(addr string) ClientOptionFunc

func WithClientDiscovery

func WithClientDiscovery(discovery resolver.Discovery) ClientOptionFunc

func WithClientLogger

func WithClientLogger(log ILogger) ClientOptionFunc

func WithClientName

func WithClientName(name string) ClientOptionFunc

func WithStreamClientInterceptors

func WithStreamClientInterceptors(streamClientInterceptors ...grpc.StreamClientInterceptor) ClientOptionFunc

func WithUnaryClientInterceptors

func WithUnaryClientInterceptors(unaryClientInterceptors ...grpc.UnaryClientInterceptor) ClientOptionFunc

type ClientOptions

type ClientOptions struct {
	Name                     string
	Address                  string
	Log                      ILogger
	StreamClientInterceptors []grpc.StreamClientInterceptor
	UnaryClientInterceptors  []grpc.UnaryClientInterceptor
	// contains filtered or unexported fields
}

func NewClientOptions

func NewClientOptions(opts ...ClientOptionFunc) ClientOptions

type GrpcClient

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

func NewGrpcClient

func NewGrpcClient(ctx context.Context, opts ...ClientOptionFunc) *GrpcClient

func (*GrpcClient) Close

func (c *GrpcClient) Close(ctx context.Context)

func (*GrpcClient) GetConn

func (c *GrpcClient) GetConn() *grpc.ClientConn

type GrpcContextHandler

type GrpcContextHandler func(ctx context.Context) context.Context

type GrpcServer

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

func NewGrpcServer

func NewGrpcServer(ctx context.Context, opts ...ServerOptionFunc) *GrpcServer

func (*GrpcServer) Get

func (s *GrpcServer) Get() *grpc.Server

func (*GrpcServer) Run

func (s *GrpcServer) Run()

func (*GrpcServer) Start

func (s *GrpcServer) Start()

func (*GrpcServer) Stop

func (s *GrpcServer) Stop()

type ILogger

type ILogger interface {
	Debugf(ctx context.Context, format string, args ...interface{})
	Debugln(ctx context.Context, args ...interface{})
	Infof(ctx context.Context, format string, args ...interface{})
	Infoln(ctx context.Context, args ...interface{})
	Warnf(ctx context.Context, format string, args ...interface{})
	Warnln(ctx context.Context, args ...interface{})
	Errorf(ctx context.Context, format string, args ...interface{})
	Errorln(ctx context.Context, args ...interface{})
	Fatalf(ctx context.Context, format string, args ...interface{})
	Fatalln(ctx context.Context, args ...interface{})
}

type Logger

type Logger struct {
}

func (*Logger) Debugf

func (l *Logger) Debugf(ctx context.Context, format string, args ...interface{})

func (*Logger) Debugln

func (l *Logger) Debugln(ctx context.Context, args ...interface{})

func (*Logger) Errorf

func (l *Logger) Errorf(ctx context.Context, format string, args ...interface{})

func (*Logger) Errorln

func (l *Logger) Errorln(ctx context.Context, args ...interface{})

func (*Logger) Fatalf

func (l *Logger) Fatalf(ctx context.Context, format string, args ...interface{})

func (*Logger) Fatalln

func (l *Logger) Fatalln(ctx context.Context, args ...interface{})

func (*Logger) Infof

func (l *Logger) Infof(ctx context.Context, format string, args ...interface{})

func (*Logger) Infoln

func (l *Logger) Infoln(ctx context.Context, args ...interface{})

func (*Logger) Warnf

func (l *Logger) Warnf(ctx context.Context, format string, args ...interface{})

func (*Logger) Warnln

func (l *Logger) Warnln(ctx context.Context, args ...interface{})

type ServerOptionFunc

type ServerOptionFunc func(o *ServerOptions)

func WithServerAddress

func WithServerAddress(addr string) ServerOptionFunc

func WithServerLogger

func WithServerLogger(log ILogger) ServerOptionFunc

func WithServerName

func WithServerName(name string) ServerOptionFunc

func WithServerRandomPort

func WithServerRandomPort(randomPort bool) ServerOptionFunc

func WithServerRegister

func WithServerRegister(registry resolver.Registry) ServerOptionFunc

func WithStreamServerInterceptor

func WithStreamServerInterceptor(streamServerInterceptors ...grpc.StreamServerInterceptor) ServerOptionFunc

func WithUnaryServerInterceptor

func WithUnaryServerInterceptor(unaryServerInterceptors ...grpc.UnaryServerInterceptor) ServerOptionFunc

type ServerOptions

type ServerOptions struct {
	Name                     string
	Address                  string
	Log                      ILogger
	StreamServerInterceptors []grpc.StreamServerInterceptor
	UnaryServerInterceptor   []grpc.UnaryServerInterceptor
	RandomPort               bool
	// contains filtered or unexported fields
}

func NewServerOptions

func NewServerOptions(opts ...ServerOptionFunc) ServerOptions

Directories

Path Synopsis
health

Jump to

Keyboard shortcuts

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