easyservice

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2021 License: Apache-2.0 Imports: 24 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"
)

Functions

func GetNextSandBoxId

func GetNextSandBoxId() int

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

func RemoveSandBox

func RemoveSandBox(sandBoxID int) error

RemoveSandBox 移除服务沙盒

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 注册服务沙盒到主服务

func Setup

func Setup(startFunction StartFunc)

Setup 启动服务

func Shutdown

func Shutdown()

Shutdown 关闭服务

Types

type BoxConf

type BoxConf struct {
	SandBoxName        string        `json:"sandbox_name"   comment:"服务沙盒的名字"`
	Network            string        `json:"network"        comment:"使用的网络协议; tcp, tcp4, tcp6, 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:"慢请求时间"`
	CountTime          bool          `json:"count_time" 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
}

func DefaultBoxConf

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

DefaultBoxConf 创建运行配置

func NewBoxConf

func NewBoxConf() *BoxConf

NewBoxConf 创建BoxConf对象

func (*BoxConf) EndpointConfig

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

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

func (*BoxConf) InnerIpPort

func (that *BoxConf) InnerIpPort() string

InnerIpPort 获取内网的服务地址

func (*BoxConf) ListenPort

func (that *BoxConf) ListenPort() string

ListenPort 获取监听端口

type EasyService

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

EasyService 服务对象

func DefaultService

func DefaultService() *EasyService

DefaultService 获取默认的service

func NewEasyService

func NewEasyService(processName ...string) *EasyService

NewEasyService 创建服务

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) SetPidFile

func (that *EasyService) SetPidFile(pidFile string)

SetPidFile 设置pid文件

func (*EasyService) SetProcessName

func (that *EasyService) SetProcessName(processName string)

SetProcessName 设置进程名字

func (*EasyService) Setup

func (that *EasyService) Setup(startFunction StartFunc)

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

func (*EasyService) Shutdown

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

Shutdown 主动结束进程

func (*EasyService) StartTime

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

StartTime 返回启动时间

type ISandBox

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

ISandBox 服务沙盒的接口

func GetSandBox

func GetSandBox(sandBoxID ...int) ISandBox

GetSandBox 获取指定的服务沙盒

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