module
0.0.0-20211113143533-446cb24580d7
Repository: https://github.com/jlzan1314/go-toolkit.git
Documentation: pkg.go.dev
# README
go-toolkit
Golang 工具集,平时在开发中常用的一些库或者封装的函数
文档目前没有写,简略版本的API文档在这里 https://godoc.org/github.com/jlzan1314/go-toolkit。
# Packages
No description provided by the author
No description provided by the author
Package events 实现了应用中的事件机制,用于业务逻辑解耦。
例如
eventManager := events.NewEventManager(events.NewMemoryEventStore(false))
eventManager.Listen(func(evt UserCreatedEvent) {
t.Logf("user created: id=%s, name=%s", evt.ID, evt.UserName)
if evt.ID != "111" {
t.Error("test failed")
}
})
eventManager.Publish(UserCreatedEvent{
ID: "111",
UserName: "李逍遥",
})
*/.
No description provided by the author
No description provided by the author
No description provided by the author
Package fpm 实现了php-fpm进程管理。
*/.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
*
Package period_job 实现了周期性任务的定时触发执行。
manager := period_job.NewManager(ctx, cc)
job1 := &DemoJob{}
job2 := &DemoJob{}
manager.Run("Test", job1, 10*time.Millisecond)
manager.Run("Test2", job2, 20*time.Millisecond)
manager.Wait()
*/.
Package pidfile provides structure and helper functions to create and remove PID file.
Package process 是一个进程管理器,类似于supervisor,能够监控进程的运行状态,自动重启失败进程。
manager := NewManager(3*time.Second, func(logType OutputType, line string, process *Process) {
color.Green("%s[%s] => %s\n", process.GetName(), logType, line)
})
manager.AddProgram("test", "/bin/sleep 1", 5, "")
manager.AddProgram("prometheus", "/bin/echo Hello", 1, "")
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()
manager.Watch(ctx)
*/.
No description provided by the author
No description provided by the author