eventbus

package
v0.0.0-...-a504e3d Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2022 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNilMessage = errors.New("nil message")
)

Functions

This section is empty.

Types

type Message

type Message struct {
	ID      string            `json:"id"`
	Key     string            `json:"key"`
	Headers map[string]string `json:"headers"`
	Body    string            `json:"body"`
}

type MessageHandler

type MessageHandler func(message *Message)

type Publisher

type Publisher interface {
	Publish(ctx context.Context, msg *Message) error
}

func NewEventBridgePublisher

func NewEventBridgePublisher(sess *session.Session, cfg *PublisherConfig) (Publisher, error)

type PublisherConfig

type PublisherConfig struct {
	Source       string
	EventBusName string
}

type SqsMessage

type SqsMessage struct {
	Version    string    `json:"version"`
	ID         string    `json:"id"`
	DetailType string    `json:"detail-type"`
	Source     string    `json:"source"`
	Account    string    `json:"account"`
	Time       time.Time `json:"time"`
	Region     string    `json:"region"`
	Detail     *Message  `json:"detail"`
}

type Subscriber

type Subscriber interface {
	Subscribe(key string, fn MessageHandler)
	Start(ctx context.Context) error
	Stop()
}

func NewSQSSubscriber

func NewSQSSubscriber(sess *session.Session, cfg *SubscriberConfig) (Subscriber, error)

type SubscriberConfig

type SubscriberConfig struct {
	Source         string
	EventBusName   string
	QueueUrl       string
	MaxWorker      int
	MaxMsg         int
	DefaultHandler MessageHandler
	Timeout        time.Duration
}

Jump to

Keyboard shortcuts

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