fsserver

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: May 7, 2023 License: MIT Imports: 7 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrShutdown = errors.New("server shutdown")
)

Functions

func ConnFromContext

func ConnFromContext(ctx context.Context) net.Conn

func ContextWithConn

func ContextWithConn(ctx context.Context, conn net.Conn) context.Context

Types

type AnyServer

type AnyServer struct {
	// Handler 处理请求的 Handler,必填
	Handler Handler

	// BeforeAccept Accept 之前的回调,可选
	BeforeAccept func(l net.Listener) error

	// OnConn 创建新链接后的回调,可选
	OnConn func(ctx context.Context, conn net.Conn, err error) (context.Context, net.Conn, error)
	// contains filtered or unexported fields
}

AnyServer 一个通用的 server

func (*AnyServer) Serve

func (as *AnyServer) Serve(l net.Listener) error

func (*AnyServer) Shutdown

func (as *AnyServer) Shutdown(ctx context.Context) error

type CanShutdown

type CanShutdown interface {
	Shutdown(ctx context.Context) error
}

CanShutdown 支持优雅关闭

type GracefulServer added in v0.0.6

type GracefulServer interface {
	Server
	CanShutdown
}

GracefulServer 支持优雅关闭的 server

type HandleFunc

type HandleFunc func(ctx context.Context, conn net.Conn)

func (HandleFunc) Handle

func (hf HandleFunc) Handle(ctx context.Context, conn net.Conn)

type Handler

type Handler interface {
	Handle(ctx context.Context, conn net.Conn)
}

type Server

type Server interface {
	Serve(l net.Listener) error
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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