service

package
v1.10.8 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	//StateStop 未启动
	StateStop = 0
	//StateRunning 正在运行
	StateRunning = 1
	//StateStopping 正在结束
	StateStopping = 2
)

Variables

This section is empty.

Functions

func Message

func Message(serviceName string, msgType string, params ...any) error

Message 发送消息到service,根据serviceName

func Restart

func Restart(serviceName string) error

Restart 服务重启

func Start

func Start(serviceName string) error

Start 服务启动

func Stop

func Stop(serviceName string) error

Stop 服务停止,根据serviceName

Types

type Service

type Service struct {
	Name string //服务名称

	State                uint8        //服务状态 //服务运行状态 , 0:未启动 1:正在运行 2:正在结束
	NextAction           string       //动作名称
	DefaultAction        string       //默认动作
	TimerFunc            func(...any) //定时回调函数
	EventFunc            func(...any) //事件回调函数
	StopFinishedCallback func(...any) //服务停止后的回调函数

	Timer *time.Timer
	// contains filtered or unexported fields
}

Service 服务

func GetService

func GetService(name string) (*Service, error)

GetService 查询服务根据服务名称

func NewService

func NewService(name string) (*Service, error)

NewService 创建服务对象

func (*Service) Message

func (s *Service) Message(t string, params ...any) error

Message 发送消息给service t 消息类型 params 消息内容

func (*Service) Restart

func (s *Service) Restart(params ...any) error

Restart 重启服务

func (*Service) SetDefaultAction

func (s *Service) SetDefaultAction(action string) *Service

SetDefaultAction 设置默认action

func (*Service) SetEventFunc

func (s *Service) SetEventFunc(eventFunc func(...any)) *Service

SetEventFunc 设置时间功能函数

func (*Service) SetStopFinishedCallback

func (s *Service) SetStopFinishedCallback(f func(...any)) *Service

SetStopFinishedCallback 设置服务停止后的回调函数

func (*Service) SetTimerFunc

func (s *Service) SetTimerFunc(timerFunc func(...any)) *Service

SetTimerFunc 设置定时功能函数

func (*Service) Start

func (s *Service) Start(vs ...any) error

Start 服务启动

func (*Service) Stop

func (s *Service) Stop() error

Stop 服务结束

type ServiceMsg

type ServiceMsg struct {
	Type   string
	Params []any
}

ServiceMsg 服务消息

Jump to

Keyboard shortcuts

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