work in progress: set up types for message processing
This commit is contained in:
parent
2a188cfa1a
commit
1cd31ffb48
3 changed files with 30 additions and 3 deletions
|
@ -47,7 +47,7 @@ func step(ctx lib.Context, sig <-chan os.Signal) bool {
|
|||
//ctx.LogInfo("Dispatcher stopped", m.Map{})
|
||||
return false
|
||||
}
|
||||
//ctx.HandleMsg(&msg)
|
||||
//ctx.HandleMsg(msg)
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@ func Start(ctx lib.Context) {
|
|||
type Base struct {
|
||||
name string
|
||||
starter lib.StartProc
|
||||
actions []lib.ActionConfig
|
||||
children []lib.Config
|
||||
}
|
||||
|
||||
|
@ -31,6 +32,10 @@ func (cfg *Base) Starter() lib.StartProc {
|
|||
return cfg.starter
|
||||
}
|
||||
|
||||
func (cfg *Base) Actions() []lib.ActionConfig {
|
||||
return cfg.actions
|
||||
}
|
||||
|
||||
func (cfg *Base) Children() []lib.Config {
|
||||
return cfg.children
|
||||
}
|
||||
|
@ -43,6 +48,7 @@ func MakeBase(name string, starter lib.StartProc) *Base {
|
|||
return &Base{
|
||||
name: name,
|
||||
starter: starter,
|
||||
actions: nil,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
25
lib/lib.go
25
lib/lib.go
|
@ -1,3 +1,5 @@
|
|||
// Package `lib` provides a set of common types (mostly interfaces
|
||||
// and function declarations) and some basic functions.
|
||||
package lib
|
||||
|
||||
import (
|
||||
|
@ -5,15 +7,24 @@ import (
|
|||
"sync"
|
||||
)
|
||||
|
||||
type ActionSpec interface {
|
||||
Handler() ActionHandler
|
||||
Receivers() []string
|
||||
}
|
||||
|
||||
type ActionConfig interface {
|
||||
Pattern() string
|
||||
Specs() []ActionSpec
|
||||
}
|
||||
|
||||
type Config interface {
|
||||
Name() string
|
||||
Starter() StartProc
|
||||
Actions() []ActionConfig
|
||||
Children() []Config
|
||||
Add(Config)
|
||||
}
|
||||
|
||||
type Message interface{}
|
||||
|
||||
type Services map[string]Context
|
||||
|
||||
type ContextState interface{}
|
||||
|
@ -31,8 +42,18 @@ type Context interface {
|
|||
Stop()
|
||||
}
|
||||
|
||||
type Message interface{}
|
||||
|
||||
type Action interface {
|
||||
Context() Context
|
||||
Spec() ActionSpec
|
||||
Message() Message
|
||||
}
|
||||
|
||||
type Proc = func(Context)
|
||||
type StartProc = Proc
|
||||
type MessageHandler = func(Context, Message)
|
||||
type ActionHandler = func(Action)
|
||||
|
||||
// async Runners
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue