From fc5f140059e73e8243850eaa21545ff24823f34d Mon Sep 17 00:00:00 2001 From: Helmut Merz Date: Fri, 21 Jul 2023 10:33:04 +0200 Subject: [PATCH] re-arrange definitions in scopes source code --- scopes.go | 62 +++++++++++++++++++++++++++---------------------------- 1 file changed, 31 insertions(+), 31 deletions(-) diff --git a/scopes.go b/scopes.go index d21ff47..8147602 100644 --- a/scopes.go +++ b/scopes.go @@ -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)