protocol

package
v0.7.2 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2025 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultScanCount = 10
View Source
const StatusOK = "OK"

Variables

View Source
var Cluster = &ClusterCommands{
	RoutingTable: "cluster.routingtable",
	Members:      "cluster.members",
}
View Source
var DMap = &DMapCommands{
	Get:         "dm.get",
	GetEntry:    "dm.getentry",
	Put:         "dm.put",
	PutEntry:    "dm.putentry",
	Del:         "dm.del",
	DelEntry:    "dm.delentry",
	Expire:      "dm.expire",
	PExpire:     "dm.pexpire",
	Destroy:     "dm.destroy",
	Incr:        "dm.incr",
	Decr:        "dm.decr",
	GetPut:      "dm.getput",
	IncrByFloat: "dm.incrbyfloat",
	Lock:        "dm.lock",
	Unlock:      "dm.unlock",
	LockLease:   "dm.locklease",
	PLockLease:  "dm.plocklease",
	Scan:        "dm.scan",
}
View Source
var ErrInvalidArgument = errors.New("invalid argument")
View Source
var Generic = &GenericCommands{
	Ping:  "ping",
	Stats: "stats",
	Auth:  "auth",
}
View Source
var GenericError = "ERR"
View Source
var Internal = &InternalCommands{
	MoveFragment:  "internal.node.movefragment",
	UpdateRouting: "internal.node.updaterouting",
	LengthOfPart:  "internal.node.lengthofpart",
}
View Source
var PubSub = &PubSubCommands{
	PubSub:          "pubsub",
	Publish:         "publish",
	PublishInternal: "publish.internal",
	Subscribe:       "subscribe",
	PSubscribe:      "psubscribe",
	PubSubChannels:  "pubsub channels",
	PubSubNumpat:    "pubsub numpat",
	PubSubNumsub:    "pubsub numsub",
}

Functions

func ConvertError

func ConvertError(err error) error

func GetError

func GetError(prefix string) error

func GetPrefix

func GetPrefix(err error) string

func SetError

func SetError(prefix string, err error)

func WriteError

func WriteError(conn redcon.Conn, err error)

Types

type Auth added in v0.7.0

type Auth struct {
	Password string
}

Auth represents a structure for authentication containing a password.

func NewAuth added in v0.7.0

func NewAuth(password string) *Auth

NewAuth creates and returns a new Auth instance initialized with the given password.

func ParseAuthCommand added in v0.7.0

func ParseAuthCommand(cmd redcon.Command) (*Auth, error)

ParseAuthCommand parses a redcon.Command to create an Auth instance and validates command arguments.

func (*Auth) Command added in v0.7.0

func (a *Auth) Command(ctx context.Context) *redis.StatusCmd

Command constructs a Redis AUTH command using the provided authentication password from the Auth instance.

type ClusterCommands

type ClusterCommands struct {
	RoutingTable string
	Members      string
}

type ClusterMembers

type ClusterMembers struct{}

func NewClusterMembers

func NewClusterMembers() *ClusterMembers

func ParseClusterMembers

func ParseClusterMembers(cmd redcon.Command) (*ClusterMembers, error)

func (*ClusterMembers) Command

func (c *ClusterMembers) Command(ctx context.Context) *redis.Cmd

type ClusterRoutingTable

type ClusterRoutingTable struct{}

func NewClusterRoutingTable

func NewClusterRoutingTable() *ClusterRoutingTable

func ParseClusterRoutingTable

func ParseClusterRoutingTable(cmd redcon.Command) (*ClusterRoutingTable, error)

func (*ClusterRoutingTable) Command

func (c *ClusterRoutingTable) Command(ctx context.Context) *redis.Cmd

type DMapCommands

type DMapCommands struct {
	Get         string
	GetEntry    string
	Put         string
	PutEntry    string
	Del         string
	DelEntry    string
	Expire      string
	PExpire     string
	Destroy     string
	Query       string
	Incr        string
	Decr        string
	GetPut      string
	IncrByFloat string
	Lock        string
	Unlock      string
	LockLease   string
	PLockLease  string
	Scan        string
}

type Decr

type Decr struct {
	*Incr
}

func NewDecr

func NewDecr(dmap, key string, delta int) *Decr

func ParseDecrCommand

func ParseDecrCommand(cmd redcon.Command) (*Decr, error)

func (*Decr) Command

func (d *Decr) Command(ctx context.Context) *redis.IntCmd

type Del

type Del struct {
	DMap string
	Keys []string
}

func NewDel

func NewDel(dmap string, keys ...string) *Del

func ParseDelCommand

