natscli

package
v0.15.0 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddConsumer

func AddConsumer(streamName string, config *nats.ConsumerConfig) (err error)

AddConsumer 添加流消费者

func AddStream

func AddStream(streamName string, subjects []string) error

AddStream 添加流(不会重复创建,也不会删除再创建)

func Connect

func Connect(clientName string, servers []string, options ...Option)

Connect NATS连接

func DelConsumer

func DelConsumer(stream, consumer string) (err error)

DelConsumer 删除流消费者

func DelStream

func DelStream(streamName string) (err error)

DelStream 删除流

func JsPub

func JsPub(subj string, data []byte) (err error)

JsPub 发布流消息

func JsQueueSubscribe

func JsQueueSubscribe(subject, queueName string, handler nats.MsgHandler) (err error)

JsQueueSubscribe 队列方式订阅流消息(分布式场景使用)

func JsSub

func JsSub(subj string, handler nats.MsgHandler) (err error)

JsSub 订阅流消息

func NewZlogLoggerWithNATS added in v0.3.0

func NewZlogLoggerWithNATS(level string, subj string)

NewZlogLoggerWithNATS 使用NATS作为日志输出

func Pub

func Pub(ctx context.Context, subj string, data []byte)

func PubGo

func PubGo(ctx context.Context, subj string, data any)

func QueueSub

func QueueSub(subj, queue string, handler nats.MsgHandler) (err error)

func QueueSubSyncWithChan

func QueueSubSyncWithChan(subject, queueName string, handler chan *nats.Msg) (sub *nats.Subscription, err error)

func Request

func Request(subj string, data []byte, timeout time.Duration) (*nats.Msg, error)

func Sub

func Sub(subj string, handler nats.MsgHandler) (err error)

Types

type Option

type Option func(*Options)

func WithNKey added in v0.4.0

func WithNKey(seedFile string) Option

WithNKey NKey认证

func WithToken added in v0.4.0

func WithToken(token string) Option

WithToken TOKEN认证

func WithUserAndPass added in v0.4.0

func WithUserAndPass(username, password string) Option

WithUserAndPass 用户名密码认证

type Options

type Options struct {

	// 认证配置-用户名密码方式
	Username string // 用户名
	Password string // 密码
	// 认证配置-NKey方式
	NKeySeedFile string
	// 认证配置-TOKEN方式
	Token string
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

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