reorganized the source to place the resuable code under the hodu package and keep the command entry point in the main package under the cmd directory

This commit is contained in:
2024-11-23 12:30:23 +09:00
parent 9d7a843b4c
commit a78a0a4fc4
11 changed files with 353 additions and 304 deletions

27
hodu.go Normal file
View File

@ -0,0 +1,27 @@
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 {
Write (level LogLevel, fmt string, args ...interface{})
}
type Service interface {
RunTask (wg *sync.WaitGroup) // blocking. run the actual task loop
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
}
type ExtTask func(svc Service, wg *sync.WaitGroup)