dserver

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: 53 Imported by: 0

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"

)

Functions

func CloseCtl added in v1.1.0

func CloseCtl()

CloseCtl 关闭ctl管理功能

func Cobra added in v1.1.0

func Cobra(f func(rootCmd *cobra.Command))

Cobra 注册命令

func SetName

func SetName(name string)

SetName 设置应用名 建议设置独特个性化的引用名,因为管理链接,日志目录等地方会用到它。 如果不设置,默认是"DServer_xxx",启动xxx为二进制名

func Setup

func Setup(startFunction ...StartFunc)

Setup 启动服务

func Shutdown

func Shutdown()

Shutdown 关闭服务

Types

type BaseSandbox

type BaseSandbox struct {
	Context context.Context
	Service *DService
	Config  *Config
}

BaseSandbox sandbox的基类,必须继承它

type Config

type Config struct {
	*gcfg.Config
}

Config 配置文件对象

func (*Config) EndpointConfig

func (that *Config) EndpointConfig(sandboxName ...string) drpc.EndpointConfig

EndpointConfig 通过配置文件获取配置信息

func (*Config) RpcServerOption added in v1.1.0

func (that *Config) RpcServerOption(serverName string) []server.Option

RpcServerOption 获取rpc server的参数

type Ctl added in v1.1.0

type Ctl struct {
	drpc.CallCtx
}

func (*Ctl) CloseLogger added in v1.1.0

func (that *Ctl) CloseLogger(_ *string) (*Result, *drpc.Status)

CloseLogger 关闭日志流

func (*Ctl) Debug added in v1.1.0

func (that *Ctl) Debug(debug *bool) (*Result, *drpc.Status)

Debug 设置debug模式

func (*Ctl) Info added in v1.1.0

func (that *Ctl) Info(_ *string) (*Infos, *drpc.Status)

func (*Ctl) OpenLogger added in v1.1.0

func (that *Ctl) OpenLogger(level *int) (*Result, *drpc.Status)

OpenLogger 开启日志流

func (*Ctl) Reload added in v1.1.0

func (that *Ctl) Reload(name *string) (*Result, *drpc.Status)

Reload 启动指定的服务

func (*Ctl) Start added in v1.1.0

func (that *Ctl) Start(name *string) (*Result, *drpc.Status)

Start 启动指定的服务

func (*Ctl) Stop added in v1.1.0

func (that *Ctl) Stop(name *string) (*Result, *drpc.Status)

Stop 停止指定的服务

type DServer

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

DServer 服务对象

func (*DServer) AddSandBox

func (that *DServer) AddSandBox(s ISandbox, services ...*DService) error

AddSandBox 添加sandbox到服务中 services 是可选,如果不传入则表示使用默认服务

func (*DServer) BeforeStop

func (that *DServer) BeforeStop(f StopFunc)

BeforeStop 设置服务重启方法

func (*DServer) Config

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

Config 获取配置信息

func (*DServer) NewService

func (that *DServer) NewService(name string) *DService

NewService 创建新的服务 注意: 如果是多进程模式,则每个service表示一个进程

func (*DServer) ProcessModel

func (that *DServer) ProcessModel(model ProcessModel)

ProcessModel 设置多进程模式 只有linux下才支持多进程模式

func (*DServer) SetInheritListener

func (that *DServer) SetInheritListener(address []InheritAddr)

SetInheritListener 多进程模式下,设置要被继承的监听地址

func (*DServer) SetPidFile

func (that *DServer) SetPidFile(pidFile string)

SetPidFile 设置pid文件路径

func (*DServer) Shutdown

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

Shutdown 主动结束进程

func (*DServer) StartTime

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

StartTime 返回启动时间

func (*DServer) Version

func (that *DServer) Version()

Version 显示版本信息

type DService

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

DService 服务对象,每个DService中可以存在多个sandbox 每个DServer中可以存在多个DService

func (*DService) Name

