events

package
v0.35.1 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ThingCreate                = thingPrefix + "create"
	ThingUpdate                = thingPrefix + "update"
	ThingUpdateGroupAndProfile = thingPrefix + "update_group_and_profile"
	ThingRemove                = thingPrefix + "remove"

	ProfileCreate = profilePrefix + "create"
	ProfileUpdate = profilePrefix + "update"
	ProfileRemove = profilePrefix + "remove"

	GroupRemove = groupPrefix + "remove"

	OrgCreate = orgPrefix + "create"
	OrgRemove = orgPrefix + "remove"

	ThingsStream = mainfluxPrefix + "things"
	AuthStream   = mainfluxPrefix + "auth"
)

Variables

View Source
var (
	// ErrEmptyStream is returned when stream name is empty.
	ErrEmptyStream = errors.New("stream name cannot be empty")

	// ErrEmptyConsumer is returned when consumer name is empty.
	ErrEmptyConsumer = errors.New("consumer name cannot be empty")

	// ErrEmptyGroup is returned when consumer group name is empty.
	ErrEmptyGroup = errors.New("consumer group cannot be empty")
)

Functions

func ReadField added in v0.34.0

func ReadField(event map[string]any, key, def string) string

ReadField returns the string value stored under the given map key. If the key is missing or not a string, it returns the provided default.

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 Subscriber

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

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

Subscriber specifies event subscription API.

func NewSubscriber added in v0.34.0

func NewSubscriber(url, stream, group, consumer string, logger logger.Logger) (Subscriber, error)

Jump to

Keyboard shortcuts

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