taskconsumer

package
v0.1.8 Latest Latest
Warning

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

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

Documentation

Overview

Package taskconsumer consumes worker task messages and executes agent runs.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RequestFromWorkerTask

func RequestFromWorkerTask(msg protocol.WorkerTaskMessage) *agent.RequestContext

RequestFromWorkerTask converts the worker task protocol into the agent runtime boundary.

Types

type Config

type Config struct {
	OrgID          uint
	WorkerID       uint
	DebounceWindow time.Duration
	MaxConcurrency int    // concurrent worker pool size, default 20
	SeqTrackerPath string // path to SQLite seq tracker database
}

Config controls one standalone worker task consumer.

type Consumer

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

Consumer subscribes to one worker task topic and dispatches tasks to an agent runtime.

func New

func New(cfg Config, subscriber eventbus.Subscriber, publisher ResultPublisher, runner agent.Runner) (*Consumer, error)

New creates a worker task consumer.

func (*Consumer) Close

func (c *Consumer) Close() error

Close shuts down the consumer gracefully, waiting for all in-flight tasks.

func (*Consumer) Start

func (c *Consumer) Start(ctx context.Context) error

Start subscribes to the worker task topic. On first start (no seq tracker or no history) it creates a durable consumer from the latest position. On restart with existing history it replays from the last completed seq via SubscribeFrom, using SQLite as the authoritative recovery point. Only one subscription is active.

func (*Consumer) TaskTopic

func (c *Consumer) TaskTopic() string

TaskTopic returns the NATS subject consumed by this worker.

type MQStreamSink

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

MQStreamSink publishes agent runtime completion events via JetStream.

func NewMQStreamSink

func NewMQStreamSink(publisher ResultPublisher, task protocol.WorkerTaskMessage) *MQStreamSink

NewMQStreamSink creates a stream sink for one worker task.

func (*MQStreamSink) Emit

func (s *MQStreamSink) Emit(ctx context.Context, event *events.Event) error

Emit publishes runtime events to the session stream topic via JetStream.

type ResultPublisher

type ResultPublisher interface {
	eventbus.Publisher
}

ResultPublisher publishes worker run result events.

Jump to

Keyboard shortcuts

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