Documentation ¶
Index ¶
- Constants
- Variables
- func CfgWithContext(ctx context.Context, cfg *Configs) context.Context
- func ConnFromContext(ctx context.Context) (*nats.Conn, error)
- func ConnWithContext(ctx context.Context, conn *nats.Conn) context.Context
- func NewConnection(ctx context.Context) (*nats.Conn, error)
- func NewEvent(msg *nats.Msg) (*entities.Event, error)
- func NewJetStream(ctx context.Context) (nats.JetStreamContext, error)
- func NewMsg(cfg *Configs, event *entities.Event) (*nats.Msg, error)
- func NewSubject(cfg *Configs, sample *entities.Event) string
- func UseSub(ctx context.Context, fn SubscribeFn) nats.MsgHandler
- type Configs
- type Pub
- type Sub
- type SubscribeFn
Constants ¶
View Source
const CTXKEY_CFG ctxkey = "ackstream.xstream.configs"
View Source
const CTXKEY_CONN ctxkey = "ackstream.xstream.connection"
Variables ¶
View Source
var ( CONSUMER_POLICY_ALL = 0 CONSUMER_POLICY_NEW = 1 )
View Source
var ErrCfgNotFound = errors.New("no configs was set")
View Source
var ErrConnNotFound = errors.New("no connection was initialized")
View Source
var ErrMsgInvalidEvent = errors.New("could not construct event from message")
View Source
var ErrSubNoQueue = errors.New("could not subscribe a topic without queue name")
Functions ¶
func ConnFromContext ¶
func NewConnection ¶
func NewJetStream ¶
func UseSub ¶
func UseSub(ctx context.Context, fn SubscribeFn) nats.MsgHandler
Types ¶
type Configs ¶
type Configs struct { Debug bool Uri string `json:"uri" mapstructure:"ACKSTREAM_XSTREAM_URI"` Region string `json:"region" mapstructure:"ACKSTREAM_XSTREAM_REGION"` Name string `json:"name" mapstructure:"ACKSTREAM_XSTREAM_NAME"` Topic string `json:"topic" mapstructure:"ACKSTREAM_XSTREAM_TOPIC"` MaxMsgs int64 `json:"max_msg" mapstructure:"ACKSTREAM_XSTREAM_MAX_MSGS"` MaxBytes int64 `json:"max_bytes" mapstructure:"ACKSTREAM_XSTREAM_MAX_BYTES"` MaxAge int32 `json:"max_age" mapstructure:"ACKSTREAM_XSTREAM_MAX_AGE"` ConsumerPolicy int `json:"consumer_policy" mapstructure:"ACKSTREAM_XSTREAM_CONSUMER_POLICY"` }
type SubscribeFn ¶
Source Files ¶
Click to show internal directories.
Click to hide internal directories.