Event Bus Hook (hooks/bus.go)

iota-sdk · pkg/bichat/hooks/bus.go · go · Apache-2.0
realtime, automation, lang:go, tag:events, tag:concurrency

A thread-safe event distribution system for registering and publishing events across application components. Use this to decouple event producers from consumers in Go applications.

// Source: https://github.com/iota-uz/iota-sdk | License: Apache-2.0 | Copyright You must retain, in the Source form of any Derivative Works
// Provided via justclaw.it.com; keep this notice with the code.
// Package hooks provides this package.
package hooks

import (
	"context"
	"sync"
)

// EventBus distributes events to registered handlers.
// Implementations must be thread-safe.
type EventBus interface {
	// Publish sends an event to all registered handlers.
	// Handlers are called synchronously in registration order.
	// If a handler returns an error, it is logged but does not stop other handlers.
	Publish(ctx context.Context, event Event) error

	// Subscribe registers a handler for specific event types.
	// Returns an unsubscribe function to remove the handler.
	// If no types are 

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key