Documentation
¶
Index ¶
- Variables
- type BufferedEvent
- type Classifier
- type EventClassification
- type NATSConsumer
- type NATSConsumerConfig
- type ReconciliationBuffer
- func (rb *ReconciliationBuffer) BufferEvent(runID string, event publisher.Event) error
- func (rb *ReconciliationBuffer) DeleteBuffer(runID string)
- func (rb *ReconciliationBuffer) GetAllBuffers() map[string]*RunBuffer
- func (rb *ReconciliationBuffer) GetBuffer(runID string) (*RunBuffer, bool)
- func (rb *ReconciliationBuffer) MarkRootSuiteEnd(runID string) error
- func (rb *ReconciliationBuffer) SetInactivityCallback(callback func(ctx context.Context, runID string))
- func (rb *ReconciliationBuffer) StartCleanupLoop(ctx context.Context)
- func (rb *ReconciliationBuffer) StopCleanupLoop()
- func (rb *ReconciliationBuffer) UpdateBufferStatus(runID string, status ReconciliationStatus)
- type ReconciliationConfig
- type ReconciliationStatus
- type RunBuffer
Constants ¶
This section is empty.
Variables ¶
var ( // ErrBufferFull is returned when a buffer reaches its size limit ErrBufferFull = errors.New("buffer full") )
Functions ¶
This section is empty.
Types ¶
type BufferedEvent ¶
type BufferedEvent struct {
Event publisher.Event
Timestamp time.Time
Type publisher.EventType
AttemptCount int
}
BufferedEvent represents an event waiting for reconciliation
type Classifier ¶
type Classifier struct {
// contains filtered or unexported fields
}
Classifier determines if an event can be immediately processed or needs buffering
func NewClassifier ¶
func NewClassifier(logger *slog.Logger) *Classifier
NewClassifier creates a new event classifier
func (*Classifier) Classify ¶
func (c *Classifier) Classify(ctx context.Context, event publisher.Event) (EventClassification, error)
Classify determines how an event should be processed
type EventClassification ¶
type EventClassification string
EventClassification indicates how an event should be processed
const ( // ClassifyImmediate means the event can be processed immediately ClassifyImmediate EventClassification = "immediate" // ClassifyBuffer means the event should be buffered for reconciliation ClassifyBuffer EventClassification = "buffer" // ClassifyReconcile means the event is a root suite end that triggers reconciliation ClassifyReconcile EventClassification = "reconcile" )
type NATSConsumer ¶ added in v0.2.0
type NATSConsumer struct {
// contains filtered or unexported fields
}
NATSConsumer wraps a NATS JetStream consumer for processing test events. Structured run, suite, test, and attempt data is persisted to PostgreSQL, while MongoDB is retained only for the live step buffer used during in-flight execution.
func NewNATSConsumer ¶ added in v0.2.0
func NewNATSConsumer(cfg NATSConsumerConfig, logger *slog.Logger, bufferRepo *mongodb.MongoRepository, pgRepo *postgres.PostgresRepository) (*NATSConsumer, error)
NewNATSConsumer creates a new NATS JetStream consumer with Postgres backend and MongoDB-backed live step buffer support.
func (*NATSConsumer) Close ¶ added in v0.2.0
func (c *NATSConsumer) Close() error
Close closes the NATS connection
func (*NATSConsumer) Start ¶ added in v0.2.0
func (c *NATSConsumer) Start(ctx context.Context, cfg NATSConsumerConfig) error
Start begins consuming messages from NATS
type NATSConsumerConfig ¶ added in v0.2.0
type NATSConsumerConfig struct {
URL string
StreamName string
ConsumerName string
BatchSize int
MaxWait time.Duration
MaxDeliver int
AckWait time.Duration
DLQSubject string
DeferQueueMaxAttempts int
DeferQueueTTL time.Duration
RetainMessages bool // Deprecated no-op; legacy raw message retention was removed.
}
NATSConsumerConfig holds configuration for NATS consumer
type ReconciliationBuffer ¶
type ReconciliationBuffer struct {
// contains filtered or unexported fields
}
ReconciliationBuffer manages buffered events for multiple test runs
func NewReconciliationBuffer ¶
func NewReconciliationBuffer(cfg ReconciliationConfig, logger *slog.Logger) *ReconciliationBuffer
NewReconciliationBuffer creates a new reconciliation buffer manager
func (*ReconciliationBuffer) BufferEvent ¶
func (rb *ReconciliationBuffer) BufferEvent(runID string, event publisher.Event) error
BufferEvent adds an event to the buffer for the given runID
func (*ReconciliationBuffer) DeleteBuffer ¶
func (rb *ReconciliationBuffer) DeleteBuffer(runID string)
DeleteBuffer removes a buffer after successful reconciliation
func (*ReconciliationBuffer) GetAllBuffers ¶
func (rb *ReconciliationBuffer) GetAllBuffers() map[string]*RunBuffer
GetAllBuffers returns a snapshot of all buffers (for inspection/monitoring)
func (*ReconciliationBuffer) GetBuffer ¶
func (rb *ReconciliationBuffer) GetBuffer(runID string) (*RunBuffer, bool)
GetBuffer retrieves a buffer for a run (thread-safe read)
func (*ReconciliationBuffer) MarkRootSuiteEnd ¶
func (rb *ReconciliationBuffer) MarkRootSuiteEnd(runID string) error
MarkRootSuiteEnd marks that a root suite end event has been received
func (*ReconciliationBuffer) SetInactivityCallback ¶
func (rb *ReconciliationBuffer) SetInactivityCallback(callback func(ctx context.Context, runID string))
SetInactivityCallback sets the callback function for inactivity timeouts
func (*ReconciliationBuffer) StartCleanupLoop ¶
func (rb *ReconciliationBuffer) StartCleanupLoop(ctx context.Context)
StartCleanupLoop starts the background cleanup goroutine
func (*ReconciliationBuffer) StopCleanupLoop ¶
func (rb *ReconciliationBuffer) StopCleanupLoop()
StopCleanupLoop stops the cleanup loop
func (*ReconciliationBuffer) UpdateBufferStatus ¶
func (rb *ReconciliationBuffer) UpdateBufferStatus(runID string, status ReconciliationStatus)
UpdateBufferStatus updates the reconciliation status of a buffer
type ReconciliationConfig ¶
type ReconciliationConfig struct {
// Enabled controls whether reconciliation is active
Enabled bool
// MaxBufferSize is the maximum number of events to buffer per run
MaxBufferSize int
// InactivityTTL is the duration after last event before triggering reconciliation
InactivityTTL time.Duration
// MaxPasses is the maximum number of reconciliation passes to attempt
MaxPasses int
// PassDelay is the delay between reconciliation passes
PassDelay time.Duration
// CleanupInterval is how often to check for inactive buffers
CleanupInterval time.Duration
}
ReconciliationConfig holds configuration for event reconciliation
func DefaultReconciliationConfig ¶
func DefaultReconciliationConfig() ReconciliationConfig
DefaultReconciliationConfig returns configuration with sensible defaults
func LoadReconciliationConfigFromEnv ¶
func LoadReconciliationConfigFromEnv() ReconciliationConfig
LoadReconciliationConfigFromEnv loads reconciliation configuration from environment variables Falls back to defaults if environment variables are not set
type ReconciliationStatus ¶
type ReconciliationStatus string
ReconciliationStatus represents the state of reconciliation for a run
const ( StatusPending ReconciliationStatus = "pending" StatusInProgress ReconciliationStatus = "in_progress" StatusCompleted ReconciliationStatus = "completed" StatusPartial ReconciliationStatus = "partial" StatusFailed ReconciliationStatus = "failed" )
type RunBuffer ¶
type RunBuffer struct {
RunID string
Events []BufferedEvent
FirstSeen time.Time
LastActivity time.Time // Refreshes on ANY event for this runID
RootSuiteEndReceived bool
ReconciliationStatus ReconciliationStatus
// contains filtered or unexported fields
}
RunBuffer holds buffered events for a specific test run