redispkg

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client holds redis client

func NewClient

func NewClient(config Config) *Client

NewClient returns a new redis client

func (*Client) Delete

func (c *Client) Delete(ctx context.Context, key string, fields ...string) error

Delete a field for a key

func (*Client) HGetAll

func (c *Client) HGetAll(ctx context.Context, key string) (map[string]string, error)

HGetAll returns all values map for a key

func (*Client) HSet

func (c *Client) HSet(ctx context.Context, key string, values ...interface{}) error

HSet set key with values

type Config

type Config struct {
	Address            string
	Password           string
	TLSEnabled         bool
	ClusterModeEnabled bool
}

Config holds redis config

type IRedis

type IRedis interface {
	Publish(ctx context.Context, publishRequest PublishRequest) error
	PublishBulk(ctx context.Context, publishRequest []PublishRequest) error
	Subscribe(ctx context.Context, channel ...string) broker.ISubscription
	UnSubscribe(ctx context.Context, s broker.ISubscription) error
	AddSubscription(ctx context.Context, channel string, s broker.ISubscription) error
	RemoveSubscription(ctx context.Context, channel string, s broker.ISubscription) error
}

IRedis is an interface over redis pubusb and streams

type PubSub

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

PubSub provides redis pubsub implementation

func NewPubSub

func NewPubSub(c *Client) *PubSub

NewPubSub returns redis PubSub

func (PubSub) AddSubscription

func (p PubSub) AddSubscription(ctx context.Context, channel string, s broker.ISubscription) error

AddSubscription to a redis pubsub channel

func (PubSub) Publish

func (p PubSub) Publish(ctx context.Context, request PublishRequest) error

Publish message to redis

func (PubSub) PublishBulk

func (p PubSub) PublishBulk(ctx context.Context, publishRequest []PublishRequest) error

PublishBulk publishes messages in bulk

func (PubSub) RemoveSubscription

func (p PubSub) RemoveSubscription(ctx context.Context, channel string, s broker.ISubscription) error

RemoveSubscription removes a subscription

func (PubSub) Subscribe

func (p PubSub) Subscribe(ctx context.Context, channel ...string) broker.ISubscription

Subscribe to a redis pubsub channel

func (PubSub) UnSubscribe

func (p PubSub) UnSubscribe(ctx context.Context, s broker.ISubscription) error

UnSubscribe from all channels

type PubSubSubscription

type PubSubSubscription struct {
	broker.BaseSubscription
	// contains filtered or unexported fields
}

PubSubSubscription provides pubsub subscription

type PublishRequest

type PublishRequest struct {
	Channel string
	Data    []byte
}

PublishRequest is the publishRequest

type StreamSubscription

type StreamSubscription struct {
	Streams
	broker.BaseSubscription
}

StreamSubscription provides stream subscription

type Streams

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

Streams provide redis streams implementation

func NewStreams

func NewStreams(c *Client) *Streams

NewStreams returns redis Streams

func (Streams) AddSubscription

func (ss Streams) AddSubscription(ctx context.Context, channel string, s broker.ISubscription) error

AddSubscription ...

func (Streams) Publish

func (ss Streams) Publish(ctx context.Context, request PublishRequest) error

Publish message to redis

func (Streams) PublishBulk

func (ss Streams) PublishBulk(ctx context.Context, publishRequests []PublishRequest) error

PublishBulk publishes messages in bulk

func (Streams) RemoveSubscription

func (ss Streams) RemoveSubscription(ctx context.Context, channel string, s broker.ISubscription) error

RemoveSubscription ...

func (Streams) Subscribe

func (ss Streams) Subscribe(ctx context.Context, channel ...string) broker.ISubscription

Subscribe to a redis stream

func (Streams) UnSubscribe

func (ss Streams) UnSubscribe(ctx context.Context, s broker.ISubscription) error

UnSubscribe ...

Jump to

Keyboard shortcuts

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