server

package
v0.0.0-...-2692626 Latest Latest
Warning

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

Go to latest
Published: Dec 28, 2023 License: MIT Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StatusRunning  status = 0 // 运行中
	StatusStopping status = 1 // 关闭中
)
View Source
const InfoTimeOutSec = 10

InfoTimeOutSec 信息 超时时间 秒

View Source
const NameBlog string = "blog" //博客
View Source
const NameCleansing string = "cleansing" //清洗
View Source
const NameFriend string = "friend" //好友
View Source
const NameGate string = "gate" //网关
View Source
const NameInteraction string = "interaction" //交互
View Source
const NameLogin string = "login" //登录
View Source
const NameNotification string = "notification" //通知
View Source
const NameRecommendation string = "recommendation" //推荐
View Source
const NameRobot string = "robot" //机器人

Variables

This section is empty.

Functions

func AvailableLoad

func AvailableLoad() uint32

AvailableLoad 可用负载

Types

type IServer

type IServer interface {
	OnLoadBench(ctx context.Context, opts ...*Options) error //加载bench.json配置文件
	OnInit(ctx context.Context, opts ...*Options) error      //初始化服务资源
	OnStart(ctx context.Context) error                       //启动
	OnRun(ctx context.Context) error                         //运行
	OnPreStop(ctx context.Context) error                     //停止前的处理
	OnStop(ctx context.Context) error                        //停止
}

type Normal

type Normal struct {
	Options     *Options
	ProgramPath string // 程序路径
	ProgramName string // 程序名称
	ZoneID      uint32 // 区域ID
	ServiceName string // 服务
	ServiceID   uint32 // 服务ID

	BenchMgr *libbench.Mgr
	TimeMgr  *libtime.Mgr
	TimerMgr *libtimer.Mgr
	LogMgr   *liblog.Mgr
	EtcdMgr  *libetcd.Mgr

	GrpcServer *grpc.Server
	// contains filtered or unexported fields
}

func GetInstance

func GetInstance() *Normal

GetInstance 获取

func NewNormal

func NewNormal() *Normal

func (*Normal) Exit

func (p *Normal) Exit()

Exit 退出服务

func (*Normal) HandleBus

func (p *Normal) HandleBus()

HandleBus 处理总线 todo [重要] issue 在处理 event 时候, 向 eventChan 中插入 事件,注意超出eventChan的上限会阻塞.

func (*Normal) Info

func (p *Normal) Info() string

Info 服务信息 [NOTE] 有性能影响. 建议 只在调试/测试时使用.

func (*Normal) IsRunning

func (p *Normal) IsRunning() bool

IsRunning 服务是否运行中

func (*Normal) IsStopping

func (p *Normal) IsStopping() bool

IsStopping 服务是否关闭中

func (*Normal) OnInit

func (p *Normal) OnInit(ctx context.Context, opts ...*Options) error

func (*Normal) OnLoadBench

func (p *Normal) OnLoadBench(_ context.Context, opts ...*Options) error

func (*Normal) OnPreStop

func (p *Normal) OnPreStop(_ context.Context) error

func (*Normal) OnRun

func (p *Normal) OnRun(_ context.Context) error

func (*Normal) OnStart

func (p *Normal) OnStart(_ context.Context) error

func (*Normal) OnStop

func (p *Normal) OnStop(_ context.Context) error

func (*Normal) SetStopping

func (p *Normal) SetStopping()

SetStopping 设置为关闭中

type NormalTimerSecond

type NormalTimerSecond struct {
	OnTimerFun libtimer.OnFun

	Arg libutil.IObject
	// contains filtered or unexported fields
}

type OnDefaultHandler

type OnDefaultHandler func(v interface{}) error

type Options

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

Options contains Options to configure a server instance. Each option can be set through setter functions. See documentation for each setter function for an explanation of the option.

func NewOptions

func NewOptions() *Options

NewOptions 新的Options

func (*Options) WithDefaultHandler

func (p *Options) WithDefaultHandler(defaultHandler OnDefaultHandler) *Options

func (*Options) WithEtcdHandler

func (p *Options) WithEtcdHandler(etcdHandler libetcd.OnFunc) *Options

func (*Options) WithSubBench

func (p *Options) WithSubBench(subBench pkgsubbench.ISubBench) *Options

func (*Options) WithTimerEachDay

func (p *Options) WithTimerEachDay(timerEachDay *NormalTimerSecond) *Options

func (*Options) WithTimerEachSecond

func (p *Options) WithTimerEachSecond(timerEachSecond *NormalTimerSecond) *Options

Jump to

Keyboard shortcuts

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