Documentation ¶
Index ¶
- Constants
- Variables
- func NewService(ctx gousu.IContext) gousu.IService
- type IService
- type ISubscription
- type Message
- type MockService
- func (s *MockService) BLPop(key string, timeout int) ([]byte, error)
- func (s *MockService) Del(key string) error
- func (s *MockService) Exists(key string) (bool, error)
- func (s *MockService) Get(key string) ([]byte, error)
- func (s *MockService) GetPool() *redis.Pool
- func (s *MockService) HDel(key string, field string) error
- func (s *MockService) HGet(key string, field string) ([]byte, error)
- func (s *MockService) HKeys(key string) ([][]byte, error)
- func (s *MockService) HLen(key string) (int, error)
- func (s *MockService) HScan(key string, cursor int) (int, map[string][]byte, error)
- func (s *MockService) HSet(key string, field string, data []byte) error
- func (s *MockService) LIndex(key string, position int) ([]byte, error)
- func (s *MockService) LLen(key string) (int, error)
- func (s *MockService) LPop(key string) ([]byte, error)
- func (s *MockService) LPush(key string, data []byte) (int, error)
- func (s *MockService) LRange(key string, start int, stop int) ([][]byte, error)
- func (s *MockService) LRem(key string, count int, data []byte) (int, error)
- func (s *MockService) NewMutex(name string, options ...redsync.Option) *redsync.Mutex
- func (s *MockService) Publish(channel string, data []byte) error
- func (s *MockService) RPop(key string) ([]byte, error)
- func (s *MockService) RPush(key string, data []byte) (int, error)
- func (s *MockService) Scan(pattern string, cursor int) (int, []string, error)
- func (s *MockService) ScanAll(pattern string, limit null.Int) ([]string, error)
- func (s *MockService) Set(key string, data []byte) error
- func (s *MockService) SetNXPX(key string, data []byte, timeoutMS int) error
- func (s *MockService) SetPX(key string, data []byte, timeoutMS int) error
- func (s *MockService) Subscribe(channels []string) (chan Message, ISubscription, error)
- func (s *MockService) XAck(groupName string, key string, id string) (int, error)
- func (s *MockService) XAdd(key string, data map[string]string) (string, error)
- func (s *MockService) XGroupCreate(groupName string, key string, offset XGroupCreateOffset, mkStream bool, ...) error
- func (s *MockService) XReadGroup(groupName string, consumerName string, key string, timeout time.Duration, ...) (*XEvent, error)
- type Service
- func (s *Service) BLPop(key string, timeout int) ([]byte, error)
- func (s *Service) Del(key string) error
- func (s *Service) Exists(key string) (bool, error)
- func (s *Service) Get(key string) ([]byte, error)
- func (s *Service) GetPool() *redis.Pool
- func (s *Service) HDel(key string, field string) error
- func (s *Service) HGet(key string, field string) ([]byte, error)
- func (s *Service) HKeys(key string) ([][]byte, error)
- func (s *Service) HLen(key string) (int, error)
- func (s *Service) HScan(key string, cursor int) (int, map[string][]byte, error)
- func (s *Service) HSet(key string, field string, data []byte) error
- func (s *Service) Health() error
- func (s *Service) LIndex(key string, position int) ([]byte, error)
- func (s *Service) LLen(key string) (int, error)
- func (s *Service) LPop(key string) ([]byte, error)
- func (s *Service) LPush(key string, data []byte) (int, error)
- func (s *Service) LRange(key string, start int, stop int) ([][]byte, error)
- func (s *Service) LRem(key string, count int, data []byte) (int, error)
- func (s *Service) Name() string
- func (s *Service) NewMutex(name string, options ...redsync.Option) *redsync.Mutex
- func (s *Service) Publish(channel string, data []byte) error
- func (s *Service) RPop(key string) ([]byte, error)
- func (s *Service) RPush(key string, data []byte) (int, error)
- func (s *Service) Scan(pattern string, cursor int) (int, []string, error)
- func (s *Service) ScanAll(pattern string, limit null.Int) ([]string, error)
- func (s *Service) Set(key string, data []byte) error
- func (s *Service) SetNXPX(key string, data []byte, timeoutMS int) error
- func (s *Service) SetPX(key string, data []byte, timeoutMS int) error
- func (s *Service) Start() error
- func (s *Service) Stop() error
- func (s *Service) Subscribe(channels []string) (chan Message, ISubscription, error)
- func (s *Service) XAck(groupName string, key string, id string) (int, error)
- func (s *Service) XAdd(key string, data map[string]string) (string, error)
- func (s *Service) XGroupCreate(groupName string, key string, offset XGroupCreateOffset, mkStream bool, ...) error
- func (s *Service) XReadGroup(groupName string, consumerName string, key string, timeout time.Duration, ...) (*XEvent, error)
- type Subscription
- type XEvent
- type XGroupCreateOffset
- type XReadGroupStreamID
Constants ¶
const ServiceName = "redis"
ServiceName defines the name of redis service used for dependency injection
Variables ¶
var ErrNil = redis.ErrNil
ErrNil is the error returned if no matching data was found
Functions ¶
Types ¶
type IService ¶
type IService interface { gousu.IService NewMutex(name string, options ...redsync.Option) *redsync.Mutex GetPool() *redis.Pool Get(key string) ([]byte, error) Set(key string, data []byte) error SetNXPX(key string, data []byte, timeoutMS int) error SetPX(key string, data []byte, timeoutMS int) error Del(key string) error Exists(key string) (bool, error) Scan(pattern string, cursor int) (int, []string, error) ScanAll(pattern string, limit null.Int) ([]string, error) RPush(key string, data []byte) (int, error) LPush(key string, data []byte) (int, error) LRange(key string, start int, stop int) ([][]byte, error) LRem(key string, count int, data []byte) (int, error) LPop(key string) ([]byte, error) RPop(key string) ([]byte, error) BLPop(key string, timeout int) ([]byte, error) HGet(key string, field string) ([]byte, error) HSet(key string, field string, data []byte) error HScan(key string, cursor int) (int, map[string][]byte, error) HKeys(key string) ([][]byte, error) HDel(key string, field string) error HLen(key string) (int, error) LIndex(key string, position int) ([]byte, error) LLen(key string) (int, error) Subscribe(channels []string) (chan Message, ISubscription, error) Publish(channel string, data []byte) error XAdd(key string, data map[string]string) (string, error) XGroupCreate(groupName string, key string, offset XGroupCreateOffset, mkStream bool, ignoreBusy bool) error XReadGroup(groupName string, consumerName string, key string, timeout time.Duration, streamID XReadGroupStreamID) (*XEvent, error) XAck(groupName string, key string, id string) (int, error) }
IService defines the interface of the redis service
type ISubscription ¶
type ISubscription interface { Subscribe(channel ...interface{}) error Unsubscribe(channel ...interface{}) error Close() error }
ISubscription defines the interface of Subscription
type MockService ¶
type MockService struct { gousu.MockService NewMutexFunc func(name string, options ...redsync.Option) *redsync.Mutex GetPoolFunc func() *redis.Pool GetFunc func(key string) ([]byte, error) SetFunc func(key string, data []byte) error SetNXPXFunc func(key string, data []byte, timeoutMS int) error SetPXFunc func(key string, data []byte, timeoutMS int) error DelFunc func(key string) error ExistsFunc func(key string) (bool, error) ScanFunc func(pattern string, cursor int) (int, []string, error) ScanAllFunc func(pattern string, limit null.Int) ([]string, error) RPushFunc func(key string, data []byte) (int, error) LPushFunc func(key string, data []byte) (int, error) LRangeFunc func(key string, start int, stop int) ([][]byte, error) LRemFunc func(key string, count int, data []byte) (int, error) LPopFunc func(key string) ([]byte, error) RPopFunc func(key string) ([]byte, error) BLPopFunc func(key string, timeout int) ([]byte, error) HGetFunc func(key string, field string) ([]byte, error) HSetFunc func(key string, field string, data []byte) error HScanFunc func(key string, cursor int) (int, map[string][]byte, error) HKeysFunc func(key string) ([][]byte, error) HDelFunc func(key string, field string) error HLenFunc func(key string) (int, error) LIndexFunc func(key string, position int) ([]byte, error) LLenFunc func(key string) (int, error) SubscribeFunc func(channels []string) (chan Message, ISubscription, error) PublishFunc func(channel string, data []byte) error XAddFunc func(key string, data map[string]string) (string, error) XGroupCreateFunc func(groupName string, key string, offset XGroupCreateOffset, mkStream bool, ignoreBusy bool) error XReadGroupFunc func(groupName string, consumerName string, key string, timeout time.Duration, streamID XReadGroupStreamID) (*XEvent, error) XAckFunc func(groupName string, key string, id string) (int, error) NewMutexFuncCalled int GetPoolFuncCalled int GetFuncCalled int SetFuncCalled int SetNXPXFuncCalled int SetPXFuncCalled int DelFuncCalled int ExistsFuncCalled int ScanFuncCalled int ScanAllFuncCalled int RPushFuncCalled int LPushFuncCalled int LRangeFuncCalled int LRemFuncCalled int LPopFuncCalled int RPopFuncCalled int BLPopFuncCalled int HGetFuncCalled int HSetFuncCalled int HScanFuncCalled int HKeysFuncCalled int HDelFuncCalled int HLenFuncCalled int LIndexFuncCalled int LLenFuncCalled int SubscribeFuncCalled int PublishFuncCalled int XAddFuncCalled int XGroupCreateFuncCalled int XReadGroupFuncCalled int XAckFuncCalled int }
MockService for simply mocking IService
func NewMockService ¶
func NewMockService() *MockService
NewMockService creates a new initialized instance of MockService
func (*MockService) BLPop ¶
func (s *MockService) BLPop(key string, timeout int) ([]byte, error)
BLPop calls BLPopFunc and increases BLPopFuncCalled
func (*MockService) Del ¶
func (s *MockService) Del(key string) error
Del calls DelFunc and increases DelFuncCalled
func (*MockService) Exists ¶
func (s *MockService) Exists(key string) (bool, error)
Exists calls ExistsFunc and increases ExistsFuncCalled
func (*MockService) Get ¶
func (s *MockService) Get(key string) ([]byte, error)
Get calls GetFunc and increases GetFuncCalled
func (*MockService) GetPool ¶
func (s *MockService) GetPool() *redis.Pool
GetPool calls GetPoolFunc and increases GetPoolFuncCalled
func (*MockService) HDel ¶
func (s *MockService) HDel(key string, field string) error
HDel calls HDelFunc and increases HDelFuncCalled
func (*MockService) HGet ¶
func (s *MockService) HGet(key string, field string) ([]byte, error)
HGet calls GetFunc and increases GetFuncCalled
func (*MockService) HKeys ¶
func (s *MockService) HKeys(key string) ([][]byte, error)
HKeys calls HKeysFunc and increases HKeysFuncCalled
func (*MockService) HLen ¶
func (s *MockService) HLen(key string) (int, error)
HLen calls HLenFunc and increases HLenFuncCalled
func (*MockService) HSet ¶
func (s *MockService) HSet(key string, field string, data []byte) error
HSet calls SetFunc and increases SetFuncCalled
func (*MockService) LIndex ¶
func (s *MockService) LIndex(key string, position int) ([]byte, error)
LIndex calls LIndexFunc and increases LIndexFuncCalled
func (*MockService) LLen ¶
func (s *MockService) LLen(key string) (int, error)
LLen calls LLenFunc and increases LLenFuncCalled
func (*MockService) LPop ¶
func (s *MockService) LPop(key string) ([]byte, error)
LPop calls LPopFunc and increases LPopFuncCalled
func (*MockService) LPush ¶
func (s *MockService) LPush(key string, data []byte) (int, error)
LPush calls LPushFunc and increases LPushFuncCalled
func (*MockService) NewMutex ¶
func (s *MockService) NewMutex(name string, options ...redsync.Option) *redsync.Mutex
NewMutex calls NewMutexFunc and increases NewMutexFuncCalled
func (*MockService) Publish ¶
func (s *MockService) Publish(channel string, data []byte) error
Publish calls PublishFunc and increases PublishFuncCalled
func (*MockService) RPop ¶
func (s *MockService) RPop(key string) ([]byte, error)
RPop calls RPopFunc and increases RPopFuncCalled
func (*MockService) RPush ¶
func (s *MockService) RPush(key string, data []byte) (int, error)
RPush calls RPushFunc and increases RPushFuncCalled
func (*MockService) ScanAll ¶
func (s *MockService) ScanAll(pattern string, limit null.Int) ([]string, error)
ScanAll calls ScanAllFunc and increases ScanAllFuncCalled
func (*MockService) Set ¶
func (s *MockService) Set(key string, data []byte) error
Set calls SetFunc and increases SetFuncCalled
func (*MockService) SetNXPX ¶
func (s *MockService) SetNXPX(key string, data []byte, timeoutMS int) error
SetNXPX calls SetNXPXFunc and increases SetNXPXFuncCalled
func (*MockService) SetPX ¶
func (s *MockService) SetPX(key string, data []byte, timeoutMS int) error
SetPX calls SetPXFunc and increases SetPXFuncCalled
func (*MockService) Subscribe ¶
func (s *MockService) Subscribe(channels []string) (chan Message, ISubscription, error)
Subscribe calls SubscribeFunc and increases SubscribeFunc
func (*MockService) XGroupCreate ¶
func (s *MockService) XGroupCreate(groupName string, key string, offset XGroupCreateOffset, mkStream bool, ignoreBusy bool) error
XGroupCreate calls XGroupCreateFunc and increases XGroupCreateFuncCalled
func (*MockService) XReadGroup ¶
func (s *MockService) XReadGroup(groupName string, consumerName string, key string, timeout time.Duration, streamID XReadGroupStreamID) (*XEvent, error)
XReadGroup calls XReadGroupFunc and increases XReadGroupFuncCalled
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service provides a service for basic redis client functionality
Used flags:
- redis_host Hostname of redis service
- redis_port Port of redis service
func (*Service) GetPool ¶
GetPool returns the redis connection pool if not in cluster mode, else nil
func (*Service) Scan ¶
Scan scans keys for a specific pattern and returns a list of keys Important: Running Scan(...) in a cluster can return only partial results
func (*Service) ScanAll ¶
ScanAll scans all keys for a specific pattern and returns a list of keys Supports being run in a cluster Important: The resulting list is unordered
func (*Service) SetNXPX ¶
SetNXPX stores a key and its value if it does not exist with expiration time in redis
func (*Service) Subscribe ¶
func (s *Service) Subscribe(channels []string) (chan Message, ISubscription, error)
Subscribe subscribes to channels and returns a subscription
func (*Service) XGroupCreate ¶
func (s *Service) XGroupCreate(groupName string, key string, offset XGroupCreateOffset, mkStream bool, ignoreBusy bool) error
XGroupCreate adds an stream event
type Subscription ¶
type Subscription struct {
// contains filtered or unexported fields
}
Subscription is used to track a subscription to a channel via Subscribe(...)
func (*Subscription) Close ¶
func (s *Subscription) Close() error
Close unsubscribes from all subscriptions and closes the connection
func (*Subscription) Subscribe ¶
func (s *Subscription) Subscribe(channel ...interface{}) error
Subscribe subscribes to one or multiple channels
func (*Subscription) Unsubscribe ¶
func (s *Subscription) Unsubscribe(channel ...interface{}) error
Unsubscribe unsubscribes from one or multiple channels
type XGroupCreateOffset ¶
type XGroupCreateOffset = string
const ( XGroupCreateOffsetLast XGroupCreateOffset = "$" XGroupCreateOffsetFirst XGroupCreateOffset = "0" )
type XReadGroupStreamID ¶
type XReadGroupStreamID = string
const ( XReadGroupIDStreamNew XReadGroupStreamID = ">" XReadGroupIDStreamPending XReadGroupStreamID = "0" )