runner

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2024 License: Apache-2.0 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

func RunServer

func RunServer(server Server, opts ...Option) error

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 EmptyServer

type EmptyServer struct {
}

func (*EmptyServer) Run

func (s *EmptyServer) Run(cfg *Config) error

func (*EmptyServer) Shutdown

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

type GrpcServer

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

func NewGrpcServer

func NewGrpcServer() *GrpcServer

func (*GrpcServer) Run

func (s *GrpcServer) Run(c *Config) 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(c *Config) 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(*Config) 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) AddOnceTimeAfterFunc

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

AddOnceTimeAfterFunc after d, once exec

func (*TaskServer) AddTickerTimeAfterFunc

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

AddTickerTimeAfterFunc ticker d, loop exec

func (*TaskServer) AddTimeAfterFunc

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

you can use AddTickerTimeAfterFunc replace this Deprecated

func (*TaskServer) Run

func (s *TaskServer) Run(c *Config) 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