func ParseDelCommand(cmd redcon.Command) (*Del, error)

func (*Del) Command

func (d *Del) Command(ctx context.Context) *redis.IntCmd

type DelEntry

type DelEntry struct {
	Del     *Del
	Replica bool
}

func NewDelEntry

func NewDelEntry(dmap, key string) *DelEntry

func ParseDelEntryCommand

func ParseDelEntryCommand(cmd redcon.Command) (*DelEntry, error)

func (*DelEntry) Command

func (d *DelEntry) Command(ctx context.Context) *redis.IntCmd

func (*DelEntry) SetReplica

func (d *DelEntry) SetReplica() *DelEntry

type Destroy

type Destroy struct {
	DMap  string
	Local bool
}

func NewDestroy

func NewDestroy(dmap string) *Destroy

func ParseDestroyCommand

func ParseDestroyCommand(cmd redcon.Command) (*Destroy, error)

func (*Destroy) Command

func (d *Destroy) Command(ctx context.Context) *redis.StatusCmd

func (*Destroy) SetLocal

func (d *Destroy) SetLocal() *Destroy

type Expire

type Expire struct {
	DMap    string
	Key     string
	Seconds time.Duration
}

func NewExpire

func NewExpire(dmap, key string, seconds time.Duration) *Expire

func ParseExpireCommand

func ParseExpireCommand(cmd redcon.Command) (*Expire, error)

func (*Expire) Command

func (e *Expire) Command(ctx context.Context) *redis.StatusCmd

type GenericCommands

type GenericCommands struct {
	Ping  string
	Stats string
	Auth  string
}

type Get

type Get struct {
	DMap string
	Key  string
	Raw  bool
}

func NewGet

func NewGet(dmap, key string) *Get

func ParseGetCommand

func ParseGetCommand(cmd redcon.Command) (*Get, error)

func (*Get) Command

func (g *Get) Command(ctx context.Context) *redis.StringCmd

func (*Get) SetRaw

func (g *Get) SetRaw() *Get

type GetEntry

type GetEntry struct {
	DMap    string
	Key     string
	Replica bool
}

func NewGetEntry

func NewGetEntry(dmap, key string) *GetEntry

func ParseGetEntryCommand

func ParseGetEntryCommand(cmd redcon.Command) (*GetEntry, error)

func (*GetEntry) Command

func (g *GetEntry) Command(ctx context.Context) *redis.StringCmd

func (*GetEntry) SetReplica

func (g *GetEntry) SetReplica() *GetEntry

type GetPut

type GetPut struct {
	DMap  string
	Key   string
	Value []byte
	Raw   bool
}

func NewGetPut

func NewGetPut(dmap, key string, value []byte) *GetPut

func ParseGetPutCommand

func ParseGetPutCommand(cmd redcon.Command) (*GetPut, error)

func (*GetPut) Command

func (g *GetPut) Command(ctx context.Context) *redis.StringCmd

func (*GetPut) SetRaw

func (g *GetPut) SetRaw() *GetPut

type Incr

type Incr struct {
	DMap  string
	Key   string
	Delta int
}

func NewIncr

func NewIncr(dmap, key string, delta int) *Incr

func ParseIncrCommand

func ParseIncrCommand(cmd redcon.Command) (*Incr, error)

func (*Incr) Command

func (i *Incr) Command(ctx context.Context) *redis.IntCmd

type IncrByFloat

type IncrByFloat struct {
	DMap  string
	Key   string
	Delta float64
}

func NewIncrByFloat

func NewIncrByFloat(dmap, key string, delta float64) *IncrByFloat

func ParseIncrByFloatCommand

func ParseIncrByFloatCommand(cmd redcon.Command) (*IncrByFloat, error)

func (*IncrByFloat) Command

func (i *IncrByFloat) Command(ctx context.Context) *redis.FloatCmd

type InternalCommands

type InternalCommands struct {
	MoveFragment        string
	UpdateRouting       string
	LengthOfPart        string
	ClusterRoutingTable string
}

type LengthOfPart

type LengthOfPart struct {
	PartID  uint64
	Replica bool
}

func NewLengthOfPart

func NewLengthOfPart(partID uint64) *LengthOfPart

func ParseLengthOfPartCommand

func ParseLengthOfPartCommand(cmd redcon.Command) (*LengthOfPart, error)

func (*LengthOfPart) Command

func (l *LengthOfPart) Command(ctx context.Context) *redis.IntCmd

func (*LengthOfPart) SetReplica

func (l *LengthOfPart) SetReplica() *LengthOfPart

type Lock

