2024-11-23 03:30:23 +00:00
|
|
|
package hodu
|
|
|
|
|
|
|
|
import "sync"
|
|
|
|
|
|
|
|
const HODU_VERSION uint32 = 0x010000
|
|
|
|
|
|
|
|
type LogLevel int
|
|
|
|
|
|
|
|
const (
|
|
|
|
LOG_DEBUG LogLevel = iota + 1
|
|
|
|
LOG_ERROR
|
|
|
|
LOG_WARN
|
|
|
|
LOG_INFO
|
|
|
|
)
|
|
|
|
|
|
|
|
type Logger interface {
|
2024-11-23 05:49:04 +00:00
|
|
|
Write (id string, level LogLevel, fmt string, args ...interface{})
|
2024-11-23 03:30:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type Service interface {
|
2024-11-23 05:49:04 +00:00
|
|
|
RunTask (wg *sync.WaitGroup) // blocking. run the actual task loop. it must call wg.Done() upon exit from itself.
|
2024-11-23 03:30:23 +00:00
|
|
|
StartService(data interface{}) // non-blocking. spin up a service. it may be invokded multiple times for multiple instances
|
|
|
|
StopServices() // non-blocking. send stop request to all services spun up
|
|
|
|
WaitForTermination() // blocking. must wait until all services are stopped
|
2024-11-23 05:49:04 +00:00
|
|
|
WriteLog(id string, level LogLevel, fmt string, args ...interface{})
|
2024-11-23 03:30:23 +00:00
|
|
|
}
|