event

package
v0.0.0-...-764ed56 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2021 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Emitter

type Emitter interface {
	Publish(ctx context.Context, event string, message interface{}, metadata map[string]interface{}) error
	Push(ctx context.Context, event, key string, message interface{}, metadata map[string]interface{}) error
}

Emitter event emitter

func NewEmitter

func NewEmitter(ctx context.Context, conf config.Getter) (Emitter, error)

NewEmitter create event emitter instance

type EmitterCache

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

EmitterCache emitter key cache

func NewEmitterCache

func NewEmitterCache(URL string) (*EmitterCache, error)

NewEmitterCache new emitter cache

type EventConfig

type EventConfig struct {
	Metadata map[string]map[string]interface{} `json:"metadata,omitempty" mapstructure:"metadata"`
	EventMap map[string]string                 `json:"event_map,omitempty" mapstructure:"event_map"`
}

type EventMessage

type EventMessage struct {
	Data     interface{}            `json:"data,omitempty" mapstructure:"data"`
	Metadata map[string]interface{} `json:"metadata,omitempty" mapstructure:"metadata"`
}

EventMessage event message

func (*EventMessage) ToBytes

func (m *EventMessage) ToBytes() ([]byte, error)

type Hybrid

type Hybrid struct {
	CollectionURL string      `json:"collection_url,omitempty" mapstructure:"collection_url"`
	CacheURL      string      `json:"cache_url,omitempty" mapstructure:"cache_url"`
	Config        EventConfig `json:"config,omitempty" mapstructure:"config"`
	PubsubURL     string      `json:"pubsub_url,omitempty" mapstructure:"pubsub_url"`
	KafkaBroker   string      `json:"kafka_broker,omitempty" mapstructure:"kafka_broker"`
	// contains filtered or unexported fields
}

Hybrid hybrid outbox pubsub repository

func NewHybridEmitter

func NewHybridEmitter(ctx context.Context, conf config.Getter) (*Hybrid, error)

NewHybridEmitter create instance of hybrid emitter

func (*Hybrid) Publish

func (h *Hybrid) Publish(ctx context.Context, event string, message interface{}, metadata map[string]interface{}) error

Publish publish message

func (*Hybrid) Push

func (h *Hybrid) Push(ctx context.Context, event, key string, message interface{}, metadata map[string]interface{}) error

Push publish sequential event

type Outbox

type Outbox struct {
	CollectionURL string      `json:"collection_url,omitempty" mapstructure:"collection_url"`
	CacheURL      string      `json:"cache_url,omitempty" mapstructure:"cache_url"`
	Config        EventConfig `json:"config,omitempty" mapstructure:"config"`
	// contains filtered or unexported fields
}

Outbox outbox repository

func NewOutboxEmitter

func NewOutboxEmitter(ctx context.Context, conf config.Getter) (*Outbox, error)

NewOutboxEmitter create outbox emitter instance

func (*Outbox) Publish

func (o *Outbox) Publish(ctx context.Context, event string, message interface{}, metadata map[string]interface{}) error

Publish store message to outbox

func (*Outbox) Push

func (o *Outbox) Push(ctx context.Context, event, key string, message interface{}, metadata map[string]interface{}) error

Push publish sequential event

type OutboxRecord

type OutboxRecord struct {
	ID         string    `json:"_id,omitempty" mapstructure:"_id" docstore:"_id"`
	GroupID    string    `json:"group_id,omitempty" mapstructure:"group_id" docstore:"group_id"`
	KafkaTopic string    `json:"kafka_topic,omitempty" mapstructure:"kafka_topic" docstore:"kafka_topic"`
	KafkaKey   string    `json:"kafka_key,omitempty" mapstructure:"kafka_key" docstore:"kafka_key"`
	KafkaValue string    `json:"kafka_value,omitempty" mapstructure:"kafka_value" docstore:"kafka_value"`
	CreatedAt  time.Time `json:"created_at,omitempty" mapstructure:"created_at" docstore:"created_at"`
}

OutboxRecord outbox model

func (*OutboxRecord) GenerateID

func (o *OutboxRecord) GenerateID() *OutboxRecord

GenerateID generate record ID

func (*OutboxRecord) Hash

func (o *OutboxRecord) Hash() []byte

Hash calculate request hash

type PubSub

type PubSub struct {
	Config      EventConfig `json:"config,omitempty" mapstructure:"config"`
	CacheURL    string      `json:"cache_url,omitempty" mapstructure:"cache_url"`
	PubsubURL   string      `json:"pubsub_url,omitempty" mapstructure:"pubsub_url"`
	KafkaBroker string      `json:"kafka_broker,omitempty" mapstructure:"kafka_broker"`
	// contains filtered or unexported fields
}

PubSub pubsub event emitter

func NewPubSubEmitter

func NewPubSubEmitter(ctx context.Context, conf config.Getter) (*PubSub, error)

NewPubSubEmitter create instance of pubsub emitter

func (*PubSub) Publish

func (p *PubSub) Publish(ctx context.Context, event string, message interface{}, metadata map[string]interface{}) error

Publish publish message

func (*PubSub) Push

func (p *PubSub) Push(ctx context.Context, event string, key string, message interface{}, metadata map[string]interface{}) error

Push publish sequential event

Jump to

Keyboard shortcuts

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