server

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2022 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 NotifyResult

type NotifyResult struct {
	Result string `json:"result"`
	Msg    string `json:"msg"`
}

type Option

type Option func(s *Server)

func WithBasePath

func WithBasePath(basePath string) Option

func WithEngine

func WithEngine(engine *gin.Engine) Option

func WithGlobalErrorHandler added in v1.0.0

func WithGlobalErrorHandler(ef func(reqId string, taskPath string, paniced interface{}) error) Option

全局错误处理。如果ef返回的error不为nil,则会将error信息通知到client

func WithLogger

func WithLogger(logger *logrus.Logger) Option

func WithMaxWaitSecondsWhenNotifyErrorBlock

func WithMaxWaitSecondsWhenNotifyErrorBlock(n int) Option

通知出错时,需要重新通知。如果队列阻塞时,最长等待时间。

func WithNotifyErrorFrequencySeconds

func WithNotifyErrorFrequencySeconds(n int) Option

通知出错时,需要重新通知。每n秒,重新通知一次。

func WithNotifyGoroutineNum

func WithNotifyGoroutineNum(n int) Option

通知client的goroutine数量

func WithPort

func WithPort(port string) Option

func WithRetryNotifyTimes

func WithRetryNotifyTimes(n int) Option

通知出错时,最多尝试次数

type Server

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

func NewServer

func NewServer(options ...Option) *Server

func (*Server) Close

func (s *Server) Close()

func (*Server) RegisterTaskHandler

func (s *Server) RegisterTaskHandler(taskPath string, handler TaskHandler)

func (*Server) Start

func (s *Server) Start()

type TaskHandler

type TaskHandler interface {
	Handle(reqId string, params map[string]string) (string, error)
}

type TaskHandlerFunc

type TaskHandlerFunc func(reqId string, params map[string]string) (string, error)

func (TaskHandlerFunc) Handle

func (f TaskHandlerFunc) Handle(reqId string, params map[string]string) (string, error)

Jump to

Keyboard shortcuts

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