easyservice

package
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2024 License: Apache-2.0 Imports: 37 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	BuildVersion     = "No Version Info"
	BuildGoVersion   = "No Version Info"
	BuildGitCommitId = "No Commit Info"
	BuildTime        = "No Time Info"
	Authors          = "No Authors Info"

)

Deprecated

Functions

func GetNextSandBoxId

func GetNextSandBoxId() int

GetNextSandBoxId 获取下一个服务沙盒的id Deprecated

func Iterator added in v0.5.1

func Iterator(f func(sandboxId int, sandbox ISandBox))

Iterator 迭代服务沙盒 Deprecated

func RemoveSandBox

func RemoveSandBox(sandBoxID int) error

RemoveSandBox 移除服务沙盒 Deprecated

func SetHelpContent

func SetHelpContent(content string)

SetHelpContent 自定义帮助信息

func SetOption

func SetOption(key string, v bool)

SetOption 添加单个自定义的参数解析

func SetOptions

func SetOptions(opt map[string]bool)

SetOptions 添加自定义的参数解析

func SetSandBox

func SetSandBox(box ISandBox)

SetSandBox 注册服务沙盒到主服务 Deprecated

func Setup

func Setup(startFunction StartFunc)

Setup 启动服务 Deprecated

func Shutdown

func Shutdown()

Shutdown 关闭服务 Deprecated

Types

type BoxConf

type BoxConf struct {
	SandBoxName        string        `json:"sandbox_name"   comment:"服务沙盒的名字"`
	Network            string        `json:"network"        comment:"使用的网络协议; tcp, tcp4, tcp6,kcp,quic,unix or unixpacket"`
	ListenAddress      string        `json:"listen_address" comment:"监听地址"`
	PrintDetail        bool          `json:"print_detail"   comment:"是否显示通讯详情"`
	SessionMaxTimeout  time.Duration `json:"session_max_timeout" comment:"会话生命周期"`
	ResponseMaxTimeout time.Duration `json:"response_max_timeout" comment:"单次处理响应最长超时时间"`
	SlowTimeout        time.Duration `json:"slow_timeout" comment:"慢请求时间"`
	RequestMaxTimeout  time.Duration `json:"request_max_timeout" comment:"请求最长超时时间"`
	RedialTimes        int           `` /* 126-byte string literal not displayed */
	RedialInterval     time.Duration `json:"redial_interval" comment:"仅限客户端角色使用 试图链接服务端时候,重试的时间间隔"`
	// contains filtered or unexported fields
}

Deprecated

func DefaultBoxConf

func DefaultBoxConf(parser *gcmd.Parser, config *gcfg.Config) *BoxConf

DefaultBoxConf 创建运行配置 Deprecated

func NewBoxConf

func NewBoxConf(name string, config *gcfg.Config, parsers ...*gcmd.Parser) *BoxConf

NewBoxConf 创建BoxConf对象 Deprecated

func (*BoxConf) EndpointConfig

func (that *BoxConf) EndpointConfig() drpc.EndpointConfig

EndpointConfig 返回rpc服务要用的配置文件 Deprecated

func (*BoxConf) GetId added in v0.1.0

func (that *BoxConf) GetId() int

func (*BoxConf) InnerIpPort

func (that *BoxConf) InnerIpPort() string

InnerIpPort 获取内网的服务地址

func (*BoxConf) ListenPort

func (that *BoxConf) ListenPort() string

ListenPort 获取监听端口

func (*BoxConf) SetId added in v0.1.0

func (that *BoxConf) SetId(id int)

type EasyService

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

EasyService 服务对象

func DefaultService

func DefaultService() *EasyService

DefaultService 获取默认的service Deprecated

func (*EasyService) AddSandBox

func (that *EasyService) AddSandBox(s ISandBox)

func (*EasyService) BeforeStop

func (that *EasyService) BeforeStop(f StopFunc)

BeforeStop 设置服务重启方法

func (*EasyService) CmdParser

func (that *EasyService) CmdParser() *gcmd.Parser

CmdParser 返回命令行解析

func (*EasyService) Config

func (that *EasyService) Config() *gcfg.Config

Config 获取配置信息

func (*EasyService) GetSandBox

func (that *EasyService) GetSandBox(id int) ISandBox

GetSandBox 获取指定的服务沙盒

func (*EasyService) Help added in v0.6.2

func (that *EasyService) Help()

Help 显示帮助信息

func (*EasyService) SandboxNames added in v0.3.2

func (that *EasyService) SandboxNames() *garray.StrArray

SandboxNames 获取当前需要启动的服务沙盒,如果为空,则表示未传入

func (*EasyService) SetPidFile

func (that *EasyService) SetPidFile(pidFile string)

SetPidFile 设置pid文件

func (*EasyService) Setup

func (that *EasyService) Setup(startFunction StartFunc)

Setup 启动服务,并执行传入的启动方法 Deprecated

func (*EasyService) Shutdown

func (that *EasyService) Shutdown(timeout ...time.Duration)

Shutdown 主动结束进程

func (*EasyService) StartTime

func (that *EasyService) StartTime() *gtime.Time

StartTime 返回启动时间

func (*EasyService) Version added in v0.6.2

func (that *EasyService) Version()

Version 显示版本信息 Deprecated

type ISandBox

type ISandBox interface {
	ID() int               // 沙盒id
	Name() string          // 沙盒名字
	Setup() error          // 启动沙盒
	Shutdown() error       //关闭沙盒
	Service() *EasyService //返回当前所在服务
}

ISandBox 服务沙盒的接口 Deprecated

func GetSandBox

func GetSandBox(sandBoxID ...int) ISandBox

GetSandBox 获取指定的服务沙盒 Deprecated

type StartFunc

type StartFunc func(service *EasyService)

StartFunc 启动回调方法

type StopFunc

type StopFunc func(service *EasyService) bool

StopFunc 服务关闭回调方法

Jump to

Keyboard shortcuts

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