Documentation ¶
Overview ¶
Package snorlax provides tools for message query based microservices:
- Configuration through environment;
- Logging through standard log;
- Use only one transport = amqp through RabbitMQ;
- Use only one exchange type for all = topic;
No registry, service discovery and other smart things. Let k8s do the rest.
Index ¶
- Variables
- func Exchange(exchange string) func(*opts)
- func PublisherSource(source string) func(*pubOpts)
- func PublisherWrapper(w PubWrapper) func(*pubOpts)
- func QOS(prefetchCount int) func(*opts)
- func SubscriberAutoAck() func(*subOpts)
- func SubscriberAutoDelete() func(*subOpts)
- func SubscriberExclusive() func(*subOpts)
- func SubscriberNotDurable() func(*subOpts)
- func SubscriberQueue(queue string) func(*subOpts)
- func SubscriberWrapper(w SubWrapper) func(*subOpts)
- func TLS(t *tls.Config) func(*opts)
- func ToContext(ctx context.Context, h Headers) context.Context
- func URL(url string) func(*opts)
- type Handler
- type HeaderOption
- type Headers
- type Option
- type PubFn
- type PubWrapper
- type Publisher
- type PublisherOption
- type Snorlax
- func (s *Snorlax) Close() error
- func (s *Snorlax) IsClosed() bool
- func (s *Snorlax) MustPublisher(optsf ...PublisherOption) *Publisher
- func (s *Snorlax) MustSubscriber(optsf ...SubscriberOption) *Subscriber
- func (s *Snorlax) NewPublisher(optsf ...PublisherOption) (*Publisher, error)
- func (s *Snorlax) NewSubscriber(optsf ...SubscriberOption) (*Subscriber, error)
- func (s *Snorlax) QueueUnbind(queue, topic string) error
- type SubWrapper
- type Subscriber
- type SubscriberOption
Constants ¶
This section is empty.
Variables ¶
Functions ¶
func Exchange ¶ added in v1.4.0
func Exchange(exchange string) func(*opts)
Exchange sets default exchange. Default to "amq.Topic".
func PublisherSource ¶ added in v1.0.0
func PublisherSource(source string) func(*pubOpts)
func PublisherWrapper ¶
func PublisherWrapper(w PubWrapper) func(*pubOpts)
func QOS ¶ added in v1.4.0
func QOS(prefetchCount int) func(*opts)
QOS quality of service prefetch count.
func SubscriberAutoAck ¶
func SubscriberAutoAck() func(*subOpts)
func SubscriberAutoDelete ¶ added in v1.3.1
func SubscriberAutoDelete() func(*subOpts)
func SubscriberExclusive ¶ added in v1.3.1
func SubscriberExclusive() func(*subOpts)
func SubscriberNotDurable ¶
func SubscriberNotDurable() func(*subOpts)
func SubscriberQueue ¶
func SubscriberQueue(queue string) func(*subOpts)
func SubscriberWrapper ¶
func SubscriberWrapper(w SubWrapper) func(*subOpts)
Types ¶
type Handler ¶
Handler handles messages from subscriber. Msg always proto.Message and will be parsed to specific one based on "MessageType" header.
type HeaderOption ¶ added in v1.2.0
type HeaderOption func(Headers)
func HeaderCorrelationID ¶ added in v1.2.0
func HeaderCorrelationID(id string) HeaderOption
func HeaderReplyTo ¶ added in v1.2.0
func HeaderReplyTo(topic string) HeaderOption
type Headers ¶ added in v1.0.0
type Headers map[string]interface{}
func FromContext ¶ added in v1.0.0
type PubWrapper ¶
type Publisher ¶
type Publisher struct {
// contains filtered or unexported fields
}
Publisher publish proto messages.
func (*Publisher) MustPublish ¶ added in v1.3.1
func (p *Publisher) MustPublish(ctx context.Context, topic string, msg proto.Message, opts ...HeaderOption)
MustPublish same as Publish but panics on error.
type PublisherOption ¶
type PublisherOption func(*pubOpts)
type Snorlax ¶
type Snorlax struct {
// contains filtered or unexported fields
}
Snorlax is main point for creating pubs and subs.
func (*Snorlax) MustPublisher ¶ added in v1.2.0
func (s *Snorlax) MustPublisher(optsf ...PublisherOption) *Publisher
MustPublisher same as NewPublisher but panics if err not nil.
func (*Snorlax) MustSubscriber ¶ added in v1.2.0
func (s *Snorlax) MustSubscriber(optsf ...SubscriberOption) *Subscriber
MustSubscriber same as NewSubscriber but panics if err not nil.
func (*Snorlax) NewPublisher ¶
func (s *Snorlax) NewPublisher(optsf ...PublisherOption) (*Publisher, error)
NewPublisher creates channel to RabbitMQ.
func (*Snorlax) NewSubscriber ¶
func (s *Snorlax) NewSubscriber(optsf ...SubscriberOption) (*Subscriber, error)
NewSubscriber creates channel to RabbitMQ
func (*Snorlax) QueueUnbind ¶ added in v1.4.0
QueueUnbind is shortcut to channel.QueueUnbind.
type SubWrapper ¶
type Subscriber ¶
type Subscriber struct {
// contains filtered or unexported fields
}
Subscriber subscribes to exchange's topic.
func (*Subscriber) MustSubscribe ¶ added in v1.3.1
func (s *Subscriber) MustSubscribe(ctx context.Context, topic string, h Handler)
MustSubscribe same as Subscribe but panics on error.
type SubscriberOption ¶
type SubscriberOption func(*subOpts)