Documentation ¶
Index ¶
- Constants
- func NewPublishId(ctx context.Context) (context.Context, string)
- type ContextKey
- type Handler
- type InitOptionSetter
- type SubscriberHandlerFunc
- type Worker
- func (w *Worker) Client() (*nats.Conn, error)
- func (w *Worker) Close()
- func (w *Worker) MustPublish(ctx context.Context, topic string, payload any)
- func (w *Worker) MustSubscribe(topic string, handler WorkerHandlerFunc)
- func (w *Worker) Publish(ctx context.Context, topic string, data any) (err error)
- func (w *Worker) PublishMsg(msg *nats.Msg) (err error)
- func (w *Worker) Subscribe(topic string, handler WorkerHandlerFunc) error
- func (w *Worker) SubscribeMsg(topic string, handler SubscriberHandlerFunc) error
- type WorkerHandlerFunc
Constants ¶
View Source
const ( ContextStartedAt = ContextKey("startedAt") ContextPublishId = ContextKey("publishId") )
View Source
const (
HeaderPublishId = "PublishId"
)
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ContextKey ¶
type ContextKey string
type InitOptionSetter ¶
type InitOptionSetter func(o *initOption)
func WithHandler ¶
func WithHandler(h Handler) InitOptionSetter
type SubscriberHandlerFunc ¶
SubscriberHandlerFunc is a native NATS handler that includes context
type Worker ¶
type Worker struct {
// contains filtered or unexported fields
}
Worker is a Queue Messaging adapter implemented using NATS
func NewWorker ¶
func NewWorker(host string, port uint16, authToken string, args ...InitOptionSetter) *Worker
func (*Worker) MustPublish ¶
func (*Worker) MustSubscribe ¶
func (w *Worker) MustSubscribe(topic string, handler WorkerHandlerFunc)
func (*Worker) PublishMsg ¶
PublishMsg publish message using native nats.Conn PublishMsg function
func (*Worker) Subscribe ¶
func (w *Worker) Subscribe(topic string, handler WorkerHandlerFunc) error
Subscribe handles subscription using WorkerHandler that wraps into native NATS SubscriberHandler
func (*Worker) SubscribeMsg ¶
func (w *Worker) SubscribeMsg(topic string, handler SubscriberHandlerFunc) error
SubscribeMsg handles subscription using native NATS SubscriberHandler
Click to show internal directories.
Click to hide internal directories.