events

package
v2.2.12 Latest Latest
Warning

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

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

Documentation

Overview

Package events provides a framework for defining, handling, and processing asynchronous events. It defines an Event interface for event handling, a base implementation for common functionality, and utilities for event processing with context-aware cancellation and timeout support. The package is designed to facilitate event-driven architectures by enabling decoupled event processing and result reporting via channels.

Index

Constants

View Source
const EventTimeout = 3 * time.Second

EventTimeout defines the default timeout for event handling responses

Variables

This section is empty.

Functions

func NewSink

func NewSink(ctx context.Context) chan<- Event

NewSink creates a channel to receive events and starts a goroutine to process them

Types

type Event

type Event interface {
	// Handle processes the event and returns any error
	Handle(ctx context.Context) error

	// Output returns a channel for sending results back to the caller
	Output() chan<- error
}

Event is an interface that defines methods to handle events

type EventBase

type EventBase struct {
	Out chan<- error // channel to send error back to the caller
}

EventBase provides common functionality for events

func (EventBase) Output

func (e EventBase) Output() chan<- error

Output returns the output channel for the event

Jump to

Keyboard shortcuts

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