runner

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2021 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run

func Run(server Server, deallocFunc func() error, opts ...Option) error

Run 运行服务进程,一般放到main.go 最后一行执行

Types

type Config

type Config struct {
	ListenAddr   string        `defval:"0.0.0.0:8080"` // host:port
	ReadTimeout  time.Duration `defval:"10m"`
	WriteTimeout time.Duration `defval:"10m"`
	Context      context.Context
}

func (*Config) Init

func (c *Config) Init() *Config

func (*Config) String

func (c *Config) String() string

func (*Config) WithOptions

func (c *Config) WithOptions(opts ...Option) *Config

type GrpcServer

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

func NewGrpcServer

func NewGrpcServer() *GrpcServer

func (*GrpcServer) Run

func (s *GrpcServer) Run(opts ...Option) error

func (*GrpcServer) RunAfter

func (s *GrpcServer) RunAfter(fn func(s *grpc.Server) error)

func (*GrpcServer) Server

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

func (*GrpcServer) Shutdown

func (s *GrpcServer) Shutdown(ctx context.Context) error

type HttpServer

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

func NewHttpServer

func NewHttpServer(handler http.Handler) *HttpServer

func (*HttpServer) Run

func (s *HttpServer) Run(opts ...Option) error

Run 监听端口

func (*HttpServer) Shutdown

func (s *HttpServer) Shutdown(ctx context.Context) error

Shutdown 优雅关闭

type Option

type Option interface {
	// contains filtered or unexported methods
}

func WithContext

func WithContext(ctx context.Context) Option

func WithListenAddr

func WithListenAddr(addr string) Option

func WithReadTimeout

func WithReadTimeout(timeout time.Duration) Option

func WithWriteTimeout

func WithWriteTimeout(timeout time.Duration) Option

type Server

type Server interface {
	Run(...Option) error
	Shutdown(context.Context) error
}

type TaskServer

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

func NewTaskServer

func NewTaskServer() *TaskServer

func (*TaskServer) AddCronFunc

func (s *TaskServer) AddCronFunc(spec string, fn func()) error

func (*TaskServer) AddTimeAfterFunc

func (s *TaskServer) AddTimeAfterFunc(d time.Duration, fn func(ctx context.Context)) error

func (*TaskServer) Run

func (s *TaskServer) Run(opts ...Option) error

func (*TaskServer) Shutdown

func (s *TaskServer) Shutdown(ctx context.Context) error

Jump to

Keyboard shortcuts

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