Documentation
¶
Overview ¶
Package nats provides NATS publishing and subscription helpers.
New code should use core-owned message and boundary contracts at consumer edges:
import "github.com/InsideGallery/core/queue/nats"
publisher := nats.NewPublisher(legacyPublisher)
result, err := publisher.Publish(ctx, nats.PublishOptions{
Message: nats.Message{Subject: "events"},
})
Prefer Publisher, Subscriber, Message, Headers, PublishOptions, RequestOptions, SubscribeOptions, and their result types where application code should not depend on the NATS SDK message type.
Compatibility: the queue/nats/client, publisher, and subscriber sub-packages remain available for existing SDK-shaped call sites. Prefer ConnectClient and the adapters in this package for new code.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrHandlerNotSet = errors.New("handler is not set")
ErrHandlerNotSet reports a missing subscriber handler.
var ErrMissingSubject = errors.New("subject is not set")
ErrMissingSubject reports a message without a subject.
var ErrPublisherNotSet = errors.New("publisher is not set")
ErrPublisherNotSet reports a missing publisher dependency.
var ErrSubscriberNotSet = errors.New("subscriber is not set")
ErrSubscriberNotSet reports a missing subscriber dependency.
Functions ¶
This section is empty.
Types ¶
type MessageHandler ¶
MessageHandler handles a message without exposing the NATS SDK message type.
type PublishOptions ¶
PublishOptions is the core-owned input for publishing a message.
type PublishResult ¶
PublishResult is the core-owned publish result.
type Publisher ¶
type Publisher interface {
Publish(ctx context.Context, options PublishOptions) (PublishResult, error)
Request(ctx context.Context, options RequestOptions) (RequestResult, error)
}
Publisher is the core-owned NATS publishing contract for new consumers.
type PublisherAdapter ¶
type PublisherAdapter struct {
// contains filtered or unexported fields
}
PublisherAdapter adapts the legacy NATS publisher to the core-owned Publisher contract.
func NewPublisher ¶
func NewPublisher(p *publisher.Publisher) *PublisherAdapter
NewPublisher wraps a legacy NATS publisher with the core-owned Publisher contract.
func (*PublisherAdapter) Publish ¶
func (p *PublisherAdapter) Publish(ctx context.Context, options PublishOptions) (PublishResult, error)
Publish publishes a message through the core-owned Publisher contract.
func (*PublisherAdapter) Request ¶
func (p *PublisherAdapter) Request(ctx context.Context, options RequestOptions) (RequestResult, error)
Request sends a request and returns a core-owned response message.
type RequestOptions ¶
type RequestOptions struct {
Message Message
}
RequestOptions is the core-owned input for request/reply messaging.
type RequestResult ¶
type RequestResult struct {
Message Message
}
RequestResult is the core-owned request/reply result.
type SubscribeOptions ¶
SubscribeOptions is the core-owned input for NATS queue subscriptions.
type SubscribeResult ¶
SubscribeResult reports the registered subscription identity.
type Subscriber ¶
type Subscriber interface {
Subscribe(ctx context.Context, options SubscribeOptions, handler MessageHandler) (SubscribeResult, error)
Close(ctx context.Context) error
Wait(ctx context.Context) error
}
Subscriber is the core-owned NATS subscriber contract for new consumers.
type SubscriberAdapter ¶
type SubscriberAdapter struct {
// contains filtered or unexported fields
}
SubscriberAdapter adapts the legacy NATS subscriber to the core-owned Subscriber contract.
func NewSubscriber ¶
func NewSubscriber(s *legacysubscriber.Subscriber) *SubscriberAdapter
NewSubscriber wraps a legacy NATS subscriber with the core-owned Subscriber contract.
func (*SubscriberAdapter) Close ¶
func (s *SubscriberAdapter) Close(ctx context.Context) error
Close closes the wrapped subscriber.
func (*SubscriberAdapter) Subscribe ¶
func (s *SubscriberAdapter) Subscribe( ctx context.Context, options SubscribeOptions, handler MessageHandler, ) (SubscribeResult, error)
Subscribe registers a queue subscriber through the core-owned Subscriber contract.
Directories
¶
| Path | Synopsis |
|---|---|
|
mock
Package mock is a generated GoMock package.
|
Package mock is a generated GoMock package. |
|
mock
Package mock is a generated GoMock package.
|
Package mock is a generated GoMock package. |
|
mock
Package mock is a generated GoMock package.
|
Package mock is a generated GoMock package. |
|
mock
Package mock is a generated GoMock package.
|
Package mock is a generated GoMock package. |