package lib import ( stdlib_context "context" "sync" ) type Config interface { Name() string Starter() StartProc Children() []Config Add(Config) } type Message interface{} type Services map[string]Context type ContextState interface{} type Context interface { stdlib_context.Context Config() Config Parent() Context Services() Services ChildContext(Config) Context State() ContextState WithState(ContextState) Context Mailbox() chan Message WaitGroup() *sync.WaitGroup Stop() } type Proc = func(Context) type StartProc = Proc // async Runners func RunCtx(ctx Context, fct Proc) { ctx.WaitGroup().Add(1) go func() { defer ctx.WaitGroup().Done() fct(ctx) }() }