redis

package
v0.0.13 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewWatermillPublisher

func NewWatermillPublisher(pub Publisher) (publisher.Publisher, error)

func NewWatermillSubscriber

func NewWatermillSubscriber(sub Subscriber, consumeFunc subscriber.ConsumeFunc) subscriber.Subscriber

Types

type Config

type Config struct {
	Host         string        `env:"REDIS_HOST,required"`
	Port         string        `env:"REDIS_PORT,required"`
	Password     string        `env:"REDIS_PASSWORD" envdefault:""`
	DB           int           `env:"REDIS_DB,required"`
	TTL          time.Duration `env:"REDIS_TTL,required"`
	UseTls       bool          `env:"REDIS_USE_TLS,notEmpty" envdefault:"false"`
	MaxIdleConns int           `env:"REDIS_MAX_IDLE_CONNS,required"`
	MinIdleConns int           `env:"REDIS_MIN_IDLE_CONNS,required"`
}

func NewConfig

func NewConfig() (*Config, error)

type MultiSubscriber

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

Subscriber to manage multiple subscribers

func NewMultiSubscriber

func NewMultiSubscriber(config *SubConfig) *MultiSubscriber

func (*MultiSubscriber) Close

func (s *MultiSubscriber) Close() error

func (*MultiSubscriber) Subscribe

func (s *MultiSubscriber) Subscribe(topic string, consumeFunc subscriber.ConsumeFunc) error

type PubConfig

type PubConfig struct {
	LoggerDebug      bool  `env:"REDIS_PUB_SUB_LOGGER_DEBUG,notEmpty" envdefault:"false"`
	LoggerTrace      bool  `env:"REDIS_PUB_SUB_LOGGER_TRACE,notEmpty" envdefault:"false"`
	MaxStreamEntries int64 `env:"REDIS_MAX_STREAM_ENTRIES" envDefault:"200"`
}

func NewPubConfig

func NewPubConfig() (*PubConfig, error)

type Publisher

type Publisher interface {
	Publish(topic string, msgs ...*message.Message) error
	Close() error
	Topic() string
	Client() redis.UniversalClient
	MaxStreamEntries() int64
}

func NewPublisher

func NewPublisher(config *PubConfig, topic string) (Publisher, error)

type Redis

type Redis struct {
	*redis.Client
}

func NewRedis

func NewRedis(config *Config) (*Redis, error)

type SubConfig

type SubConfig struct {
	PubConfig
	ConsumerGroup string `env:"REDIS_PUB_SUB_CONSUMER_GROUP_ID,notEmpty" envdefault:""`
}

func NewSubConfig

func NewSubConfig() (*SubConfig, error)

type Subscriber

type Subscriber interface {
	Close() error
	Subscribe(ctx context.Context, topic string) (<-chan *message.Message, error)
	GroupID() string
	Topic() string
}

func NewSubscriber

func NewSubscriber(config *SubConfig, client redis.UniversalClient, topic string) (Subscriber, error)

type WatermillPublisher

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

func (*WatermillPublisher) Close

func (w *WatermillPublisher) Close() error

func (*WatermillPublisher) PublishMessage

func (w *WatermillPublisher) PublishMessage(messages ...string) error

func (*WatermillPublisher) Topic

func (w *WatermillPublisher) Topic() string

type WatermillSubscriber

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

func (*WatermillSubscriber) Close

func (r *WatermillSubscriber) Close() error

func (*WatermillSubscriber) GroupID

func (r *WatermillSubscriber) GroupID() string

func (*WatermillSubscriber) Start

func (r *WatermillSubscriber) Start()

func (*WatermillSubscriber) Topic

func (r *WatermillSubscriber) Topic() string

Jump to

Keyboard shortcuts

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