redisext

package
v1.3.16 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2023 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Name = "Redis"
)

Variables

This section is empty.

Functions

func DIMiddleware

func DIMiddleware(client *Client) mux.MiddlewareFunc

func UnaryDIInterceptor

func UnaryDIInterceptor(client *Client) grpc.UnaryServerInterceptor

Types

type Client

type Client struct {
	Configs
	DB      *redis.Client
	Queue   rmq.Connection
	Lock    *redsync.Redsync
	Limiter *redis_rate.Limiter
	// contains filtered or unexported fields
}

func Connect

func Connect(ctx context.Context, configs Configs) (*Client, error)

func Provide

func Provide(ctx context.Context) *Client

func (*Client) Close

func (c *Client) Close() error

func (*Client) Del

func (c *Client) Del(ctx context.Context, ns, key string) error

func (*Client) Exists

func (c *Client) Exists(ctx context.Context, ns, key string) error

func (*Client) Expire

func (c *Client) Expire(ctx context.Context, ns, key string, exp time.Duration) error

func (*Client) Get

func (c *Client) Get(ctx context.Context, ns, key string, value any) error

func (*Client) Limit

func (c *Client) Limit(ctx context.Context, ns, key string, limit redis_rate.Limit) (*redis_rate.Result, error)

func (*Client) LimitReport

func (c *Client) LimitReport(ctx context.Context, ns, key string, limit redis_rate.Limit) (*redis_rate.Result, error)

func (*Client) NewMutex

func (c *Client) NewMutex(ns, key string, exp time.Duration) *redsync.Mutex

func (*Client) OpenQueue

func (c *Client) OpenQueue(name string) (*Queue, error)

func (*Client) Set

func (c *Client) Set(ctx context.Context, ns, key string, value any, exp time.Duration) error

type Configs

type Configs struct {
	RedisAddress       string        `env:"REDIS_ADDRESS,required"`
	RedisPassword      string        `env:"REDIS_PASSWORD"`
	RedisDatabase      int           `env:"REDIS_DATABASE"`
	RedisQueueCleaning time.Duration `env:"REDIS_QUEUE_CLEANING" envDefault:"1m"`
	RedisQueuePool     int64         `env:"REDIS_QUEUE_POOL" envDefault:"10"`
	RedisQueueApp      string        `env:"REDIS_QUEUE_APP" envDefault:"app"`
}

type Consumer

type Consumer interface {
	Tag() string
	Consume(delivery *Delivery) error
}

type Delivery

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

func (Delivery) Ack

func (d Delivery) Ack()

func (Delivery) Payload

func (d Delivery) Payload(value any) error

func (Delivery) Push

func (d Delivery) Push()

func (Delivery) Reject

func (d Delivery) Reject()

type Queue

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

func (*Queue) Publish

func (q *Queue) Publish(value any) error

func (*Queue) SetConsumer

func (q *Queue) SetConsumer(c Consumer) error

Jump to

Keyboard shortcuts

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