testexecutor

package
v2.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package testexecutor provides mock implementations for agent executor for testing.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewWithControlChannels

func NewWithControlChannels() (*TestAgentExecutor, *ControlChannels)

NewWithControlChannels creates a TestAgentExecutor controllable through the returned channels.

Types

type ControlChannels

type ControlChannels struct {
	ReqCtx         <-chan *a2asrv.ExecutorContext
	ExecEvent      chan<- a2a.Event
	CancelCalled   <-chan struct{}
	ContinueCancel chan<- struct{}
}

ControlChannels is a group of channels for controlling TestAgentExecutor behavior.

type TestAgentExecutor

type TestAgentExecutor struct {
	ExecuteFn func(context.Context, *a2asrv.ExecutorContext) iter.Seq2[a2a.Event, error]
	CancelFn  func(context.Context, *a2asrv.ExecutorContext) iter.Seq2[a2a.Event, error]
	CleanupFn func(context.Context, *a2asrv.ExecutorContext, a2a.SendMessageResult, error)
	// contains filtered or unexported fields
}

TestAgentExecutor is a mock of a2asrv.AgentExecutor.

func FromEventGenerator

func FromEventGenerator(generator func(execCtx *a2asrv.ExecutorContext) []a2a.Event) *TestAgentExecutor

FromEventGenerator creates a TestAgentExecutor that emits events from a generator.

func FromFunction

func FromFunction(fn func(ctx context.Context, ec *a2asrv.ExecutorContext) iter.Seq2[a2a.Event, error]) *TestAgentExecutor

FromFunction creates a TestAgentExecutor from a function.

func NewCanceler

func NewCanceler() *TestAgentExecutor

NewCanceler creates a TestAgentExecutor which emits a single a2a.TaskStateCanceled even on cancel.

func (*TestAgentExecutor) Cancel

Cancel implements a2asrv.AgentExecutor interface.

func (*TestAgentExecutor) Cleanup

func (e *TestAgentExecutor) Cleanup(ctx context.Context, execCtx *a2asrv.ExecutorContext, result a2a.SendMessageResult, err error)

Cleanup implements a2asrv.AgentExecutionCleaner interface.

func (*TestAgentExecutor) Emitted

func (e *TestAgentExecutor) Emitted() []a2a.Event

Emitted provides access to events emitted by TestAgentExecutor guarded with a mutex.

func (*TestAgentExecutor) Execute

Execute implements a2asrv.AgentExecutor interface.

Jump to

Keyboard shortcuts

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