redis

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2023 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultConsumerBufferCapacity int = 1e3
)
View Source
const (
	DefaultProducerWarningNum int = 1e4
)

Variables

This section is empty.

Functions

func New

func New(ctx context.Context, conf Redis) (*redis.Client, error)

Types

type ConsumerConfig

type ConsumerConfig struct {
	RedisKey       string
	BufferCapacity int
	GoroutineNum   int
	AutoAck        bool
}

type ConsumerHandel

type ConsumerHandel func(ctx context.Context, message *messagePackage)

type ConsumerStatus

type ConsumerStatus struct {
	Id             string
	RedisKey       string
	BufferCapacity int
	BufferSize     int
}

type Instance

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

func NewRedis

func NewRedis(ctx context.Context, rc Redis) *Instance

func (*Instance) Client

func (instance *Instance) Client() *redis.Client

type MQConfig

type MQConfig struct {
	Addr         string        `json:"addr" yaml:"addr"`
	Username     string        `json:"username" yaml:"username"`
	Password     string        `json:"password" yaml:"password"`
	Db           int           `json:"db" yaml:"db"`
	ReadTimeout  time.Duration `json:"readTimeout" yaml:"readTimeout"`
	WriteTimeout time.Duration `json:"writeTimeout" yaml:"writeTimeout"`
	DialTimeout  time.Duration `json:"dialTimeout" yaml:"dialTimeout"`
	MaxRetries   int           `json:"maxRetries" yaml:"maxRetries"`
	PoolSize     int           `json:"poolSize" yaml:"poolSize"`
	PoolTimeout  time.Duration `json:"poolTimeout" yaml:"poolTimeout"`
}

type MessageQueue

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

func NewMessageQueue

func NewMessageQueue(ctx context.Context, cfg MQConfig) *MessageQueue

func (*MessageQueue) Running

func (mq *MessageQueue) Running()

func (*MessageQueue) Stop

func (mq *MessageQueue) Stop()

type MqConsumer

type MqConsumer struct {
	ConsumerId string
	RedisKey   string
	// contains filtered or unexported fields
}

func NewConsumer

func NewConsumer(mq *MessageQueue, cfg ConsumerConfig) *MqConsumer

type MqProducer

type MqProducer struct {
	RedisKey string
	// contains filtered or unexported fields
}

func NewProducer

func NewProducer(mq *MessageQueue, cfg ProducerConfig) *MqProducer

func (*MqProducer) Id

func (producer *MqProducer) Id() string

func (*MqProducer) Push

func (producer *MqProducer) Push(ctx context.Context, message any)

func (*MqProducer) Start

func (producer *MqProducer) Start() *MqProducer

type ProducerConfig

type ProducerConfig struct {
	RedisKey              string
	BufferPoolFlushTicker time.Duration
	BufferCapacity        int
	WarningSize           int
}

type ProducerStatus

type ProducerStatus struct {
	Id             string
	RedisKey       string
	BufferCapacity int
	BufferSize     int
}

type Redis

type Redis struct {
	Addr               string        `json:"addr" yaml:"addr"`
	Username           string        `json:"username" yaml:"username"`
	Password           string        `json:"password" yaml:"password"`
	Db                 int           `json:"db" yaml:"db"`
	ReadTimeout        time.Duration `json:"readTimeout" yaml:"readTimeout"`
	WriteTimeout       time.Duration `json:"writeTimeout" yaml:"writeTimeout"`
	DialTimeout        time.Duration `json:"dialTimeout" yaml:"dialTimeout"`
	MaxRetries         int           `json:"maxRetries" yaml:"maxRetries"`
	MinRetryBackoff    time.Duration `json:"minRetryBackoff" yaml:"minRetryBackoff"`
	MaxRetryBackoff    time.Duration `json:"maxRetryBackoff" yaml:"maxRetryBackoff"`
	PoolSize           int           `json:"poolSize" yaml:"poolSize"`
	MinIdleConns       int           `json:"minIdleConns" yaml:"minIdleConns"`
	MaxConnAge         time.Duration `json:"maxConnAge" yaml:"maxConnAge"`
	PoolTimeout        time.Duration `json:"poolTimeout" yaml:"poolTimeout"`
	IdleTimeout        time.Duration `json:"idleTimeout" yaml:"idleTimeout"`
	IdleCheckFrequency time.Duration `json:"idleCheckFrequency" yaml:"idleCheckFrequency"`
}

Jump to

Keyboard shortcuts

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