cluster

package
v1.2.3 Latest Latest
Warning

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

Go to latest
Published: May 9, 2021 License: GPL-3.0 Imports: 20 Imported by: 0

Documentation

Overview

communicate with peers within cluster

Index

Constants

View Source
const (
	CreatedStatus    = 0
	PreparedStatus   = 1
	CommittedStatus  = 2
	RolledBackStatus = 3
)

Variables

This section is empty.

Functions

func Commit

func Commit(cluster *Cluster, c redis.Connection, args [][]byte) redis.Reply

commit local transaction as a worker

func CommitDel

func CommitDel(cluster *Cluster, c redis.Connection, tx *Transaction) redis.Reply

invoker should provide lock

func CommitMSet

func CommitMSet(cluster *Cluster, c redis.Connection, tx *Transaction) redis.Reply

invoker should provide lock

func Del

func Del(cluster *Cluster, c redis.Connection, args [][]byte) redis.Reply

func FlushAll

func FlushAll(cluster *Cluster, c redis.Connection, args [][]byte) redis.Reply

func FlushDB

func FlushDB(cluster *Cluster, c redis.Connection, args [][]byte) redis.Reply

func MGet

func MGet(cluster *Cluster, c redis.Connection, args [][]byte) redis.Reply

func MSet

func MSet(cluster *Cluster, c redis.Connection, args [][]byte) redis.Reply

func MSetNX

func MSetNX(cluster *Cluster, c redis.Connection, args [][]byte) redis.Reply

func MakeRouter

func MakeRouter() map[string]CmdFunc

func OnRelayedPublish

func OnRelayedPublish(cluster *Cluster, c redis.Connection, args [][]byte) redis.Reply

receive publish command from peer, just publish to local subscribing clients, do not relay to peers

func Ping

func Ping(cluster *Cluster, c redis.Connection, args [][]byte) redis.Reply

func PrepareDel

func PrepareDel(cluster *Cluster, c redis.Connection, args [][]byte) redis.Reply

args: PrepareDel id keys...

func PrepareMSet

func PrepareMSet(cluster *Cluster, c redis.Connection, args [][]byte) redis.Reply

args: PrepareMSet id keys...

func Publish

func Publish(cluster *Cluster, c redis.Connection, args [][]byte) redis.Reply

broadcast msg to all peers in cluster when receive publish command from client

func Rename

func Rename(cluster *Cluster, c redis.Connection, args [][]byte) redis.Reply

Rename renames a key, the origin and the destination must within the same slot

func RenameNx

func RenameNx(cluster *Cluster, c redis.Connection, args [][]byte) redis.Reply

func RequestCommit

func RequestCommit(cluster *Cluster, c redis.Connection, txId int64, peers map[string][]string) ([]redis.Reply, reply.ErrorReply)

request all node commit transaction as leader

func RequestRollback

func RequestRollback(cluster *Cluster, c redis.Connection, txId int64, peers map[string][]string)

request all node rollback transaction as leader

func Rollback

func Rollback(cluster *Cluster, c redis.Connection, args [][]byte) redis.Reply

rollback local transaction

func Subscribe

func Subscribe(cluster *Cluster, c redis.Connection, args [][]byte) redis.Reply

func UnSubscribe

func UnSubscribe(cluster *Cluster, c redis.Connection, args [][]byte) redis.Reply

Types

type Cluster

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

func MakeCluster

func MakeCluster() *Cluster

start current processing as a node of cluster

func (*Cluster) AfterClientClose

func (cluster *Cluster) AfterClientClose(c redis.Connection)

func (*Cluster) Broadcast

func (cluster *Cluster) Broadcast(c redis.Connection, args [][]byte) map[string]redis.Reply

broadcast command to all node in cluster

func (*Cluster) Close

func (cluster *Cluster) Close()

func (*Cluster) Exec

func (cluster *Cluster) Exec(c redis.Connection, args [][]byte) (result redis.Reply)

func (*Cluster) Relay

func (cluster *Cluster) Relay(peer string, c redis.Connection, args [][]byte) redis.Reply

relay command to peer cannot call Prepare, Commit, Rollback of self node

type CmdFunc

type CmdFunc func(cluster *Cluster, c redis.Connection, cmdAndArgs [][]byte) redis.Reply

CmdFunc represents the handler of a redis command

type ConnectionFactory

type ConnectionFactory struct {
	Peer string
}

func (*ConnectionFactory) ActivateObject

func (f *ConnectionFactory) ActivateObject(ctx context.Context, object *pool.PooledObject) error

func (*ConnectionFactory) DestroyObject

func (f *ConnectionFactory) DestroyObject(ctx context.Context, object *pool.PooledObject) error

func (*ConnectionFactory) MakeObject

func (f *ConnectionFactory) MakeObject(ctx context.Context) (*pool.PooledObject, error)

func (*ConnectionFactory) PassivateObject

func (f *ConnectionFactory) PassivateObject(ctx context.Context, object *pool.PooledObject) error

func (*ConnectionFactory) ValidateObject

func (f *ConnectionFactory) ValidateObject(ctx context.Context, object *pool.PooledObject) bool

type Transaction

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

func NewTransaction

func NewTransaction(cluster *Cluster, c redis.Connection, id string, args [][]byte, keys []string) *Transaction

Jump to

Keyboard shortcuts

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