Documentation ¶
Index ¶
- func ActiveSign(active bool) string
- func CleanConnection(connection *redisConnection) error
- func CleanQueue(queue *redisQueue)
- func OpenConnection(tag, network, address string, db int) *redisConnection
- func OpenConnectionWithRedisClient(tag string, redisClient *redis.Client) *redisConnection
- func OpenConnectionWithTestRedisClient(tag string) *redisConnection
- type BatchConsumer
- type Cleaner
- type Connection
- type ConnectionStat
- type ConnectionStats
- type Consumer
- type ConsumerFunc
- type Deliveries
- type Delivery
- type Queue
- type QueueStat
- type QueueStats
- type RedisClient
- type RedisWrapper
- func (wrapper RedisWrapper) Del(key string) (affected int, ok bool)
- func (wrapper RedisWrapper) FlushDb()
- func (wrapper RedisWrapper) LLen(key string) (affected int, ok bool)
- func (wrapper RedisWrapper) LPush(key, value string) bool
- func (wrapper RedisWrapper) LRem(key string, count int, value string) (affected int, ok bool)
- func (wrapper RedisWrapper) LTrim(key string, start, stop int)
- func (wrapper RedisWrapper) RPopLPush(source, destination string) (value string, ok bool)
- func (wrapper RedisWrapper) SAdd(key, value string) bool
- func (wrapper RedisWrapper) SMembers(key string) []string
- func (wrapper RedisWrapper) SRem(key, value string) (affected int, ok bool)
- func (wrapper RedisWrapper) Set(key string, value string, expiration time.Duration) bool
- func (wrapper RedisWrapper) TTL(key string) (ttl time.Duration, ok bool)
- type State
- type Stats
- type TestBatchConsumer
- type TestConnection
- func (connection TestConnection) CollectStats(queueList []string) Stats
- func (connection TestConnection) GetDeliveries(queueName string) []string
- func (connection TestConnection) GetDelivery(queueName string, index int) string
- func (connection TestConnection) GetOpenQueues() []string
- func (connection TestConnection) OpenQueue(name string) Queue
- func (connection TestConnection) Reset()
- type TestConsumer
- type TestDelivery
- type TestQueue
- func (queue *TestQueue) AddBatchConsumer(tag string, batchSize int, consumer BatchConsumer) string
- func (queue *TestQueue) AddBatchConsumerWithTimeout(tag string, batchSize int, timeout time.Duration, consumer BatchConsumer) string
- func (queue *TestQueue) AddConsumer(tag string, consumer Consumer) string
- func (queue *TestQueue) AddConsumerFunc(tag string, consumerFunc ConsumerFunc) string
- func (queue *TestQueue) Close() bool
- func (queue *TestQueue) Publish(payload string) bool
- func (queue *TestQueue) PublishBytes(payload []byte) bool
- func (queue *TestQueue) PurgeReady() int
- func (queue *TestQueue) PurgeRejected() int
- func (queue *TestQueue) Reset()
- func (queue *TestQueue) ReturnAllRejected() int
- func (queue *TestQueue) ReturnAllUnacked() int
- func (queue *TestQueue) ReturnRejected(count int) int
- func (queue *TestQueue) SetPushQueue(pushQueue Queue)
- func (queue *TestQueue) StartConsuming(prefetchLimit int, pollDuration time.Duration) bool
- func (queue *TestQueue) StopConsuming() <-chan struct{}
- func (queue *TestQueue) String() string
- type TestRedisClient
- func (client *TestRedisClient) Del(key string) (affected int, ok bool)
- func (client *TestRedisClient) FlushDb()
- func (client *TestRedisClient) Get(key string) string
- func (client *TestRedisClient) LLen(key string) (affected int, ok bool)
- func (client *TestRedisClient) LPush(key, value string) bool
- func (client *TestRedisClient) LRange(key string, start, end int) []string
- func (client *TestRedisClient) LRem(key string, count int, value string) (affected int, ok bool)
- func (client *TestRedisClient) LTrim(key string, start, stop int)
- func (client *TestRedisClient) RPopLPush(source, destination string) (value string, ok bool)
- func (client *TestRedisClient) SAdd(key, value string) bool
- func (client *TestRedisClient) SMembers(key string) (members []string)
- func (client *TestRedisClient) SRem(key, value string) (affected int, ok bool)
- func (client *TestRedisClient) Set(key string, value string, expiration time.Duration) bool
- func (client *TestRedisClient) TTL(key string) (ttl time.Duration, ok bool)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ActiveSign ¶
func CleanConnection ¶ added in v1.0.1
func CleanConnection(connection *redisConnection) error
func CleanQueue ¶ added in v1.0.1
func CleanQueue(queue *redisQueue)
func OpenConnection ¶
OpenConnection opens and returns a new connection
func OpenConnectionWithRedisClient ¶
OpenConnectionWithRedisClient opens and returns a new connection
func OpenConnectionWithTestRedisClient ¶ added in v1.0.1
func OpenConnectionWithTestRedisClient(tag string) *redisConnection
OpenConnectionWithTestRedisClient opens and returns a new connection which uses a test redis client internally. This is useful in integration tests.
Types ¶
type BatchConsumer ¶
type BatchConsumer interface {
Consume(batch Deliveries)
}
type Cleaner ¶
type Cleaner struct {
// contains filtered or unexported fields
}
func NewCleaner ¶
func NewCleaner(connection Connection) *Cleaner
type Connection ¶
type Connection interface { OpenQueue(name string) Queue CollectStats(queueList []string) Stats GetOpenQueues() []string }
Connection is an interface that can be used to test publishing
type ConnectionStat ¶
type ConnectionStat struct {
// contains filtered or unexported fields
}
func (ConnectionStat) String ¶
func (stat ConnectionStat) String() string
type ConnectionStats ¶
type ConnectionStats map[string]ConnectionStat
type ConsumerFunc ¶ added in v1.0.1
type ConsumerFunc func(Delivery)
func (ConsumerFunc) Consume ¶ added in v1.0.1
func (consumerFunc ConsumerFunc) Consume(delivery Delivery)
type Deliveries ¶
type Deliveries []Delivery
func (Deliveries) Ack ¶
func (deliveries Deliveries) Ack() int
func (Deliveries) Push ¶ added in v1.0.1
func (deliveries Deliveries) Push() int
func (Deliveries) Reject ¶
func (deliveries Deliveries) Reject() int
type Queue ¶
type Queue interface { Publish(payload string) bool PublishBytes(payload []byte) bool SetPushQueue(pushQueue Queue) StartConsuming(prefetchLimit int, pollDuration time.Duration) bool StopConsuming() <-chan struct{} AddConsumer(tag string, consumer Consumer) string AddConsumerFunc(tag string, consumerFunc ConsumerFunc) string AddBatchConsumer(tag string, batchSize int, consumer BatchConsumer) string AddBatchConsumerWithTimeout(tag string, batchSize int, timeout time.Duration, consumer BatchConsumer) string PurgeReady() int PurgeRejected() int ReturnRejected(count int) int ReturnAllRejected() int ReturnAllUnacked() int Close() bool }
type QueueStat ¶
type QueueStat struct { ReadyCount int `json:"ready"` RejectedCount int `json:"rejected"` // contains filtered or unexported fields }
func NewQueueStat ¶
func (QueueStat) ConnectionCount ¶
func (QueueStat) ConsumerCount ¶
func (QueueStat) UnackedCount ¶
type QueueStats ¶
type RedisClient ¶ added in v1.0.1
type RedisClient interface { // simple keys Set(key string, value string, expiration time.Duration) bool Del(key string) (affected int, ok bool) // default affected: 0 TTL(key string) (ttl time.Duration, ok bool) // default ttl: 0 // lists LPush(key, value string) bool LLen(key string) (affected int, ok bool) LRem(key string, count int, value string) (affected int, ok bool) LTrim(key string, start, stop int) RPopLPush(source, destination string) (value string, ok bool) // sets SAdd(key, value string) bool SMembers(key string) (members []string) // default members: []string{} SRem(key, value string) (affected int, ok bool) // default affected: 0 // special FlushDb() }
type RedisWrapper ¶ added in v1.0.1
type RedisWrapper struct {
// contains filtered or unexported fields
}
func (RedisWrapper) Del ¶ added in v1.0.1
func (wrapper RedisWrapper) Del(key string) (affected int, ok bool)
func (RedisWrapper) FlushDb ¶ added in v1.0.1
func (wrapper RedisWrapper) FlushDb()
func (RedisWrapper) LLen ¶ added in v1.0.1
func (wrapper RedisWrapper) LLen(key string) (affected int, ok bool)
func (RedisWrapper) LPush ¶ added in v1.0.1
func (wrapper RedisWrapper) LPush(key, value string) bool
func (RedisWrapper) LTrim ¶ added in v1.0.1
func (wrapper RedisWrapper) LTrim(key string, start, stop int)
func (RedisWrapper) RPopLPush ¶ added in v1.0.1
func (wrapper RedisWrapper) RPopLPush(source, destination string) (value string, ok bool)
func (RedisWrapper) SAdd ¶ added in v1.0.1
func (wrapper RedisWrapper) SAdd(key, value string) bool
func (RedisWrapper) SMembers ¶ added in v1.0.1
func (wrapper RedisWrapper) SMembers(key string) []string
func (RedisWrapper) SRem ¶ added in v1.0.1
func (wrapper RedisWrapper) SRem(key, value string) (affected int, ok bool)
type Stats ¶
type Stats struct { QueueStats QueueStats `json:"queues"` // contains filtered or unexported fields }
func CollectStats ¶
type TestBatchConsumer ¶
type TestBatchConsumer struct { LastBatch Deliveries ConsumedCount int AutoFinish bool // contains filtered or unexported fields }
func NewTestBatchConsumer ¶
func NewTestBatchConsumer() *TestBatchConsumer
func (*TestBatchConsumer) Consume ¶
func (consumer *TestBatchConsumer) Consume(batch Deliveries)
func (*TestBatchConsumer) Finish ¶
func (consumer *TestBatchConsumer) Finish()
type TestConnection ¶
type TestConnection struct {
// contains filtered or unexported fields
}
func NewTestConnection ¶
func NewTestConnection() TestConnection
func (TestConnection) CollectStats ¶
func (connection TestConnection) CollectStats(queueList []string) Stats
func (TestConnection) GetDeliveries ¶
func (connection TestConnection) GetDeliveries(queueName string) []string
func (TestConnection) GetDelivery ¶
func (connection TestConnection) GetDelivery(queueName string, index int) string
func (TestConnection) GetOpenQueues ¶
func (connection TestConnection) GetOpenQueues() []string
func (TestConnection) OpenQueue ¶
func (connection TestConnection) OpenQueue(name string) Queue
func (TestConnection) Reset ¶
func (connection TestConnection) Reset()
type TestConsumer ¶
type TestConsumer struct { AutoAck bool AutoFinish bool SleepDuration time.Duration LastDelivery Delivery LastDeliveries []Delivery // contains filtered or unexported fields }
func NewTestConsumer ¶
func NewTestConsumer(name string) *TestConsumer
func (*TestConsumer) Consume ¶
func (consumer *TestConsumer) Consume(delivery Delivery)
func (*TestConsumer) Finish ¶
func (consumer *TestConsumer) Finish()
func (*TestConsumer) String ¶
func (consumer *TestConsumer) String() string
type TestDelivery ¶
type TestDelivery struct { State State // contains filtered or unexported fields }
func NewTestDelivery ¶
func NewTestDelivery(content interface{}) *TestDelivery
func NewTestDeliveryString ¶
func NewTestDeliveryString(payload string) *TestDelivery
func (*TestDelivery) Ack ¶
func (delivery *TestDelivery) Ack() bool
func (*TestDelivery) Payload ¶
func (delivery *TestDelivery) Payload() string
func (*TestDelivery) Push ¶
func (delivery *TestDelivery) Push() bool
func (*TestDelivery) Reject ¶
func (delivery *TestDelivery) Reject() bool
type TestQueue ¶
type TestQueue struct { LastDeliveries []string // contains filtered or unexported fields }
func NewTestQueue ¶
func (*TestQueue) AddBatchConsumer ¶
func (queue *TestQueue) AddBatchConsumer(tag string, batchSize int, consumer BatchConsumer) string
func (*TestQueue) AddBatchConsumerWithTimeout ¶
func (*TestQueue) AddConsumer ¶
func (*TestQueue) AddConsumerFunc ¶ added in v1.0.1
func (queue *TestQueue) AddConsumerFunc(tag string, consumerFunc ConsumerFunc) string
func (*TestQueue) PublishBytes ¶
func (*TestQueue) PurgeReady ¶
func (*TestQueue) PurgeRejected ¶
func (*TestQueue) ReturnAllRejected ¶
func (*TestQueue) ReturnAllUnacked ¶ added in v1.0.4
func (*TestQueue) ReturnRejected ¶
func (*TestQueue) SetPushQueue ¶
func (*TestQueue) StartConsuming ¶
func (*TestQueue) StopConsuming ¶
func (queue *TestQueue) StopConsuming() <-chan struct{}
type TestRedisClient ¶ added in v1.0.1
type TestRedisClient struct {
// contains filtered or unexported fields
}
TestRedisClient is a mock for redis
func NewTestRedisClient ¶ added in v1.0.1
func NewTestRedisClient() *TestRedisClient
NewTestRedisClient returns a NewTestRedisClient
func (*TestRedisClient) Del ¶ added in v1.0.1
func (client *TestRedisClient) Del(key string) (affected int, ok bool)
Del removes the specified key. A key is ignored if it does not exist.
func (*TestRedisClient) FlushDb ¶ added in v1.0.1
func (client *TestRedisClient) FlushDb()
FlushDb delete all the keys of the currently selected DB. This command never fails.
func (*TestRedisClient) Get ¶ added in v1.0.1
func (client *TestRedisClient) Get(key string) string
Get the value of key. If the key does not exist or isn't a string the special value nil is returned.
func (*TestRedisClient) LLen ¶ added in v1.0.1
func (client *TestRedisClient) LLen(key string) (affected int, ok bool)
LLen returns the length of the list stored at key. If key does not exist, it is interpreted as an empty list and 0 is returned. An error is returned when the value stored at key is not a list.
func (*TestRedisClient) LPush ¶ added in v1.0.1
func (client *TestRedisClient) LPush(key, value string) bool
LPush inserts the specified value at the head of the list stored at key. If key does not exist, it is created as empty list before performing the push operations. When key holds a value that is not a list, an error is returned. It is possible to push multiple elements using a single command call just specifying multiple arguments at the end of the command. Elements are inserted one after the other to the head of the list, from the leftmost element to the rightmost element.
func (*TestRedisClient) LRange ¶ added in v1.0.1
func (client *TestRedisClient) LRange(key string, start, end int) []string
LRange returns the specified elements of the list stored at key. The offsets start and stop are zero-based indexes, with 0 being the first element of the list (the head of the list), 1 being the next element and so on. These offsets can also be negative numbers indicating offsets starting at the end of the list. For example, -1 is the last element of the list, -2 the penultimate, and so on.
func (*TestRedisClient) LRem ¶ added in v1.0.1
LRem removes the first count occurrences of elements equal to value from the list stored at key. The count argument influences the operation in the following ways: count > 0: Remove elements equal to value moving from head to tail. count < 0: Remove elements equal to value moving from tail to head. count = 0: Remove all elements equal to value. For example, LREM list -2 "hello" will remove the last two occurrences of "hello" in the list stored at list. Note that non-existing keys are treated like empty lists, so when key does not exist, the command will always return 0.
func (*TestRedisClient) LTrim ¶ added in v1.0.1
func (client *TestRedisClient) LTrim(key string, start, stop int)
LTrim trims an existing list so that it will contain only the specified range of elements specified. Both start and stop are zero-based indexes, where 0 is the first element of the list (the head), 1 the next element and so on. For example: LTRIM foobar 0 2 will modify the list stored at foobar so that only the first three elements of the list will remain. start and end can also be negative numbers indicating offsets from the end of the list, where -1 is the last element of the list, -2 the penultimate element and so on. Out of range indexes will not produce an error: if start is larger than the end of the list, or start > end, the result will be an empty list (which causes key to be removed). If end is larger than the end of the list, Redis will treat it like the last element of the list
func (*TestRedisClient) RPopLPush ¶ added in v1.0.1
func (client *TestRedisClient) RPopLPush(source, destination string) (value string, ok bool)
RPopLPush atomically returns and removes the last element (tail) of the list stored at source, and pushes the element at the first element (head) of the list stored at destination. For example: consider source holding the list a,b,c, and destination holding the list x,y,z. Executing RPOPLPUSH results in source holding a,b and destination holding c,x,y,z. If source does not exist, the value nil is returned and no operation is performed. If source and destination are the same, the operation is equivalent to removing the last element from the list and pushing it as first element of the list, so it can be considered as a list rotation command.
func (*TestRedisClient) SAdd ¶ added in v1.0.1
func (client *TestRedisClient) SAdd(key, value string) bool
SAdd adds the specified members to the set stored at key. Specified members that are already a member of this set are ignored. If key does not exist, a new set is created before adding the specified members. An error is returned when the value stored at key is not a set.
func (*TestRedisClient) SMembers ¶ added in v1.0.1
func (client *TestRedisClient) SMembers(key string) (members []string)
SMembers returns all the members of the set value stored at key. This has the same effect as running SINTER with one argument key.
func (*TestRedisClient) SRem ¶ added in v1.0.1
func (client *TestRedisClient) SRem(key, value string) (affected int, ok bool)
SRem removes the specified members from the set stored at key. Specified members that are not a member of this set are ignored. If key does not exist, it is treated as an empty set and this command returns 0. An error is returned when the value stored at key is not a set.
func (*TestRedisClient) Set ¶ added in v1.0.1
Set sets key to hold the string value. If key already holds a value, it is overwritten, regardless of its type. Any previous time to live associated with the key is discarded on successful SET operation.
func (*TestRedisClient) TTL ¶ added in v1.0.1
func (client *TestRedisClient) TTL(key string) (ttl time.Duration, ok bool)
TTL returns the remaining time to live of a key that has a timeout. This introspection capability allows a Redis client to check how many seconds a given key will continue to be part of the dataset. In Redis 2.6 or older the command returns -1 if the key does not exist or if the key exist but has no associated expire. Starting with Redis 2.8 the return value in case of error changed: The command returns -2 if the key does not exist. The command returns -1 if the key exists but has no associated expire.