Documentation
¶
Overview ¶
Package testexecutor provides mock implementations for agent executor for testing.
Index ¶
- func NewWithControlChannels() (*TestAgentExecutor, *ControlChannels)
- type ControlChannels
- type TestAgentExecutor
- func (e *TestAgentExecutor) Cancel(ctx context.Context, execCtx *a2asrv.ExecutorContext) iter.Seq2[a2a.Event, error]
- func (e *TestAgentExecutor) Cleanup(ctx context.Context, execCtx *a2asrv.ExecutorContext, ...)
- func (e *TestAgentExecutor) Emitted() []a2a.Event
- func (e *TestAgentExecutor) Execute(ctx context.Context, execCtx *a2asrv.ExecutorContext) iter.Seq2[a2a.Event, error]
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 ¶
func (e *TestAgentExecutor) Cancel(ctx context.Context, execCtx *a2asrv.ExecutorContext) iter.Seq2[a2a.Event, error]
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 ¶
func (e *TestAgentExecutor) Execute(ctx context.Context, execCtx *a2asrv.ExecutorContext) iter.Seq2[a2a.Event, error]
Execute implements a2asrv.AgentExecutor interface.