redis

package
v1.1.4 Latest Latest
Warning

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

Go to latest
Published: May 24, 2024 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const Name = "redisgo"

Name is the name of the pubsub.

Variables

This section is empty.

Functions

func Get

func Get() pubsub.IPubSub

Get returns a setup Redis, or set it up.

func New

func New(ctx context.Context, url string, options ...Option) (pubsub.IPubSub, error)

New creates a new Redis pubsub.

func Set

func Set(ps pubsub.IPubSub)

Set sets the singleton. Useful for testing.

Types

type Option

type Option = redisgo.Options

Option is for the Redis configuration.

type Redis

type Redis struct {
	*pubsub.PubSub

	// Options are the Redis configuration.
	Options []Option `json:"-" validate:"required"`

	// Client is the Redis client.
	Client *redisgo.Client

	// URL is the Redis URL.
	URL string `json:"url" validate:"required"`
	// contains filtered or unexported fields
}

Redis pubsub definition.

func (*Redis) Close

func (r *Redis) Close() error

Close the connection to the Pub Sub broker.

func (*Redis) GetClient

func (r *Redis) GetClient() any

GetClient returns the storage client. Use that to interact with the underlying storage client.

func (*Redis) MustPublish

func (r *Redis) MustPublish(ctx context.Context, msgs ...*message.Message) []*message.Message

MustPublish sends a message to a topic. In case of error it will panic.

func (*Redis) MustPublishAsync

func (r *Redis) MustPublishAsync(ctx context.Context, messages ...*message.Message)

MustPublishAsync sends a message to a topic asynchronously. In case of error it will panic.

func (*Redis) MustSubscribe

func (r *Redis) MustSubscribe(ctx context.Context, subscriptions ...*subscription.Subscription) []*subscription.Subscription

MustSubscribe to a topic. In case of error it will panic.

func (*Redis) MustSubscribeAsync

func (r *Redis) MustSubscribeAsync(ctx context.Context, subscriptions ...*subscription.Subscription)

MustSubscribeAsync to a topic asynchronously. In case of error it will panic.

func (*Redis) Publish

func (r *Redis) Publish(
	ctx context.Context,
	messages []*message.Message,
	opts ...pubsub.Func,
) ([]*message.Message, concurrentloop.Errors)

Publish sends a message to a topic.

func (*Redis) Subscribe

func (r *Redis) Subscribe(
	ctx context.Context,
	subscriptions []*subscription.Subscription,
	opts ...pubsub.Func,
) ([]*subscription.Subscription, concurrentloop.Errors)

Subscribe to a topic.

func (*Redis) Unsubscribe

func (r *Redis) Unsubscribe(ctx context.Context, subscriptions ...*subscription.Subscription) error

Unsubscribe from a topic.

Jump to

Keyboard shortcuts

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