events

package
v0.0.0-...-4ee07f5 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2024 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const (
	UnpublishedEventsCheckInterval        = 1 * time.Minute
	ConnCheckInterval                     = 100 * time.Millisecond
	MaxUnpublishedEvents           uint64 = 1e4
	MaxEventStreamLen              int64  = 1e6
)

Variables

This section is empty.

Functions

func Read

func Read[T any](event map[string]interface{}, key string, def T) T

Read reads value from event map. If value is not of type T, returns default value.

func ReadStringSlice

func ReadStringSlice(event map[string]interface{}, key string) []string

ReadStringSlice reads string slice from event map. If value is not a string slice, returns empty slice.

Types

type Event

type Event interface {
	// Encode encodes event to map.
	Encode() (map[string]interface{}, error)
}

Event represents an event.

type EventHandler

type EventHandler interface {
	// Handle handles events passed by underlying implementation.
	Handle(ctx context.Context, event Event) error
}

EventHandler represents event handler for Subscriber.

type Publisher

type Publisher interface {
	// Publish publishes event to stream.
	Publish(ctx context.Context, event Event) error

	// Close gracefully closes event publisher's connection.
	Close() error
}

Publisher specifies events publishing API.

type Subscriber

type Subscriber interface {
	// Subscribe subscribes to the event stream and consumes events.
	Subscribe(ctx context.Context, cfg SubscriberConfig) error

	// Close gracefully closes event subscriber's connection.
	Close() error
}

Subscriber specifies event subscription API.

type SubscriberConfig

type SubscriberConfig struct {
	Consumer string
	Stream   string
	Handler  EventHandler
}

SubscriberConfig represents event subscriber configuration.

Directories

Path Synopsis
Package redis contains the domain concept definitions needed to support Magistrala redis events source service functionality.
Package redis contains the domain concept definitions needed to support Magistrala redis events source service functionality.
Package redis contains the domain concept definitions needed to support Magistrala redis events source service functionality.
Package redis contains the domain concept definitions needed to support Magistrala redis events source service functionality.
Package redis contains the domain concept definitions needed to support Magistrala redis events source service functionality.
Package redis contains the domain concept definitions needed to support Magistrala redis events source service functionality.

Jump to

Keyboard shortcuts

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