messaging

package
v0.0.11 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2020 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MaxInt32   = 1<<31 - 1
	MaxRetries = MaxInt32
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Connection

type Connection interface {
	Consumer(autoAck bool, exchange, queue string) (Consumer, error)
	Producer(exchange string) (Producer, error)
	Close()
}

type Consumer

type Consumer interface {
	Subscribe(action string, handler EventHandler, options *SubscribeOptions) error
	Unsubscribe(action string) error
	BindActions(actions ...string) error
	UnbindActions(actions ...string) error
	Consume()
	Close()
}

type Event

type Event struct {
	Id        string
	Action    string
	Timestamp time.Time
	Body      []byte
	Ack       func(multiple bool) error
	Nack      func(multiple, requeue bool) error
	Reject    func(requeue bool) error
	Manual    func()
	// contains filtered or unexported fields
}

func (Event) Context

func (e Event) Context() context.Context

Context returns the current context; if nil, it defaults to the background context. To change the context, use WithContext.

func (Event) WithContext

func (e Event) WithContext(ctx context.Context) Event

WithContext returns a shallow copy of Event with its context changed to ctx. The provided ctx must be non-nil.

type EventHandler

type EventHandler func(Event) error

type Producer

type Producer interface {
	Publish(action string, data []byte)
	NotifyClose() <-chan bool
	Close()
}

type SubscribeOptions

type SubscribeOptions struct {
	// The time to retry after it fails.
	RetryDelay time.Duration
	// If enable the retry time it will be incresed in power of two.
	// This means if your retry delay is 1s, the first retry will be after 1s,
	// the sencond 2s, the third 4s and so on.
	DelayedRetry bool
	// Max attempts to retry.
	MaxRetries int32
}

Jump to

Keyboard shortcuts

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