publisher

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultStreamName is the JetStream stream for test events
	DefaultStreamName = "tests_events"
	// DefaultSubjectPrefix is the subject prefix for test events
	DefaultSubjectPrefix = "tests.events.v1"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Event

type Event struct {
	Type      EventType       `json:"type"`
	Timestamp time.Time       `json:"timestamp"`
	Data      json.RawMessage `json:"data"`
}

Event represents a generic event wrapper for publishing

type EventType

type EventType string

EventType represents the type of event being published

const (
	EventTypeTestBegin   EventType = "test.begin"
	EventTypeTestEnd     EventType = "test.end"
	EventTypeStepBegin   EventType = "step.begin"
	EventTypeStepEnd     EventType = "step.end"
	EventTypeSuiteBegin  EventType = "suite.begin"
	EventTypeSuiteEnd    EventType = "suite.end"
	EventTypeTestFailure EventType = "test.failure"
	EventTypeTestError   EventType = "test.error"
	EventTypeStdOutput   EventType = "stdout"
	EventTypeStdError    EventType = "stderr"
	EventTypeHeartbeat   EventType = "heartbeat"
	EventTypeRunEnd      EventType = "run.end"
	EventTypeRunStart    EventType = "run.start"
)

type NATSConfig

type NATSConfig struct {
	URL           string
	StreamName    string
	SubjectPrefix string
}

NATSConfig holds configuration for NATS publisher

type NATSPublisher

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

NATSPublisher wraps a NATS JetStream connection for publishing events

func NewNATSPublisher

func NewNATSPublisher(cfg NATSConfig, logger *slog.Logger) (*NATSPublisher, error)

NewNATSPublisher creates a new NATS JetStream publisher If logger is nil, a no-op logger is used

func (*NATSPublisher) Close

func (p *NATSPublisher) Close() error

Close closes the NATS connection

func (*NATSPublisher) Publish

func (p *NATSPublisher) Publish(ctx context.Context, eventType EventType, data interface{}) error

Publish publishes an event to NATS JetStream

Jump to

Keyboard shortcuts

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