nats

package module
v0.0.0-...-a744095 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2022 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Example (Handler)
cb := func(ctx context.Context, sub string, data []byte) ([]byte, error) {
	return nil, nil
}

tele := tel.NewNull()
mw := New(tele, false)

conn, _ := nats.Connect("example.com")
_, _ = conn.QueueSubscribe("sub", "queue", mw.Handler(cb))
_, _ = conn.QueueSubscribe("sub2", "queue", mw.Handler(cb))
Output:

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MiddleWare

type MiddleWare struct {
	// contains filtered or unexported fields
}

MiddleWare helper

func New

func New(tele tel.Telemetry, reply bool) *MiddleWare

New nats middleware

func (*MiddleWare) Handler

func (n *MiddleWare) Handler(next PostFn) func(*nats.Msg)

Handler is entry point perform recovery, debug logging and perform tracing

type PostFn

type PostFn func(ctx context.Context, sub string, data []byte) ([]byte, error)

PostFn callback function which got new instance of tele inside ctx and msg sub + data

Jump to

Keyboard shortcuts

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