master

package
v0.8.3 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2025 License: MIT Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// FlagParser 可由 App 指定自定义的 flag
	FlagParser = flagParse

	Daemon  bool
	Version bool
)
View Source
var (
	// ConfigModTime 公共配置文件集最后修改时间
	ConfigModTime time.Time

	// ConfigLoadTime 配置文件最后加载时间
	ConfigLoadTime time.Time

	// MainWatcherKey 主程序二进制和配置文件监控器标识
	MainWatcherKey     = "__PKG_MAIN_BIN_WATCHER__"
	MainWatcherConfKey = "__PKG_MAIN_CONFIG_WATCHER__"
)

Functions

func DebVersion

func DebVersion(debName string) string

DebVersion 获取当前安装的包版本

func DebVersionByService

func DebVersionByService(name string) string

DebVersionByService ff-app.service

func GetRemoteConf

func GetRemoteConf(ctx context.Context, cfg config.FilesConf)

GetRemoteConf 定时获取远端配置, 配合 RemotePipelines 使用 注: 当主配置变化时, 该函数会退出并重新运行

func MD5ConfigFiles

func MD5ConfigFiles() (md5 string, confFiles []string)

MD5ConfigFiles 配置文件 MD5, 有变化时重载系统配置项

func MD5Files

func MD5Files(files ...string) (md5 string)

MD5Files 文件 MD5

func Main

func Main()

Main 带默认命令行参数启动

func Register

func Register(stage Stage, sf ...Pipeline)

func RegisterWithContext

func RegisterWithContext(stage Stage, sf ...ContextFunc)

func Run

func Run()

Run 守护进程启动程序

func SetExtraWatcherFiles added in v0.8.1

func SetExtraWatcherFiles(confFile ...string)

SetExtraWatcherFiles 设置额外的文件到内容变化监控列表

func Start added in v0.0.10

func Start()

Start 执行程序初始化

func Stop added in v0.0.10

func Stop()

Stop 程序退出

func WaitUntilNtpdate added in v0.6.10

func WaitUntilNtpdate(timeout time.Duration) bool

WaitUntilNtpdate 等待, 直到第一次时间同步成功

Types

type ContextFunc

type ContextFunc func(ctx context.Context)

type Pipeline added in v0.0.10

type Pipeline interface {
	Start() error
	Runtime() error
	Stop() error
}

type Stage

type Stage int
const (
	// ConfigStage 程序启动和配置重载时优先执行
	ConfigStage Stage = iota

	// MainStage 在 ConfigStage 执行完成后执行
	MainStage

	// RemoteStage 执行定时远程获取配置
	RemoteStage
)

type Watcher

type Watcher struct {
	// 监控器标识
	Key string

	// 待监控的文件列表
	Files []string

	// 文件列表中文件内容变化时执行
	Func func()

	// 始终执行, 不关注文件内容是否变化
	Always bool

	// 基于文件内容是否变化的标记生成函数, 默认为: MD5Files
	HashGenerator func(...string) string
}

Watcher 文件变化监控器

func (Watcher) Start

func (w Watcher) Start()

func (Watcher) Stop

func (w Watcher) Stop()

Jump to

Keyboard shortcuts

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