messaging

package
v0.0.0-...-984c388 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2023 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidSchemaType = errors.New("bus: invalid schema type")
	ErrSchemaNotFound    = errors.New("bus: schema not found")
)

Functions

This section is empty.

Types

type Bus

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

func NewBus

func NewBus(w Writer, r Reader) *Bus

func (*Bus) Publish

func (b *Bus) Publish(ctx context.Context, events []domain.Event) error

func (*Bus) Register

func (b *Bus) Register(stream string, v any) error

func (*Bus) Shutdown

func (b *Bus) Shutdown()

func (*Bus) Start

func (b *Bus) Start()

func (*Bus) Subscribe

func (b *Bus) Subscribe(stream, group string, subscriberFunc SubscriberFunc)

type Message

type Message struct {
	ID          string    `json:"message_id"`
	Time        time.Time `json:"message_time"`
	TimeUsec    int64     `json:"message_time_microseconds"`
	StreamName  string    `json:"stream_name"`
	Key         string    `json:"message_key"`
	ContentType string    `json:"content_type"`
	Data        []byte    `json:"data"`
}

type Reader

type Reader interface {
	Read(ctx context.Context, task ReaderTask) error
}

type ReaderTask

type ReaderTask struct {
	Stream  string
	GroupID string
	Handler SubscriberFunc
}

type SubscriberFunc

type SubscriberFunc func(ctx context.Context, message Message) error

type Writer

type Writer interface {
	Write(ctx context.Context, msgs []Message) error
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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