Documentation
¶
Overview ¶
Package taskmaster provides an unstable reusable async message scheduler.
The runtime coordinates local node inboxes and external dispatch targets around one public Message type. Nodes receive one message, can emit many addressed messages while running, and return one terminal Outcome.
Index ¶
- Constants
- Variables
- type CLILogTarget
- type Config
- type EmitFunc
- type Locator
- func NewAgentLocator(id string) Locator
- func NewCLIInputLocator() Locator
- func NewCLILogLocator() Locator
- func NewFakeChatHumanLocator(chatID string) Locator
- func NewLocator(locatorClass string, transport string, key string) Locator
- func NewTelegramHumanLocator(chatID int64, topicID int) Locator
- func NewTimerSourceLocator() Locator
- func NewWhatsAppHumanLocator(phoneNumberID string) Locator
- func NormalizeLocator(locator Locator) (Locator, error)
- type Message
- type Node
- type Outcome
- type OutcomeRouter
- type Runtime
- type Target
Constants ¶
const ( // MessageKindJob identifies a job message. MessageKindJob = "job" // MessageKindProgress identifies a progress update message. MessageKindProgress = "progress" // MessageKindNotification identifies a notification message. MessageKindNotification = "notification" // MessageKindResult identifies a result message. MessageKindResult = "result" // MessageKindError identifies an error message. MessageKindError = "error" // OutcomeStatusCompleted means a node completed message handling successfully. OutcomeStatusCompleted = "completed" // OutcomeStatusFailed means a node failed message handling. OutcomeStatusFailed = "failed" // OutcomeStatusStopped means a node requested runtime shutdown. OutcomeStatusStopped = "stopped" )
const ( // LocatorClassAgent identifies an agent endpoint. LocatorClassAgent = "agent" // LocatorClassAlias identifies an alias endpoint. LocatorClassAlias = "alias" // LocatorClassHuman identifies a human endpoint. LocatorClassHuman = "human" // LocatorClassIntegration identifies an integration endpoint. LocatorClassIntegration = "integration" // LocatorTransportCLI identifies CLI transport. LocatorTransportCLI = "cli" // LocatorTransportFakeChat identifies fake chat transport. LocatorTransportFakeChat = "fakechat" // LocatorTransportLocal identifies in-process local transport. LocatorTransportLocal = "local" // LocatorTransportTelegram identifies Telegram transport. LocatorTransportTelegram = "telegram" // LocatorTransportTimer identifies timer transport. LocatorTransportTimer = "timer" // LocatorTransportWhatsApp identifies WhatsApp transport. LocatorTransportWhatsApp = "whatsapp" // CLIInputKey identifies the built-in CLI input endpoint. CLIInputKey = "input" // CLILogKey identifies the built-in CLI log endpoint. CLILogKey = "log" // DefaultTimerKey identifies the default timer endpoint. DefaultTimerKey = "default" )
Variables ¶
var ErrUnsupported = errors.New("unsupported locator operation")
ErrUnsupported reports that a target cannot handle the requested locator operation.
Functions ¶
This section is empty.
Types ¶
type CLILogTarget ¶
type CLILogTarget struct {
// contains filtered or unexported fields
}
CLILogTarget writes CLI log messages through zerolog.
func (CLILogTarget) DispatchMessage ¶
func (t CLILogTarget) DispatchMessage(_ context.Context, msg Message) error
DispatchMessage writes a message to the configured logger.
func (CLILogTarget) Supports ¶
func (t CLILogTarget) Supports(locator Locator) bool
Supports reports whether the target handles the locator.
type Config ¶
type Config struct {
Logger *zerolog.Logger
RootNodeID string
Nodes map[string]Node
Targets []Target
OutcomeRouter OutcomeRouter
}
Config configures a taskmaster runtime.
type Locator ¶
type Locator struct {
Class string `json:"class"`
Transport string `json:"transport"`
Key string `json:"key"`
Address map[string]any `json:"address,omitempty"`
}
Locator identifies a message source or destination.
func NewAgentLocator ¶
NewAgentLocator constructs a local agent locator.
func NewCLIInputLocator ¶
func NewCLIInputLocator() Locator
NewCLIInputLocator constructs the built-in CLI input locator.
func NewCLILogLocator ¶
func NewCLILogLocator() Locator
NewCLILogLocator constructs the built-in CLI log locator.
func NewFakeChatHumanLocator ¶
NewFakeChatHumanLocator constructs a fake chat human locator.
func NewLocator ¶
NewLocator constructs a normalized locator.
func NewTelegramHumanLocator ¶
NewTelegramHumanLocator constructs a Telegram human locator.
func NewTimerSourceLocator ¶
func NewTimerSourceLocator() Locator
NewTimerSourceLocator constructs the built-in timer source locator.
func NewWhatsAppHumanLocator ¶
NewWhatsAppHumanLocator constructs a WhatsApp human locator.
func NormalizeLocator ¶
NormalizeLocator validates and canonicalizes a locator.
type Message ¶
type Message struct {
ID string `json:"id"`
SessionID string `json:"session_id"`
Kind string `json:"kind"`
From Locator `json:"from"`
To Locator `json:"to"`
ParentID string `json:"parent_id,omitempty"`
Content string `json:"content"`
Metadata map[string]any `json:"metadata,omitempty"`
}
Message is the unit routed through a taskmaster runtime.
func NormalizeMessage ¶
NormalizeMessage validates and canonicalizes a message.
type OutcomeRouter ¶
OutcomeRouter maps a completed message and outcome to follow-up messages.
type Runtime ¶
type Runtime struct {
// contains filtered or unexported fields
}
Runtime coordinates taskmaster nodes, routing, and lifecycle.
func (*Runtime) Done ¶
func (r *Runtime) Done() <-chan struct{}
Done returns a channel closed when the runtime exits.