command

package
v0.1.18 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 30, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package command 提供统一的 Worker Command 分发器。

Dispatcher 负责启动各 lane 订阅(cmd.run、cmd.control、cmd.interaction、cmd.skill), 并将收到的统一 WorkerCommand 分发到对应的 handler。

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	OrgID    uint
	WorkerID uint
}

Config 是 Dispatcher 的配置。

type ControlHandler

type ControlHandler interface {
	HandleControlCommand(ctx context.Context, cmd messaging.WorkerCommand) error
}

ControlHandler 处理 cmd.control lane 的 cancel 命令。

type Dispatcher

type Dispatcher struct {
	// contains filtered or unexported fields
}

Dispatcher 是统一的 worker 命令分发器。

func New

func New(cfg Config, sub Subscriber, handlers Handlers) (*Dispatcher, error)

New 创建新的 Dispatcher。 一次性校验 worker 标识、subscriber 和全部 handler。

func (*Dispatcher) Run

func (d *Dispatcher) Run(ctx context.Context) error

Run 并发启动四个 lane 订阅并阻塞,直到 ctx 取消或任一订阅异常退出。

任一订阅异常退出时会取消其他 lane 的 context 并返回带 lane/subject 上下文的错误。 ctx 正常取消时返回 nil。

type Handlers

type Handlers struct {
	Run         RunHandler
	Control     ControlHandler
	Interaction InteractionHandler
	Skill       SkillHandler
}

Handlers 显式包含四类 handler,构造时一次性校验。

type InteractionHandler

type InteractionHandler interface {
	HandleInteractionCommand(ctx context.Context, cmd messaging.WorkerCommand) error
}

InteractionHandler 处理 cmd.interaction lane 的 approval/question 命令。

type RunHandler

type RunHandler interface {
	HandleRunCommand(ctx context.Context, cmd messaging.WorkerCommand, msg *nats.Msg) error
}

RunHandler 处理 cmd.run lane 的 agent run 命令。 msg 是原始 NATS 消息,供 handler 获取 stream seq 用于 seq tracking 和背压控制。

type SkillHandler

type SkillHandler interface {
	HandleSkillCommand(ctx context.Context, cmd messaging.WorkerCommand, msg *nats.Msg) error
}

SkillHandler 处理 cmd.skill lane 的 skill 管理命令。

type Subscriber

type Subscriber interface {
	Subscribe(ctx context.Context, topic string, consumer string, handler func(msg *nats.Msg)) error
}

Subscriber 是 Dispatcher 所需的最小订阅接口。

Directories

Path Synopsis
Package interaction 处理 cmd.interaction lane 的交互式命令 (approval.resolve 和 question.answer),通过 Resolver 接口转发。
Package interaction 处理 cmd.interaction lane 的交互式命令 (approval.resolve 和 question.answer),通过 Resolver 接口转发。
Package run provides the cmd.run lane handler for worker agent run commands.
Package run provides the cmd.run lane handler for worker agent run commands.
Package skill handles cmd.skill lane commands (install, list, detail, uninstall, import).
Package skill handles cmd.skill lane commands (install, list, detail, uninstall, import).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL