event

package
v0.5.11 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package event provides domain event interfaces for event-driven architectures.

The package defines core abstractions for implementing event sourcing and publish-subscribe patterns:

  • Event: marker interface for domain events with a Topic() method
  • EventPublisher: interface for publishing events to a message broker
  • EventSubscriber: interface for subscribing to events from a message broker
  • EventFactoryFn: factory function type for creating event instances
  • EventHandlerFn: handler function type for processing events

These interfaces are designed to be implemented by concrete message broker adapters (e.g., Kafka, NATS, in-memory) while keeping domain code decoupled from infrastructure concerns.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Event

type Event interface {
	Topic() string
}

Event represents a domain event. It is a marker interface that defines the contract for domain events. The event should be immutable and contain all the necessary information. It should be created using the EventFactoryFn.

type EventFactoryFn

type EventFactoryFn func() Event

EventFactoryFn is a (factory) function that creates a new event.

type EventHandlerFn

type EventHandlerFn func(e Event) error

EventHandlerFn is a (handler) function that handles an event.

type EventPublisher

type EventPublisher interface {
	Publish(ctx context.Context, e Event) error
}

EventPublisher represents the publisher for events. It is a marker interface that defines the contract for event publishers.

type EventSubscriber

type EventSubscriber interface {
	Subscribe(ctx context.Context, topic string, factory EventFactoryFn, handler EventHandlerFn) error
}

EventSubscriber interface defines the contract for subscribing to events. It is a marker interface that defines the contract for event subscribers. It uses EventFactoryFn to create events and EventHandlerFn to handle events.

Jump to

Keyboard shortcuts

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