Documentation
¶
Index ¶
- type AuthTokenChecker
- type Bus
- type ClientHeadUpdateData
- type ClientStatusUpdateData
- type Event
- type EventBus
- func (eb *EventBus) NewCustomEvent(eventType string, testRunID, taskIndex uint64, data any) (*Event, error)
- func (eb *EventBus) Publish(event *Event)
- func (eb *EventBus) PublishClientHeadUpdate(clientIndex int, clientName string, clHeadSlot uint64, clHeadRoot string, ...)
- func (eb *EventBus) PublishClientStatusUpdate(clientIndex int, clientName string, clStatus string, clReady bool, ...)
- func (eb *EventBus) PublishTaskCompleted(testRunID, taskIndex uint64, taskName, taskTitle, taskID, result string)
- func (eb *EventBus) PublishTaskCreated(testRunID, taskIndex uint64, taskName, taskTitle, taskID string, ...)
- func (eb *EventBus) PublishTaskFailed(testRunID, taskIndex uint64, taskName, taskTitle, taskID, errMsg string)
- func (eb *EventBus) PublishTaskLog(testRunID, taskIndex uint64, taskName, taskID, level, message string, ...)
- func (eb *EventBus) PublishTaskProgress(testRunID, taskIndex uint64, taskName, taskTitle, taskID string, ...)
- func (eb *EventBus) PublishTaskStarted(testRunID, taskIndex uint64, taskName, taskTitle, taskID string)
- func (eb *EventBus) PublishTestCompleted(testRunID uint64, testID, testName, status string)
- func (eb *EventBus) PublishTestFailed(testRunID uint64, testID, testName, errMsg string)
- func (eb *EventBus) PublishTestStarted(testRunID uint64, testID, testName string)
- func (eb *EventBus) Start(ctx context.Context) error
- func (eb *EventBus) Stop() error
- func (eb *EventBus) Subscribe(filter FilterFunc) *Subscriber
- func (eb *EventBus) Unsubscribe(sub *Subscriber)
- type EventType
- type FilterFunc
- type SSEHandler
- type SSEMiddleware
- type Subscriber
- type TaskCompletedData
- type TaskCreatedData
- type TaskFailedData
- type TaskLogData
- type TaskProgressData
- type TaskStartedData
- type TestCompletedData
- type TestFailedData
- type TestStartedData
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AuthTokenChecker ¶
AuthTokenChecker is a function that validates an authorization token.
type Bus ¶
type Bus interface {
Start(ctx context.Context) error
Stop() error
Publish(event *Event)
Subscribe(filter FilterFunc) *Subscriber
Unsubscribe(sub *Subscriber)
}
Bus is the interface for the event bus.
type ClientHeadUpdateData ¶
type ClientHeadUpdateData struct {
ClientIndex int `json:"clientIndex"`
ClientName string `json:"clientName"`
CLHeadSlot uint64 `json:"clHeadSlot"`
CLHeadRoot string `json:"clHeadRoot"`
ELHeadNumber uint64 `json:"elHeadNumber"`
ELHeadHash string `json:"elHeadHash"`
}
ClientHeadUpdateData contains data for client.head_update events.
type ClientStatusUpdateData ¶
type ClientStatusUpdateData struct {
ClientIndex int `json:"clientIndex"`
ClientName string `json:"clientName"`
CLStatus string `json:"clStatus"`
CLReady bool `json:"clReady"`
ELStatus string `json:"elStatus"`
ELReady bool `json:"elReady"`
}
ClientStatusUpdateData contains data for client.status_update events.
type Event ¶
type Event struct {
ID uint64 `json:"id"`
Type EventType `json:"type"`
Timestamp time.Time `json:"timestamp"`
TestRunID uint64 `json:"testRunId,omitempty"`
TaskIndex uint64 `json:"taskIndex,omitempty"`
Data json.RawMessage `json:"data,omitempty"`
}
Event represents a single event in the system.
func NewCustomEvent ¶
NewCustomEvent creates a new event with a custom event type string.
type EventBus ¶
type EventBus struct {
// contains filtered or unexported fields
}
EventBus is the default implementation of the Bus interface.
func NewEventBus ¶
func NewEventBus(logger logrus.FieldLogger) *EventBus
NewEventBus creates a new event bus.
func (*EventBus) NewCustomEvent ¶
func (eb *EventBus) NewCustomEvent(eventType string, testRunID, taskIndex uint64, data any) (*Event, error)
NewCustomEvent creates a new event with a custom event type string.
func (*EventBus) PublishClientHeadUpdate ¶
func (eb *EventBus) PublishClientHeadUpdate( clientIndex int, clientName string, clHeadSlot uint64, clHeadRoot string, elHeadNumber uint64, elHeadHash string, )
PublishClientHeadUpdate publishes a client head update event.
func (*EventBus) PublishClientStatusUpdate ¶
func (eb *EventBus) PublishClientStatusUpdate( clientIndex int, clientName string, clStatus string, clReady bool, elStatus string, elReady bool, )
PublishClientStatusUpdate publishes a client status update event.
func (*EventBus) PublishTaskCompleted ¶
func (eb *EventBus) PublishTaskCompleted( testRunID, taskIndex uint64, taskName, taskTitle, taskID, result string, )
PublishTaskCompleted publishes a task completed event.
func (*EventBus) PublishTaskCreated ¶
func (eb *EventBus) PublishTaskCreated( testRunID, taskIndex uint64, taskName, taskTitle, taskID string, parentIndex uint64, runConcurrent bool, )
PublishTaskCreated publishes a task created event.
func (*EventBus) PublishTaskFailed ¶
func (eb *EventBus) PublishTaskFailed( testRunID, taskIndex uint64, taskName, taskTitle, taskID, errMsg string, )
PublishTaskFailed publishes a task failed event.
func (*EventBus) PublishTaskLog ¶
func (eb *EventBus) PublishTaskLog( testRunID, taskIndex uint64, taskName, taskID, level, message string, fields map[string]any, )
PublishTaskLog publishes a task log event.
func (*EventBus) PublishTaskProgress ¶
func (eb *EventBus) PublishTaskProgress( testRunID, taskIndex uint64, taskName, taskTitle, taskID string, progress float64, message string, )
PublishTaskProgress publishes a task progress event.
func (*EventBus) PublishTaskStarted ¶
func (eb *EventBus) PublishTaskStarted( testRunID, taskIndex uint64, taskName, taskTitle, taskID string, )
PublishTaskStarted publishes a task started event.
func (*EventBus) PublishTestCompleted ¶
PublishTestCompleted publishes a test completed event.
func (*EventBus) PublishTestFailed ¶
PublishTestFailed publishes a test failed event.
func (*EventBus) PublishTestStarted ¶
PublishTestStarted publishes a test started event.
func (*EventBus) Subscribe ¶
func (eb *EventBus) Subscribe(filter FilterFunc) *Subscriber
Subscribe creates a new subscription with an optional filter.
func (*EventBus) Unsubscribe ¶
func (eb *EventBus) Unsubscribe(sub *Subscriber)
Unsubscribe removes a subscriber from the event bus.
type EventType ¶
type EventType string
EventType represents the type of event being published.
const ( EventTestStarted EventType = "test.started" EventTestCompleted EventType = "test.completed" EventTestFailed EventType = "test.failed" )
Event types for test lifecycle.
const ( EventTaskCreated EventType = "task.created" EventTaskStarted EventType = "task.started" EventTaskProgress EventType = "task.progress" EventTaskCompleted EventType = "task.completed" EventTaskFailed EventType = "task.failed" EventTaskLog EventType = "task.log" )
Event types for task lifecycle.
type FilterFunc ¶
FilterFunc is a function that filters events for a subscriber.
func CombineFilters ¶
func CombineFilters(filters ...FilterFunc) FilterFunc
CombineFilters combines multiple filters with AND logic.
func CreateEventTypeFilter ¶
func CreateEventTypeFilter(eventTypes ...EventType) FilterFunc
CreateEventTypeFilter creates a filter for specific event types.
func CreateTestRunFilter ¶
func CreateTestRunFilter(testRunID uint64) FilterFunc
CreateTestRunFilter creates a filter for a specific test run.
type SSEHandler ¶
type SSEHandler struct {
// contains filtered or unexported fields
}
SSEHandler handles Server-Sent Events connections.
func NewSSEHandler ¶
func NewSSEHandler(logger logrus.FieldLogger, eventBus *EventBus) *SSEHandler
NewSSEHandler creates a new SSE handler.
func NewSSEHandlerWithAuth ¶
func NewSSEHandlerWithAuth(logger logrus.FieldLogger, eventBus *EventBus, authChecker AuthTokenChecker, requireAuthLog bool) *SSEHandler
NewSSEHandlerWithAuth creates a new SSE handler with authentication support.
func (*SSEHandler) HandleClientStream ¶
func (h *SSEHandler) HandleClientStream(w http.ResponseWriter, r *http.Request)
HandleClientStream handles the client events stream endpoint.
func (*SSEHandler) HandleGlobalStream ¶
func (h *SSEHandler) HandleGlobalStream(w http.ResponseWriter, r *http.Request)
HandleGlobalStream handles the global event stream endpoint.
func (*SSEHandler) HandleTestRunStream ¶
func (h *SSEHandler) HandleTestRunStream(w http.ResponseWriter, r *http.Request, testRunID uint64)
HandleTestRunStream handles the per-test event stream endpoint.
type SSEMiddleware ¶
type SSEMiddleware struct {
// contains filtered or unexported fields
}
SSEMiddleware wraps an SSE handler with common functionality.
func NewSSEMiddleware ¶
func NewSSEMiddleware(logger logrus.FieldLogger, eventBus *EventBus) *SSEMiddleware
NewSSEMiddleware creates a new SSE middleware.
func (*SSEMiddleware) GlobalStreamHandler ¶
func (m *SSEMiddleware) GlobalStreamHandler() http.HandlerFunc
GlobalStreamHandler returns an http.HandlerFunc for the global event stream.
func (*SSEMiddleware) TestRunStreamHandler ¶
func (m *SSEMiddleware) TestRunStreamHandler(testRunID uint64) http.HandlerFunc
TestRunStreamHandler returns a function that creates handlers for test run streams.
type Subscriber ¶
type Subscriber struct {
// contains filtered or unexported fields
}
Subscriber represents a subscriber to the event bus.
func (*Subscriber) Channel ¶
func (s *Subscriber) Channel() <-chan *Event
Channel returns the channel for receiving events.
type TaskCompletedData ¶
type TaskCompletedData struct {
TaskName string `json:"taskName"`
TaskTitle string `json:"taskTitle"`
TaskID string `json:"taskId,omitempty"`
Result string `json:"result"`
}
TaskCompletedData contains data for task.completed events.
type TaskCreatedData ¶
type TaskCreatedData struct {
TaskName string `json:"taskName"`
TaskTitle string `json:"taskTitle"`
TaskID string `json:"taskId,omitempty"`
ParentIndex uint64 `json:"parentIndex"`
RunConcurrent bool `json:"runConcurrent,omitempty"`
}
TaskCreatedData contains data for task.created events.
type TaskFailedData ¶
type TaskFailedData struct {
TaskName string `json:"taskName"`
TaskTitle string `json:"taskTitle"`
TaskID string `json:"taskId,omitempty"`
Error string `json:"error,omitempty"`
}
TaskFailedData contains data for task.failed events.
type TaskLogData ¶
type TaskLogData struct {
TaskName string `json:"taskName"`
TaskID string `json:"taskId,omitempty"`
Level string `json:"level"`
Message string `json:"message"`
Fields map[string]any `json:"fields,omitempty"`
Timestamp time.Time `json:"timestamp"`
}
TaskLogData contains data for task.log events.
type TaskProgressData ¶
type TaskProgressData struct {
TaskName string `json:"taskName"`
TaskTitle string `json:"taskTitle"`
TaskID string `json:"taskId,omitempty"`
Progress float64 `json:"progress"`
Message string `json:"message,omitempty"`
}
TaskProgressData contains data for task.progress events.
type TaskStartedData ¶
type TaskStartedData struct {
TaskName string `json:"taskName"`
TaskTitle string `json:"taskTitle"`
TaskID string `json:"taskId,omitempty"`
}
TaskStartedData contains data for task.started events.
type TestCompletedData ¶
type TestCompletedData struct {
TestID string `json:"testId"`
TestName string `json:"testName"`
Status string `json:"status"`
}
TestCompletedData contains data for test.completed events.
type TestFailedData ¶
type TestFailedData struct {
TestID string `json:"testId"`
TestName string `json:"testName"`
Error string `json:"error,omitempty"`
}
TestFailedData contains data for test.failed events.
type TestStartedData ¶
TestStartedData contains data for test.started events.