Documentation
¶
Overview ¶
Package events provides the public API contract for publishing events to MCPBee
Index ¶
- Constants
- type Event
- func (e *Event) SetFile(file string) *Event
- func (e *Event) SetLanguage(language string) *Event
- func (e *Event) SetMetadata(key string, value interface{}) *Event
- func (e *Event) SetProjectID(projectID string) *Event
- func (e *Event) SetSessionID(sessionID string) *Event
- func (e *Event) SetUserID(userID string) *Event
- type InMemoryPublisher
- type Publisher
- type RedisPublisher
Constants ¶
const ( EventTypeToolExecuted = "tool_executed" EventTypeError = "error" EventTypeSuccess = "success" EventTypeWarning = "warning" )
EventType constants for common event types
const ( StatusSuccess = "success" StatusError = "error" StatusWarning = "warning" StatusPending = "pending" )
Status constants for event status
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Event ¶
type Event struct {
Type string `json:"type"` // Event type: "tool_executed", "error", "success"
Tool string `json:"tool"` // Tool name
Input string `json:"input"` // Input provided to the tool
Output string `json:"output"` // Output received from the tool
Status string `json:"status"` // Status: "success", "error", "warning"
Error string `json:"error"` // Error message if status is "error"
Metadata map[string]interface{} `json:"metadata"` // Additional metadata
Timestamp time.Time `json:"timestamp"` // When the event occurred
}
Event represents a tool execution event that can be published to MCPBee
func NewErrorEvent ¶
NewErrorEvent creates a new error event
func NewSuccessEvent ¶
NewSuccessEvent creates a new success event
func NewToolEvent ¶
NewToolEvent creates a new tool execution event
func (*Event) SetLanguage ¶
SetLanguage sets the programming language in metadata
func (*Event) SetMetadata ¶
SetMetadata adds metadata to the event
func (*Event) SetProjectID ¶
SetProjectID sets the project ID in metadata
func (*Event) SetSessionID ¶
SetSessionID sets the session ID in metadata
type InMemoryPublisher ¶
type InMemoryPublisher struct {
// contains filtered or unexported fields
}
InMemoryPublisher is a simple in-memory publisher for testing
func NewInMemoryPublisher ¶
func NewInMemoryPublisher() *InMemoryPublisher
NewInMemoryPublisher creates a new in-memory publisher
func (*InMemoryPublisher) Clear ¶
func (imp *InMemoryPublisher) Clear()
Clear removes all stored events (for testing)
func (*InMemoryPublisher) Close ¶
func (imp *InMemoryPublisher) Close() error
Close is a no-op for in-memory publisher
func (*InMemoryPublisher) GetEvents ¶
func (imp *InMemoryPublisher) GetEvents() []*Event
GetEvents returns all stored events (for testing)
func (*InMemoryPublisher) Publish ¶
func (imp *InMemoryPublisher) Publish(ctx context.Context, event *Event) error
Publish stores the event in memory
func (*InMemoryPublisher) PublishBatch ¶
func (imp *InMemoryPublisher) PublishBatch(ctx context.Context, events []*Event) error
PublishBatch stores multiple events in memory
type Publisher ¶
type Publisher interface {
// Publish sends an event to MCPBee for processing
Publish(ctx context.Context, event *Event) error
// PublishBatch sends multiple events to MCPBee
PublishBatch(ctx context.Context, events []*Event) error
// Close closes the publisher connection
Close() error
}
Publisher is the interface for publishing events to MCPBee
type RedisPublisher ¶
type RedisPublisher struct {
// contains filtered or unexported fields
}
RedisPublisher publishes events to Redis streams
func NewRedisPublisher ¶
func NewRedisPublisher(redisAddr string, streamKey string) (*RedisPublisher, error)
NewRedisPublisher creates a new Redis-based event publisher
func (*RedisPublisher) Close ¶
func (rp *RedisPublisher) Close() error
Close closes the Redis connection
func (*RedisPublisher) Publish ¶
func (rp *RedisPublisher) Publish(ctx context.Context, event *Event) error
Publish sends an event to the Redis stream
func (*RedisPublisher) PublishBatch ¶
func (rp *RedisPublisher) PublishBatch(ctx context.Context, events []*Event) error
PublishBatch sends multiple events to the Redis stream