events

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: May 28, 2025 License: AGPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Encoder

type Encoder interface {
	Encode(v interface{}) ([]byte, error)
	Decode(data []byte) (interface{}, error)
}

type Event

type Event struct {
	Subject  string            `json:"subject"`            // The exact subject name
	Data     interface{}       `json:"data"`               // The actual event data
	Metadata map[string]string `json:"metadata,omitempty"` // Optional metadata like timestamps, IDs, etc.
}

type LocalDispatcher

type LocalDispatcher struct {
	// contains filtered or unexported fields
}

func NewLocalDispatcher

func NewLocalDispatcher(ctx context.Context) *LocalDispatcher

NewLocalDispatcher creates a new LocalDispatcher with a dedicated goroutine for processing.

func (*LocalDispatcher) Publish

func (ed *LocalDispatcher) Publish(subject string, data interface{}) error

Publish sends a message to all subscribers of the given subject.

func (*LocalDispatcher) Subscribe

func (ed *LocalDispatcher) Subscribe(name string, subjects ...string) (<-chan Event, func())

type NatsDispatcher

type NatsDispatcher struct {
	// contains filtered or unexported fields
}

func NewNatsDispatcher

func NewNatsDispatcher(ctx context.Context, nc *nats.Conn, handler Encoder) (*NatsDispatcher, error)

NewNatsDispatcher creates a new NatsDispatcher with a dedicated goroutine for processing.

func (*NatsDispatcher) Close

func (d *NatsDispatcher) Close()

Close stops the dispatcher and cleans up resources.

func (*NatsDispatcher) Publish

func (d *NatsDispatcher) Publish(subject string, data interface{}) error

Publish sends a message to all subscribers of the given subject.

func (*NatsDispatcher) Subscribe

func (d *NatsDispatcher) Subscribe(name string, subjects ...string) (<-chan Event, func())

type NatsJetDispatcher

type NatsJetDispatcher struct {
	// contains filtered or unexported fields
}

func NewNatsJetDispatcher

func NewNatsJetDispatcher(ctx context.Context, nc *nats.Conn, handler Encoder) (*NatsJetDispatcher, error)

NewNatsJetDispatcher creates a new NatsJetDispatcher with a dedicated goroutine for processing.

func (*NatsJetDispatcher) Publish

func (d *NatsJetDispatcher) Publish(subject string, data interface{}) error

Publish sends a message to all subscribers of the given subject.

func (*NatsJetDispatcher) Subscribe

func (d *NatsJetDispatcher) Subscribe(name string, subjects ...string) (<-chan Event, func())

type StreamConsumer

type StreamConsumer struct {
	// contains filtered or unexported fields
}

type SubjectConsumer

type SubjectConsumer struct {
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

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