app

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type App

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

App is an application components lifecycle manager

func New

func New(opts ...Option) *App

New create an application lifecycle manager.

func (*App) ID

func (a *App) ID() string

ID returns app instance id.

func (*App) Metadata

func (a *App) Metadata() map[string]string

Metadata returns service metadata.

func (*App) Name

func (a *App) Name() string

Name returns service name.

func (*App) Run

func (a *App) Run() error

func (*App) Stop

func (a *App) Stop() error

Stop gracefully stops the application.

func (*App) Version

func (a *App) Version() string

Version returns app version.

type GRPCServer

type GRPCServer struct {
	// Port 端口号
	Port int `json:"port" yaml:"port"`
	// TLS tls配置
	TLS ServerTLS `json:"tls" yaml:"tls"`
	// WriteBufferSize 写缓冲区大小,默认是32kB
	WriteBufferSize int `json:"write_buffer_size" yaml:"write_buffer_size"`
	// ReadBufferSize 读缓冲区大小,默认是32KB
	ReadBufferSize int `json:"read_buffer_size" yaml:"read_buffer_size"`
	// MaxRecvMsgSize 最大接受消息的大小
	MaxRecvMsgSize int `json:"max_recv_msg_size" yaml:"max_recv_msg_size"`
	// MaxSendMsgSize 最大发送消息的大小
	MaxSendMsgSize int `json:"max_send_msg_size" yaml:"max_send_msg_size"`
	// MaxConcurrentStreams 最大的并发数
	MaxConcurrentStreams uint32          `json:"max_concurrent_streams" yaml:"max_concurrent_streams"`
	KeepaliveParams      KeepaliveParams `json:"keepalive_params" yaml:"keepalive_params"`
}

type HTTPServer

type HTTPServer struct {
	// Port 端口号
	Port int `json:"port" yaml:"port"`
	// TLS tls配置
	TLS            *ServerTLS    `json:"tls" yaml:"tls"`
	ReadTimeout    time.Duration `json:"read_timeout" yaml:"read_timeout"`
	WriteTimeout   time.Duration `json:"write_timeout" yaml:"write_timeout"`
	IdleTimeout    time.Duration `json:"idle_timeout" yaml:"idle_timeout"`
	MaxHeaderBytes int           `json:"max_header_bytes" yaml:"max_header_bytes"`
}

type KeepaliveParams

type KeepaliveParams struct {
	MaxConnectionIdle     time.Duration `json:"max_connection_idle" yaml:"max_connection_idle"`
	MaxConnectionAge      time.Duration `json:"max_connection_age" yaml:"max_connection_age"`
	MaxConnectionAgeGrace time.Duration `json:"max_connection_age_grace" yaml:"max_connection_age_grace"`
	Time                  time.Duration `json:"time" yaml:"time"`
	Timeout               time.Duration `json:"timeout" yaml:"timeout"`
	MinTime               time.Duration `json:"min_time" yaml:"min_time"`
	PermitWithoutStream   bool          `json:"permit_without_stream" yaml:"permit_without_stream"`
}

type Option

type Option func(o *options)

Option is an application option.

func Context

func Context(c context.Context) Option

Context with context.

func ID

func ID(id string) Option

ID with service id.

func Logger

func Logger(l log.Logger) Option

Logger with logger.

func Metadata

func Metadata(md map[string]string) Option

Metadata with service metadata.

func Monitor

func Monitor(conf *monitor.Config) Option

Monitor with app monitor.

func Name

func Name(name string) Option

Name with service name.

func Server

func Server(srv ...transport.Server) Option

Server with transport servers.

func Sigs

func Sigs(sigs []os.Signal) Option

Sigs with Sigs.

func StopTimeout

func StopTimeout(t time.Duration) Option

StopTimeout with app stop timeout.

func Version

func Version(version string) Option

Version with service version.

type ServerTLS

type ServerTLS struct {
	Enabled    bool   `json:"enabled" yaml:"enabled"`
	CertFile   string `json:"cert_file" yaml:"cert_file"`
	KeyFile    string `json:"key_file" yaml:"key_file"`
	ServerName string `json:"server_name" yaml:"server_name"`
}

Jump to

Keyboard shortcuts

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