push

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2025 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package push provides a basic implementation of push notification functionality. To enable push notifications in the default server implementation, github.com/a2aproject/a2a-go/a2asrv.WithPushNotifications function should be used:

sender := push.NewHTTPPushSender()
configStore := push.NewInMemoryStore()
requestHandler := a2asrv.NewRequestHandler(
	agentExecutor,
	a2asrv.WithPushNotifications(configStore, sender),
)

Index

Constants

This section is empty.

Variables

View Source
var ErrPushConfigNotFound = errors.New("push config not found")

ErrPushConfigNotFound indicates that a push config with the provided ID was not found.

Functions

This section is empty.

Types

type HTTPPushSender

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

HTTPPushSender sends A2A events to a push notification endpoint over HTTP.

func NewHTTPPushSender

func NewHTTPPushSender(config *HTTPSenderConfig) *HTTPPushSender

NewHTTPPushSender creates a new HTTPPushSender. It uses a default client with a 30-second timeout. An optional config can be provided to customize it.

func (*HTTPPushSender) SendPush

func (s *HTTPPushSender) SendPush(ctx context.Context, config *a2a.PushConfig, task *a2a.Task) error

SendPush serializes the task to JSON and sends it as an HTTP POST request to the URL specified in the push configuration.

type HTTPSenderConfig

type HTTPSenderConfig struct {
	// Timeout is used to configure internal [http.Client].
	Timeout time.Duration
	// FailOnError can be set to true to make push sending errors trigger execution cancelation.
	FailOnError bool
}

HTTPSenderConfig allows to configure HTTPPushSender.

type InMemoryPushConfigStore

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

InMemoryPushConfigStore implements a2asrv.PushConfigStore.

func NewInMemoryStore

func NewInMemoryStore() *InMemoryPushConfigStore

NewInMemoryStore creates an empty store.

func (*InMemoryPushConfigStore) Delete

func (s *InMemoryPushConfigStore) Delete(ctx context.Context, taskID a2a.TaskID, configID string) error

Delete removes a single config from a store.

func (*InMemoryPushConfigStore) DeleteAll

func (s *InMemoryPushConfigStore) DeleteAll(ctx context.Context, taskID a2a.TaskID) error

DeleteAll removes all stored configs for a task.

func (*InMemoryPushConfigStore) Get

func (s *InMemoryPushConfigStore) Get(ctx context.Context, taskID a2a.TaskID, configID string) (*a2a.PushConfig, error)

Get returns a copy of stored config for a task and with given ID.

func (*InMemoryPushConfigStore) List

func (s *InMemoryPushConfigStore) List(ctx context.Context, taskID a2a.TaskID) ([]*a2a.PushConfig, error)

List returns a copy of stored configs for a task.

func (*InMemoryPushConfigStore) Save

func (s *InMemoryPushConfigStore) Save(ctx context.Context, taskID a2a.TaskID, config *a2a.PushConfig) (*a2a.PushConfig, error)

Save adds a copy of push config to the store.

Jump to

Keyboard shortcuts

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