redis

package
v2.3.2 Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2023 License: Apache-2.0 Imports: 12 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Option

type Option func(opt *Options)

Option of the Redis subscriber or publisher

func WithEncoder

func WithEncoder(encoder encoder.Encoder) Option

WithEncoder set the message encoder

func WithErrorHandler

func WithErrorHandler(h nc.ErrorHandler) Option

WithErrorHandler set handler of error processing

func WithLogger

func WithLogger(logger loggerInterface) Option

WithLogger provides logging interface

func WithPanicHandler

func WithPanicHandler(h nc.PanicHandler) Option

WithPanicHandler set handler of panic processing

func WithRedisClient

func WithRedisClient(cli *redis.Client) Option

WithRedisClient puts redis connect option

func WithRedisOpts

func WithRedisOpts(opts *redis.Options) Option

WithRedisOpts set redis options to connect

func WithRedisURL

func WithRedisURL(urlString string) Option

WithRedisURL is an Option to set the URL the client should connect to. The url can contain username/password semantics. e.g. redis://derek:pass@localhost:4222/databaseNumber?topics=t1,t2

func WithTopics

func WithTopics(topics ...string) Option

WithTopics of the pubsub stream

type Options

type Options struct {
	// Client of the redis server
	Client *redis.Client

	// Channels list
	Channels []string

	// RedisOptions to connect to the client
	RedisOptions *redis.Options

	// ErrorHandler of message processing
	ErrorHandler nc.ErrorHandler

	// PanicHandler process panic
	PanicHandler nc.PanicHandler

	// Message encoder interface
	Encoder encoder.Encoder

	// Logger of subscriber
	Logger loggerInterface
}

Options of the Redis wrapper

type Publisher

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

Publisher for NATS queue

func MustNewPublisher

func MustNewPublisher(options ...Option) *Publisher

MustNewPublisher of the NATS stream server

func NewPublisher

func NewPublisher(options ...Option) (*Publisher, error)

NewPublisher of the NATS stream server

func (*Publisher) Close

func (s *Publisher) Close() error

Close nats-stream client

func (*Publisher) Publish

func (s *Publisher) Publish(ctx context.Context, messages ...any) (err error)

Publish one or more messages to the pub-service

type Subscriber

type Subscriber struct {
	nc.ModelSubscriber
	// contains filtered or unexported fields
}

Subscriber for Redis channels

func MustNewSubscriber

func MustNewSubscriber(options ...Option) *Subscriber

MustNewSubscriber creates new subscriber object

func NewSubscriber

func NewSubscriber(options ...Option) (*Subscriber, error)

NewSubscriber creates new subscriber object

func (*Subscriber) Close

func (s *Subscriber) Close() error

Close nstream client

func (*Subscriber) Listen

func (s *Subscriber) Listen(ctx context.Context) error

Listen kafka consumer

Jump to

Keyboard shortcuts

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