type Lock struct {
	DMap     string
	Key      string
	Deadline float64
	EX       float64
	PX       int64
}

func NewLock

func NewLock(dmap, key string, deadline float64) *Lock

func ParseLockCommand

func ParseLockCommand(cmd redcon.Command) (*Lock, error)

func (*Lock) Command

func (l *Lock) Command(ctx context.Context) *redis.StringCmd

func (*Lock) SetEX

func (l *Lock) SetEX(ex float64) *Lock

func (*Lock) SetPX

func (l *Lock) SetPX(px int64) *Lock

type LockLease

type LockLease struct {
	DMap    string
	Key     string
	Token   string
	Timeout float64
}

func NewLockLease

func NewLockLease(dmap, key, token string, timeout float64) *LockLease

func ParseLockLeaseCommand

func ParseLockLeaseCommand(cmd redcon.Command) (*LockLease, error)

func (*LockLease) Command

func (l *LockLease) Command(ctx context.Context) *redis.StatusCmd

type MoveFragment

type MoveFragment struct {
	Payload []byte
}

func NewMoveFragment

func NewMoveFragment(payload []byte) *MoveFragment

func ParseMoveFragmentCommand

func ParseMoveFragmentCommand(cmd redcon.Command) (*MoveFragment, error)

func (*MoveFragment) Command

func (m *MoveFragment) Command(ctx context.Context) *redis.StatusCmd

type PExpire

type PExpire struct {
	DMap         string
	Key          string
	Milliseconds time.Duration
}

func NewPExpire

func NewPExpire(dmap, key string, milliseconds time.Duration) *PExpire

func ParsePExpireCommand

func ParsePExpireCommand(cmd redcon.Command) (*PExpire, error)

func (*PExpire) Command

func (p *PExpire) Command(ctx context.Context) *redis.StatusCmd

type PLockLease

type PLockLease struct {
	DMap    string
	Key     string
	Token   string
	Timeout int64
}

func NewPLockLease

func NewPLockLease(dmap, key, token string, timeout int64) *PLockLease

func ParsePLockLeaseCommand

func ParsePLockLeaseCommand(cmd redcon.Command) (*PLockLease, error)

func (*PLockLease) Command

func (p *PLockLease) Command(ctx context.Context) *redis.StatusCmd

type PSubscribe

type PSubscribe struct {
	Patterns []string
}

func NewPSubscribe

func NewPSubscribe(patterns ...string) *PSubscribe

func ParsePSubscribeCommand

func ParsePSubscribeCommand(cmd redcon.Command) (*PSubscribe, error)

func (*PSubscribe) Command

func (s *PSubscribe) Command(ctx context.Context) *redis.SliceCmd

type Ping

type Ping struct {
	Message string
}

func NewPing

func NewPing() *Ping

func ParsePingCommand

func ParsePingCommand(cmd redcon.Command) (*Ping, error)

func (*Ping) Command

func (p *Ping) Command(ctx context.Context) *redis.StringCmd

func (*Ping) SetMessage

func (p *Ping) SetMessage(m string) *Ping

type PubSubChannels

type PubSubChannels struct {
	Pattern string
}

func NewPubSubChannels

func NewPubSubChannels() *PubSubChannels

func ParsePubSubChannelsCommand

func ParsePubSubChannelsCommand(cmd redcon.Command) (*PubSubChannels, error)

func (*PubSubChannels) Command

func (ps *PubSubChannels) Command(ctx context.Context) *redis.SliceCmd

func (*PubSubChannels) SetPattern

func (ps *PubSubChannels) SetPattern(pattern string) *PubSubChannels

type PubSubCommands

type PubSubCommands struct {
	PubSub          string
	Publish         string
	PublishInternal string
	Subscribe       string
	PSubscribe      string
	PubSubChannels  string
	PubSubNumpat    string
	PubSubNumsub    string
}

type PubSubNumpat

type PubSubNumpat struct{}

func NewPubSubNumpat

func NewPubSubNumpat() *PubSubNumpat

func ParsePubSubNumpatCommand

func ParsePubSubNumpatCommand(cmd redcon.Command) (*PubSubNumpat, error)

func (*PubSubNumpat) Command

func (ps *PubSubNumpat) Command(ctx context.Context) *redis.IntCmd

type PubSubNumsub

type PubSubNumsub struct {
	Channels []string
}

func NewPubSubNumsub

func NewPubSubNumsub(channels ...string) *PubSubNumsub

func ParsePubSubNumsubCommand

func ParsePubSubNumsubCommand(cmd redcon.Command) (*PubSubNumsub, error)

func (*PubSubNumsub) Command