func (that *DService) Name() string

Name 获取服务名

func (*DService) SearchSandBox

func (that *DService) SearchSandBox(name string) (ISandbox, bool)

SearchSandBox 搜索同一个服务下的其他sandbox

type ISandbox

type ISandbox interface {
	Name() string    // 沙盒名字
	Setup() error    // 启动沙盒
	Shutdown() error //关闭沙盒
}

ISandbox 服务沙盒的接口

func GetSandbox added in v1.2.0

func GetSandbox(sandboxName string) ISandbox

GetSandbox 通过sandbox name 获取已注册的sandbox

type Info

type Info struct {
	SandBoxName string `protobuf:"bytes,1,opt,name=SandBoxName,proto3" json:"SandBoxName,omitempty"`
	ServiceName string `protobuf:"bytes,2,opt,name=ServiceName,proto3" json:"ServiceName,omitempty"`
	Status      string `protobuf:"bytes,3,opt,name=Status,proto3" json:"Status,omitempty"`
	Description string `protobuf:"bytes,4,opt,name=Description,proto3" json:"Description,omitempty"`
	// contains filtered or unexported fields
}

func (*Info) Descriptor deprecated

func (*Info) Descriptor() ([]byte, []int)

Deprecated: Use Info.ProtoReflect.Descriptor instead.

func (*Info) GetDescription

func (x *Info) GetDescription() string

func (*Info) GetSandBoxName

func (x *Info) GetSandBoxName() string

func (*Info) GetServiceName

func (x *Info) GetServiceName() string

func (*Info) GetStatus

func (x *Info) GetStatus() string

func (*Info) ProtoMessage

func (*Info) ProtoMessage()

func (*Info) ProtoReflect

func (x *Info) ProtoReflect() protoreflect.Message

func (*Info) Reset

func (x *Info) Reset()

func (*Info) String

func (x *Info) String() string

type Infos

type Infos struct {
	List []*Info `protobuf:"bytes,1,rep,name=list,proto3" json:"list,omitempty"`
	// contains filtered or unexported fields
}

func (*Infos) Descriptor deprecated

func (*Infos) Descriptor() ([]byte, []int)

Deprecated: Use Infos.ProtoReflect.Descriptor instead.

func (*Infos) GetList

func (x *Infos) GetList() []*Info

func (*Infos) ProtoMessage

func (*Infos) ProtoMessage()

func (*Infos) ProtoReflect

func (x *Infos) ProtoReflect() protoreflect.Message

func (*Infos) Reset

func (x *Infos) Reset()

func (*Infos) String

func (x *Infos) String() string

type InheritAddr

type InheritAddr struct {
	Network   string
	Host      string
	Port      int
	TlsConfig *tls.Config
	// ghttp服务专用
	ServerName string
}

InheritAddr master进程需要监听的配置

type ProcessModel

type ProcessModel int

ProcessModel 进程模型

const ProcessModelMulti ProcessModel = 1

ProcessModelMulti 多进程模型

const ProcessModelSingle ProcessModel = 0

ProcessModelSingle 单进程模式

type Result

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

func (*Result) Descriptor deprecated

func (*Result) Descriptor() ([]byte, []int)

Deprecated: Use Result.ProtoReflect.Descriptor instead.

func (*Result) ProtoMessage

func (*Result) ProtoMessage()

func (*Result) ProtoReflect

func (x *Result) ProtoReflect() protoreflect.Message

func (*Result) Reset

func (x *Result) Reset()

func (*Result) String

func (x *Result) String() string

type ServiceSandbox added in v1.1.0

type ServiceSandbox struct {
	BaseSandbox
}

ServiceSandbox 服务

type StartFunc

type StartFunc func(svr *DServer)

StartFunc 启动回调方法

type StopFunc

type StopFunc func(svr *DServer) bool

StopFunc 服务关闭回调方法

Jump to

Keyboard shortcuts

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