re-arrange definitions in scopes source code

This commit is contained in:
Helmut Merz 2023-07-21 10:33:04 +02:00
parent b6325392a8
commit fc5f140059

View file

@ -1,4 +1,4 @@
// Package `scopes` provides a set of common types (mostly interfaces
// Package `scopes` provides a set of core types (mostly interfaces
// and function declarations) and some basic functions.
package scopes
@ -8,35 +8,6 @@ import (
"sync"
)
// config
type ActionSpec interface {
Handler() ActionHandler
Receivers() []string
}
type Pattern interface {
fmt.Stringer
Slice() []string
}
type ActionConfig interface {
Pattern() Pattern
Specs() []ActionSpec
}
type Config interface {
Name() string
Starter() StartProc
Step() StepProc
MessageHandler() MessageHandler
DoneHandler() StepProc
Actions() []ActionConfig
AddAction(string, ...ActionSpec) Config
Children() []Config
Add(...Config) Config
}
// services - context
type Services map[string]Context
@ -100,6 +71,11 @@ type Action interface {
Handle() bool
}
type ActionSpec interface {
Handler() ActionHandler
Receivers() []string
}
// procedures and handlers
type Proc = func(Context)
@ -108,7 +84,31 @@ type StepProc = func(Context) bool
type MessageHandler = func(Context, Message) bool
type ActionHandler = func(Action) bool
// library functions
// standard configuration interfaces
type Config interface {
Name() string
Starter() StartProc
Step() StepProc
MessageHandler() MessageHandler
DoneHandler() StepProc
Actions() []ActionConfig
AddAction(string, ...ActionSpec) Config
Children() []Config
Add(...Config) Config
}
type ActionConfig interface {
Pattern() Pattern
Specs() []ActionSpec
}
type Pattern interface {
fmt.Stringer
Slice() []string
}
// core library functions
func RunCtx(ctx Context, fct Proc) {
ctx.WaitGroup().Add(1)