Documentation ¶
Index ¶
- Constants
- func DecodeNatsMsg(msg *gnats.Msg, v interface{}) error
- func GetCompanyIdFromHeader(m *nats.Msg) string
- func GetContentEncodingFromHeader(m *nats.Msg) string
- func GetCustomHeaderValue(m *nats.Msg, header string) string
- func GetLocationIdFromHeader(m *nats.Msg) string
- func GetMsgIdFromHeader(m *nats.Msg) string
- func GetRegionFromHeader(m *nats.Msg) string
- func GetRequestIdFromHeader(m *nats.Msg) string
- func GetSessionIdFromHeader(m *nats.Msg) string
- func GetUserIdFromHeader(m *nats.Msg) string
- func NewJetStreamConsumer(config ConsumerConfig) (jetstream.Consumer, error)
- func NewNats(log logger.Logger, name string, hosts string, credentials gnats.Option, ...) (*gnats.Conn, error)
- func SetCompanyIdHeader(m *nats.Msg, value string)
- func SetContentEncodingHeader(m *nats.Msg, value string)
- func SetCustomHeader(m *nats.Msg, header string, value string)
- func SetLocationIdHeader(m *nats.Msg, value string)
- func SetMsgIdHeader(m *nats.Msg, value string)
- func SetRegionHeader(m *nats.Msg, value string)
- func SetRequestIdHeader(m *nats.Msg, value string)
- func SetSessionIdHeader(m *nats.Msg, value string)
- func SetUserIdHeader(m *nats.Msg, value string)
- type ConsumerConfig
- type EphemeralOptsFunc
- func WithEphemeralAckWait(duration time.Duration) EphemeralOptsFunc
- func WithEphemeralConsumerDescription(description string) EphemeralOptsFunc
- func WithEphemeralContext(context context.Context) EphemeralOptsFunc
- func WithEphemeralDelivery(policy nats.DeliverPolicy) EphemeralOptsFunc
- func WithEphemeralDisableSubscriberLogging() EphemeralOptsFunc
- func WithEphemeralMaxAckPending(max int) EphemeralOptsFunc
- func WithEphemeralMaxDeliver(max int) EphemeralOptsFunc
- func WithEphemeralMaxRequestBatch(max int) EphemeralOptsFunc
- type ExactlyOnceOptsFunc
- func WithExactlyOnceAckWait(ackWait time.Duration) ExactlyOnceOptsFunc
- func WithExactlyOnceByStartTimePolicy(start time.Time) ExactlyOnceOptsFunc
- func WithExactlyOnceConsumerDescription(description string) ExactlyOnceOptsFunc
- func WithExactlyOnceContext(context context.Context) ExactlyOnceOptsFunc
- func WithExactlyOnceDelivery(policy nats.DeliverPolicy) ExactlyOnceOptsFunc
- func WithExactlyOnceDisableSubscriberLogging() ExactlyOnceOptsFunc
- func WithExactlyOnceMaxDeliver(max int) ExactlyOnceOptsFunc
- func WithExactlyOnceMaxRequestBatch(max int) ExactlyOnceOptsFunc
- func WithExactlyOnceReplicas(replicas int) ExactlyOnceOptsFunc
- type Handler
- type QueueOptsFunc
- func WithQueueAckWait(max time.Duration) QueueOptsFunc
- func WithQueueConsumerDescription(description string) QueueOptsFunc
- func WithQueueContext(context context.Context) QueueOptsFunc
- func WithQueueDelivery(policy nats.DeliverPolicy) QueueOptsFunc
- func WithQueueDisableSubscriberLogging() QueueOptsFunc
- func WithQueueMaxAckPending(max int) QueueOptsFunc
- func WithQueueMaxDeliver(max int) QueueOptsFunc
- func WithQueueMaxRequestBatch(max int) QueueOptsFunc
- func WithQueueReplicas(replicas int) QueueOptsFunc
- type Subscriber
- func NewEphemeralConsumer(logger logger.Logger, js nats.JetStreamContext, stream string, subject string, ...) (Subscriber, error)
- func NewExactlyOnceConsumer(logger logger.Logger, js nats.JetStreamContext, stream string, durable string, ...) (Subscriber, error)
- func NewQueueConsumer(logger logger.Logger, js nats.JetStreamContext, stream string, durable string, ...) (Subscriber, error)
Constants ¶
const ( RegionHdr = "region" RequestIdHdr = "x-request-id" CompanyIdHdr = "x-company-id" UserIdHdr = "x-user-id" LocationIdHdr = "x-location-id" SessionIdHdr = "x-session-id" )
Default headers which published in messages from API backend
const (
ContentEncodingHdr = "content-encoding"
)
Default nats headers
Variables ¶
This section is empty.
Functions ¶
func DecodeNatsMsg ¶ added in v0.0.70
DecodeNatsMsg will decode the nats message into the provided interface.
func GetCompanyIdFromHeader ¶ added in v0.0.71
func GetCompanyIdFromHeader(m *nats.Msg) string
func GetContentEncodingFromHeader ¶ added in v0.0.71
func GetContentEncodingFromHeader(m *nats.Msg) string
func GetCustomHeaderValue ¶ added in v0.0.71
func GetLocationIdFromHeader ¶ added in v0.0.71
func GetLocationIdFromHeader(m *nats.Msg) string
func GetMsgIdFromHeader ¶ added in v0.0.71
func GetMsgIdFromHeader(m *nats.Msg) string
func GetRequestIdFromHeader ¶ added in v0.0.71
func GetRequestIdFromHeader(m *nats.Msg) string
func GetSessionIdFromHeader ¶ added in v0.0.71
func GetSessionIdFromHeader(m *nats.Msg) string
func GetUserIdFromHeader ¶ added in v0.0.71
func GetUserIdFromHeader(m *nats.Msg) string
func NewJetStreamConsumer ¶ added in v0.0.71
func NewJetStreamConsumer(config ConsumerConfig) (jetstream.Consumer, error)
NewJetStreamConsumer creates a new JetStream consumer with the given configuration. This will create or update a consumer based on the given configuration.
func NewNats ¶
func NewNats(log logger.Logger, name string, hosts string, credentials gnats.Option, opts ...gnats.Option) (*gnats.Conn, error)
NewNats will return a new nats connections
func SetCompanyIdHeader ¶ added in v0.0.71
func SetCompanyIdHeader(m *nats.Msg, value string)
func SetContentEncodingHeader ¶ added in v0.0.71
func SetContentEncodingHeader(m *nats.Msg, value string)
func SetCustomHeader ¶ added in v0.0.71
func SetLocationIdHeader ¶ added in v0.0.71
func SetLocationIdHeader(m *nats.Msg, value string)
func SetMsgIdHeader ¶ added in v0.0.71
func SetMsgIdHeader(m *nats.Msg, value string)
func SetRequestIdHeader ¶ added in v0.0.71
func SetRequestIdHeader(m *nats.Msg, value string)
func SetSessionIdHeader ¶ added in v0.0.71
func SetSessionIdHeader(m *nats.Msg, value string)
func SetUserIdHeader ¶ added in v0.0.71
func SetUserIdHeader(m *nats.Msg, value string)
Types ¶
type ConsumerConfig ¶ added in v0.0.71
type EphemeralOptsFunc ¶ added in v0.0.27
type EphemeralOptsFunc func(config *ephemeralConsumerConfig) error
func WithEphemeralAckWait ¶ added in v0.0.28
func WithEphemeralAckWait(duration time.Duration) EphemeralOptsFunc
WithEphemeralAckWait overrides the default ack wait of 30s
func WithEphemeralConsumerDescription ¶ added in v0.0.27
func WithEphemeralConsumerDescription(description string) EphemeralOptsFunc
WithEphemeralConsumerDescription set the consumer description
func WithEphemeralContext ¶ added in v0.0.27
func WithEphemeralContext(context context.Context) EphemeralOptsFunc
WithEphemeralContext set the internal context
func WithEphemeralDelivery ¶ added in v0.0.27
func WithEphemeralDelivery(policy nats.DeliverPolicy) EphemeralOptsFunc
WithEphemeralDelivery set the internal context
func WithEphemeralDisableSubscriberLogging ¶ added in v0.0.34
func WithEphemeralDisableSubscriberLogging() EphemeralOptsFunc
WithEphemeralDisableSubscriberLogging to turn off extra trace logging in the subscriber
func WithEphemeralMaxAckPending ¶ added in v0.0.27
func WithEphemeralMaxAckPending(max int) EphemeralOptsFunc
WithEphemeralMaxAckPending set the maximum ack pending value
func WithEphemeralMaxDeliver ¶ added in v0.0.27
func WithEphemeralMaxDeliver(max int) EphemeralOptsFunc
WithEphemeralMaxDeliver set the maximum deliver value
func WithEphemeralMaxRequestBatch ¶ added in v0.0.51
func WithEphemeralMaxRequestBatch(max int) EphemeralOptsFunc
WithEphemeralMaxRequestBatch set the maximum number of records to fetch
type ExactlyOnceOptsFunc ¶ added in v0.0.27
type ExactlyOnceOptsFunc func(config *exactlyOnceConsumerConfig) error
func WithExactlyOnceAckWait ¶ added in v0.0.56
func WithExactlyOnceAckWait(ackWait time.Duration) ExactlyOnceOptsFunc
Add the ability to set the ack wait time for the consumer
func WithExactlyOnceByStartTimePolicy ¶ added in v0.0.53
func WithExactlyOnceByStartTimePolicy(start time.Time) ExactlyOnceOptsFunc
func WithExactlyOnceConsumerDescription ¶ added in v0.0.27
func WithExactlyOnceConsumerDescription(description string) ExactlyOnceOptsFunc
WithExactlyOnceConsumerDescription set the consumer description
func WithExactlyOnceContext ¶ added in v0.0.27
func WithExactlyOnceContext(context context.Context) ExactlyOnceOptsFunc
WithExactlyOnceContext set the internal context
func WithExactlyOnceDelivery ¶ added in v0.0.27
func WithExactlyOnceDelivery(policy nats.DeliverPolicy) ExactlyOnceOptsFunc
WithExactlyOnceDelivery set the internal context
func WithExactlyOnceDisableSubscriberLogging ¶ added in v0.0.34
func WithExactlyOnceDisableSubscriberLogging() ExactlyOnceOptsFunc
WithExactlyOnceDisableSubscriberLogging to turn off extra trace logging in the subscriber
func WithExactlyOnceMaxDeliver ¶ added in v0.0.27
func WithExactlyOnceMaxDeliver(max int) ExactlyOnceOptsFunc
WithExactlyOnceMaxDeliver set the maximum deliver value
func WithExactlyOnceMaxRequestBatch ¶ added in v0.0.56
func WithExactlyOnceMaxRequestBatch(max int) ExactlyOnceOptsFunc
Add the ability to set the max fetch value for the consumer
func WithExactlyOnceReplicas ¶ added in v0.0.32
func WithExactlyOnceReplicas(replicas int) ExactlyOnceOptsFunc
WithExactlyOnceReplicas set the number of replicas for the consumer
type QueueOptsFunc ¶ added in v0.0.27
type QueueOptsFunc func(config *queueConsumerConfig) error
func WithQueueAckWait ¶ added in v0.0.52
func WithQueueAckWait(max time.Duration) QueueOptsFunc
WithQueueAckWait set the maximum ack wait duration value
func WithQueueConsumerDescription ¶ added in v0.0.27
func WithQueueConsumerDescription(description string) QueueOptsFunc
WithQueueConsumerDescription set the consumer description
func WithQueueContext ¶ added in v0.0.27
func WithQueueContext(context context.Context) QueueOptsFunc
WithQueueContext set the internal context
func WithQueueDelivery ¶ added in v0.0.27
func WithQueueDelivery(policy nats.DeliverPolicy) QueueOptsFunc
WithQueueDelivery set the internal context
func WithQueueDisableSubscriberLogging ¶ added in v0.0.34
func WithQueueDisableSubscriberLogging() QueueOptsFunc
WithQueueDisableSubscriberLogging to turn off extra trace logging in the subscriber
func WithQueueMaxAckPending ¶ added in v0.0.27
func WithQueueMaxAckPending(max int) QueueOptsFunc
WithQueueMaxAckPending set the maximum ack pending value
func WithQueueMaxDeliver ¶ added in v0.0.27
func WithQueueMaxDeliver(max int) QueueOptsFunc
WithQueueMaxDeliver set the maximum deliver value
func WithQueueMaxRequestBatch ¶ added in v0.0.51
func WithQueueMaxRequestBatch(max int) QueueOptsFunc
WithQueueMaxRequestBatch set the maximum number of records to fetch
func WithQueueReplicas ¶ added in v0.0.32
func WithQueueReplicas(replicas int) QueueOptsFunc
WithQueueReplicas set the number of replicas
type Subscriber ¶ added in v0.0.22
type Subscriber interface { // Close the subscriber and stop delivery Close() error }
Subscriber represents a nats subscriber
func NewEphemeralConsumer ¶ added in v0.0.23
func NewEphemeralConsumer(logger logger.Logger, js nats.JetStreamContext, stream string, subject string, handler Handler, opts ...EphemeralOptsFunc) (Subscriber, error)
NewEphemeralConsumer will create (or reuse) an ephemeral consumer
func NewExactlyOnceConsumer ¶ added in v0.0.3
func NewExactlyOnceConsumer(logger logger.Logger, js nats.JetStreamContext, stream string, durable string, subject string, handler Handler, opts ...ExactlyOnceOptsFunc) (Subscriber, error)
NewExactlyOnceConsumer will create (or reuse) an exactly once durable consumer
func NewQueueConsumer ¶ added in v0.0.22
func NewQueueConsumer(logger logger.Logger, js nats.JetStreamContext, stream string, durable string, subject string, handler Handler, opts ...QueueOptsFunc) (Subscriber, error)
NewQueueConsumer will create (or reuse) a queue consumer with default config