Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Engine ¶
type Engine struct {
// contains filtered or unexported fields
}
Engine wraps an engine.Session with queue-based async operation. Submissions are processed in order; events are broadcast to all subscribers.
func (*Engine) Cancel ¶
func (e *Engine) Cancel()
Cancel enqueues a cancellation for the current turn.
func (*Engine) Submit ¶
func (e *Engine) Submit(message string) *Submission
Submit enqueues a user turn for processing.
type Event ¶
type Event struct {
ID string
Type EventType
Content string
ToolName string
ToolID string
Usage *Usage
Timestamp time.Time
SessionID string
}
Event is a single event from the async engine.
type EventQueue ¶
type EventQueue struct {
// contains filtered or unexported fields
}
EventQueue is a thread-safe, replayable queue of events.
func NewEventQueue ¶
func NewEventQueue(maxSize int) *EventQueue
NewEventQueue creates an event queue with the given max capacity.
func (*EventQueue) Push ¶
func (eq *EventQueue) Push(evt *Event)
Push adds an event and broadcasts it to all subscribers.
func (*EventQueue) Replay ¶
func (eq *EventQueue) Replay() []*Event
Replay returns all stored events for replay.
func (*EventQueue) Subscribe ¶
func (eq *EventQueue) Subscribe() <-chan *Event
Subscribe returns a channel that receives new events.
type EventType ¶
type EventType string
EventType identifies the kind of event emitted by the engine.
type Submission ¶
type Submission struct {
ID string
Op OpType
Payload string
Timestamp time.Time
ReplyTo chan<- *Event // optional: caller gets a direct reply
}
Submission represents a user request sent to the async engine.
type SubmissionQueue ¶
type SubmissionQueue struct {
// contains filtered or unexported fields
}
SubmissionQueue is a thread-safe queue for user submissions.
func NewSubmissionQueue ¶
func NewSubmissionQueue() *SubmissionQueue
NewSubmissionQueue creates a new submission queue.
func (*SubmissionQueue) Len ¶
func (sq *SubmissionQueue) Len() int
Len returns the number of pending submissions.
func (*SubmissionQueue) Next ¶
func (sq *SubmissionQueue) Next() *Submission
Next blocks until a submission is available and returns it.
func (*SubmissionQueue) Submit ¶
func (sq *SubmissionQueue) Submit(s *Submission)
Submit adds a submission and notifies the engine.