func (ps *PubSubNumsub) Command(ctx context.Context) *redis.SliceCmd

type Publish

type Publish struct {
	Channel string
	Message string
}

func NewPublish

func NewPublish(channel, message string) *Publish

func ParsePublishCommand

func ParsePublishCommand(cmd redcon.Command) (*Publish, error)

func (*Publish) Command

func (p *Publish) Command(ctx context.Context) *redis.IntCmd

type PublishInternal

type PublishInternal struct {
	Channel string
	Message string
}

func NewPublishInternal

func NewPublishInternal(channel, message string) *PublishInternal

func ParsePublishInternalCommand

func ParsePublishInternalCommand(cmd redcon.Command) (*PublishInternal, error)

func (*PublishInternal) Command

func (p *PublishInternal) Command(ctx context.Context) *redis.IntCmd

type Put

type Put struct {
	DMap  string
	Key   string
	Value []byte
	EX    float64
	PX    int64
	EXAT  float64
	PXAT  int64
	NX    bool
	XX    bool
}

func NewPut

func NewPut(dmap, key string, value []byte) *Put

func ParsePutCommand

func ParsePutCommand(cmd redcon.Command) (*Put, error)

func (*Put) Command

func (p *Put) Command(ctx context.Context) *redis.StatusCmd

func (*Put) SetEX

func (p *Put) SetEX(ex float64) *Put

func (*Put) SetEXAT

func (p *Put) SetEXAT(exat float64) *Put

func (*Put) SetNX

func (p *Put) SetNX() *Put

func (*Put) SetPX

func (p *Put) SetPX(px int64) *Put

func (*Put) SetPXAT

func (p *Put) SetPXAT(pxat int64) *Put

func (*Put) SetXX

func (p *Put) SetXX() *Put

type PutEntry

type PutEntry struct {
	DMap  string
	Key   string
	Value []byte
}

func NewPutEntry

func NewPutEntry(dmap, key string, value []byte) *PutEntry

func ParsePutEntryCommand

func ParsePutEntryCommand(cmd redcon.Command) (*PutEntry, error)

func (*PutEntry) Command

func (p *PutEntry) Command(ctx context.Context) *redis.StatusCmd

type Scan

type Scan struct {
	PartID  uint64
	DMap    string
	Cursor  uint64
	Count   int
	Match   string
	Replica bool
}

func NewScan

func NewScan(partID uint64, dmap string, cursor uint64) *Scan

func ParseScanCommand

func ParseScanCommand(cmd redcon.Command) (*Scan, error)

func (*Scan) Command

func (s *Scan) Command(ctx context.Context) *redis.ScanCmd

func (*Scan) SetCount

func (s *Scan) SetCount(count int) *Scan

func (*Scan) SetMatch

func (s *Scan) SetMatch(match string) *Scan

func (*Scan) SetReplica

func (s *Scan) SetReplica() *Scan

type Stats

type Stats struct {
	CollectRuntime bool
}

func NewStats

func NewStats() *Stats

func ParseStatsCommand

func ParseStatsCommand(cmd redcon.Command) (*Stats, error)

func (*Stats) Command

func (s *Stats) Command(ctx context.Context) *redis.StringCmd

func (*Stats) SetCollectRuntime

func (s *Stats) SetCollectRuntime() *Stats

type Subscribe

type Subscribe struct {
	Channels []string
}

func NewSubscribe

func NewSubscribe(channels ...string) *Subscribe

func ParseSubscribeCommand

func ParseSubscribeCommand(cmd redcon.Command) (*Subscribe, error)

func (*Subscribe) Command

func (s *Subscribe) Command(ctx context.Context) *redis.SliceCmd

type Unlock

type Unlock struct {
	DMap  string
	Key   string
	Token string
}

func NewUnlock

func NewUnlock(dmap, key, token string) *Unlock

func ParseUnlockCommand

func ParseUnlockCommand(cmd redcon.Command) (*Unlock, error)

func (*Unlock) Command

func (u *Unlock) Command(ctx context.Context) *redis.StatusCmd

type UpdateRouting

type UpdateRouting struct {
	Payload       []byte
	CoordinatorID uint64
}

func NewUpdateRouting

func NewUpdateRouting(payload []byte, coordinatorID uint64) *UpdateRouting

func ParseUpdateRoutingCommand

func ParseUpdateRoutingCommand(cmd redcon.Command) (*UpdateRouting, error)

func (*UpdateRouting) Command

func (u *UpdateRouting) Command(ctx context.Context) *redis.StringCmd

Jump to

Keyboard shortcuts

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