service

package
v0.0.0-...-e7d4c05 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2025 License: Apache-2.0 Imports: 9 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 定义应用信息

func NewApp

func NewApp(servers []*Server, opts ...Option) *App

func (*App) StartAndServe

func (app *App) StartAndServe()

StartAndServe 启动整个app

type Option

type Option func(*App)

func WithShutdownCallbacks

func WithShutdownCallbacks(callbacks ...ShutdownCallback) Option

WithShutdownCallbacks 通过此处设置shutdown回调

type Server

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

Server 定义

func NewServer

func NewServer(name, addr string) *Server

func (*Server) Handle

func (s *Server) Handle(pattern string, handler http.Handler)

func (*Server) Start

func (s *Server) Start() error

type ShutdownCallback

type ShutdownCallback func(ctx context.Context)

ShutdownCallback 采用 context.Context 来控制超时,而不是用 time.After 是因为 - 超时本质上是使用这个回调的人控制的 - 我们还希望用户知道,他的回调必须要在一定时间内处理完毕,而且他必须显式处理超时错误

Jump to

Keyboard shortcuts

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