handlers

package
v0.0.0-...-68b20d9 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2023 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// 默认每个rpc接口100ms放入5个请求
	DefaultLimitTime = 100
	DefaultBurst     = 5
	// 默认服务端超时时间为5s
	DefaultServiceTimeout = 5 * time.Second
	SERVER_RPC_LOG_ENABLE = "SERVER_RPC_LOG_ENABLE"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type BootstrapHandler

type BootstrapHandler func(
	ctx context.Context,
	wg *sync.WaitGroup,
	startupTimer startup.Timer,
	dic *di.Container) (success bool)

BootstrapHandler defines the contract each bootstrap handler must fulfill. Implementation returns true if the handler completed successfully, false if it did not.

type HttpServer

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

HttpServer contains references to dependencies required by the http server implementation.

func NewHttpServer

func NewHttpServer(router *gin.Engine, doListenAndServe bool) *HttpServer

NewHttpServer is a factory method that returns an initialized HttpServer receiver struct.

func (*HttpServer) BootstrapHandler

func (b *HttpServer) BootstrapHandler(
	ctx context.Context,
	wg *sync.WaitGroup,
	_ startup.Timer,
	dic *di.Container) bool

BootstrapHandler fulfills the BootstrapHandler contract. It creates two go routines -- one that executes ListenAndServe() and another that waits on closure of a context's done channel before calling Shutdown() to cleanly shut down the http server.

func (*HttpServer) IsRunning

func (b *HttpServer) IsRunning() bool

IsRunning returns whether or not the http server is running. It is provided to support delayed shutdown of any resources required to successfully process http requests until after all outstanding requests have been processed (e.g. a database connection).

type RPCServer

type RPCServer struct {
	S *grpc.Server
	// contains filtered or unexported fields
}

func NewRPCServer

func NewRPCServer(ctx context.Context, wg *sync.WaitGroup, dic *di.Container, register RegisterFunc) (*RPCServer, error)

type RegisterFunc

type RegisterFunc func(serve *grpc.Server)

Jump to

Keyboard shortcuts

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