client

package
v0.0.0-...-4cb854e Latest Latest
Warning

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

Go to latest
Published: May 1, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const EVENT_MODE_DEFAULT_CLEAR = 1
View Source
const EVENT_MODE_DEFAULT_SET = 0

Variables

View Source
var RootKey = [16]byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
View Source
var WaitTimeout = errors.New("timeout")

Functions

This section is empty.

Types

type BinaryClientProtocol

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

func NewBinaryClientProtocol

func NewBinaryClientProtocol(stream *Stream) *BinaryClientProtocol

func (*BinaryClientProtocol) Close

func (self *BinaryClientProtocol) Close() error

func (*BinaryClientProtocol) GetStream

func (self *BinaryClientProtocol) GetStream() *Stream

func (*BinaryClientProtocol) LocalAddr

func (self *BinaryClientProtocol) LocalAddr() net.Addr

func (*BinaryClientProtocol) Read

func (*BinaryClientProtocol) ReadCommand

func (self *BinaryClientProtocol) ReadCommand() (protocol.CommandDecode, error)

func (*BinaryClientProtocol) RemoteAddr

func (self *BinaryClientProtocol) RemoteAddr() net.Addr

func (*BinaryClientProtocol) Write

func (self *BinaryClientProtocol) Write(command protocol.CommandEncode) error

func (*BinaryClientProtocol) WriteCommand

func (self *BinaryClientProtocol) WriteCommand(command protocol.CommandEncode) error

type Client

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

func NewClient

func NewClient(host string, port uint) *Client

func (*Client) Close

func (self *Client) Close() error

func (*Client) CloseSubscribe

func (self *Client) CloseSubscribe(s ISubscriber) error

func (*Client) Event

func (self *Client) Event(eventKey [16]byte, timeout uint32, expried uint32, defaultSeted bool) *Event

func (*Client) ExecuteCommand

func (self *Client) ExecuteCommand(command protocol.ICommand, timeout int) (protocol.ICommand, error)

func (*Client) GenRequestId

func (self *Client) GenRequestId() [16]byte

func (*Client) GetDefaultExpriedFlag

func (self *Client) GetDefaultExpriedFlag() uint16

func (*Client) GetDefaultTimeoutFlag

func (self *Client) GetDefaultTimeoutFlag() uint16

func (*Client) GroupEvent

func (self *Client) GroupEvent(groupKey [16]byte, clientId uint64, versionId uint64, timeout uint32, expried uint32) *GroupEvent

func (*Client) Lock

func (self *Client) Lock(lockKey [16]byte, timeout uint32, expried uint32) *Lock

func (*Client) MaxConcurrentFlow

func (self *Client) MaxConcurrentFlow(flowKey [16]byte, count uint16, timeout uint32, expried uint32) *MaxConcurrentFlow

func (*Client) Open

func (self *Client) Open() error

func (*Client) RLock

func (self *Client) RLock(lockKey [16]byte, timeout uint32, expried uint32) *RLock

func (*Client) RWLock

func (self *Client) RWLock(lockKey [16]byte, timeout uint32, expried uint32) *RWLock

func (*Client) SelectDB

func (self *Client) SelectDB(dbId uint8) *Database

func (*Client) Semaphore

func (self *Client) Semaphore(semaphoreKey [16]byte, timeout uint32, expried uint32, count uint16) *Semaphore

func (*Client) SendCommand

func (self *Client) SendCommand(command protocol.ICommand) error

func (*Client) SetDefaultExpriedFlag

func (self *Client) SetDefaultExpriedFlag(expriedFlag uint16)

func (*Client) SetDefaultTimeoutFlag

func (self *Client) SetDefaultTimeoutFlag(timeoutFlag uint16)

func (*Client) State

func (self *Client) State(dbId uint8) *protocol.StateResultCommand

func (*Client) Subscribe

func (self *Client) Subscribe(expried uint32, maxSize uint32) (ISubscriber, error)

func (*Client) SubscribeMask

func (self *Client) SubscribeMask(lockKeyMask [16]byte, expried uint32, maxSize uint32) (ISubscriber, error)

func (*Client) TokenBucketFlow

func (self *Client) TokenBucketFlow(flowKey [16]byte, count uint16, timeout uint32, period float64) *TokenBucketFlow

func (*Client) TreeLock

func (self *Client) TreeLock(lockKey [16]byte, parentKey [16]byte, timeout uint32, expried uint32) *TreeLock

func (*Client) Unavailable

func (self *Client) Unavailable() chan bool

func (*Client) UpdateSubscribe

func (self *Client) UpdateSubscribe(s ISubscriber) error

type ClientProtocol

type ClientProtocol interface {
	Close() error
	Read() (protocol.CommandDecode, error)
	Write(protocol.CommandEncode) error
	ReadCommand() (protocol.CommandDecode, error)
	WriteCommand(protocol.CommandEncode) error
	GetStream() *Stream
	RemoteAddr() net.Addr
	LocalAddr() net.Addr
}

type Database

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

func NewDatabase

func NewDatabase(dbId uint8, client IClient) *Database

func (*Database) Close

func (self *Database) Close() error

func (*Database) Event

func (self *Database) Event(eventKey [16]byte, timeout uint32, expried uint32, defaultSeted bool) *Event

func (*Database) GenLockId

func (self *Database) GenLockId() [16]byte

func (*Database) GenRequestId

func (self *Database) GenRequestId() [16]byte

func (*Database) GetDefaultExpriedFlag

func (self *Database) GetDefaultExpriedFlag() uint16

func (*Database) GetDefaultTimeoutFlag

func (self *Database) GetDefaultTimeoutFlag() uint16

func (*Database) GroupEvent

func (self *Database) GroupEvent(groupKey [16]byte, clientId uint64, versionId uint64, timeout uint32, expried uint32) *GroupEvent

func (*Database) ListLockLockeds

func (self *Database) ListLockLockeds(lockKey [16]byte, timeout int) (*protobuf.LockDBListLockedResponse, error)

func (*Database) ListLockWaits

func (self *Database) ListLockWaits(lockKey [16]byte, timeout int) (*protobuf.LockDBListWaitResponse, error)

func (*Database) ListLocks

func (self *Database) ListLocks(timeout int) (*protobuf.LockDBListLockResponse, error)

func (*Database) Lock

func (self *Database) Lock(lockKey [16]byte, timeout uint32, expried uint32) *Lock

func (*Database) MaxConcurrentFlow

func (self *Database) MaxConcurrentFlow(flowKey [16]byte, count uint16, timeout uint32, expried uint32) *MaxConcurrentFlow

func (*Database) RLock

func (self *Database) RLock(lockKey [16]byte, timeout uint32, expried uint32) *RLock

func (*Database) RWLock

func (self *Database) RWLock(lockKey [16]byte, timeout uint32, expried uint32) *RWLock

func (*Database) Semaphore

func (self *Database) Semaphore(semaphoreKey [16]byte, timeout uint32, expried uint32, count uint16) *Semaphore

func (*Database) SetDefaultExpriedFlag

func (self *Database) SetDefaultExpriedFlag(expriedFlag uint16)

func (*Database) SetDefaultTimeoutFlag

func (self *Database) SetDefaultTimeoutFlag(timeoutFlag uint16)

func (*Database) State

func (self *Database) State() *protocol.StateResultCommand

func (*Database) TokenBucketFlow

func (self *Database) TokenBucketFlow(flowKey [16]byte, count uint16, timeout uint32, period float64) *TokenBucketFlow

func (*Database) TreeLock

func (self *Database) TreeLock(lockKey [16]byte, parentKey [16]byte, timeout uint32, expried uint32) *TreeLock

type Event

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

func NewDefaultClearEvent

func NewDefaultClearEvent(db *Database, eventKey [16]byte, timeout uint32, expried uint32) *Event

func NewDefaultSetEvent

func NewDefaultSetEvent(db *Database, eventKey [16]byte, timeout uint32, expried uint32) *Event

func NewEvent

func NewEvent(db *Database, eventKey [16]byte, timeout uint32, expried uint32) *Event

func (*Event) Clear

func (self *Event) Clear() (*protocol.LockResultCommand, error)

func (*Event) ClearWithUnsetData

func (self *Event) ClearWithUnsetData() (*protocol.LockResultCommand, error)

func (*Event) GetEventKey

func (self *Event) GetEventKey() [16]byte

func (*Event) GetExpried

func (self *Event) GetExpried() uint32

func (*Event) GetTimeout

func (self *Event) GetTimeout() uint32

func (*Event) IsSet

func (self *Event) IsSet() (bool, error)

func (*Event) Mode

func (self *Event) Mode() uint8

func (*Event) Set

func (self *Event) Set() (*protocol.LockResultCommand, error)

func (*Event) SetWithData

func (self *Event) SetWithData(data *protocol.LockCommandData) (*protocol.LockResultCommand, error)

func (*Event) Wait

func (self *Event) Wait(timeout uint32) (*protocol.LockResultCommand, error)

func (*Event) WaitAndTimeoutRetryClear

func (self *Event) WaitAndTimeoutRetryClear(timeout uint32) (*protocol.LockResultCommand, error)

type GroupEvent

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

func NewGroupEvent

func NewGroupEvent(db *Database, groupKey [16]byte, clientId uint64, versionId uint64, timeout uint32, expried uint32) *GroupEvent

func (*GroupEvent) Clear

func (self *GroupEvent) Clear() (*protocol.LockResultCommand, error)

func (*GroupEvent) ClearWithUnsetData

func (self *GroupEvent) ClearWithUnsetData() (*protocol.LockResultCommand, error)

func (*GroupEvent) GetClientId

func (self *GroupEvent) GetClientId() uint64

func (*GroupEvent) GetExpried

func (self *GroupEvent) GetExpried() uint32

func (*GroupEvent) GetGroupKey

func (self *GroupEvent) GetGroupKey() [16]byte

func (*GroupEvent) GetTimeout

func (self *GroupEvent) GetTimeout() uint32

func (*GroupEvent) GetVersionId

func (self *GroupEvent) GetVersionId() uint64

func (*GroupEvent) IsSet

func (self *GroupEvent) IsSet() (bool, error)

func (*GroupEvent) Set

func (self *GroupEvent) Set() (*protocol.LockResultCommand, error)

func (*GroupEvent) SetWithData

func (self *GroupEvent) SetWithData(data *protocol.LockCommandData) (*protocol.LockResultCommand, error)

func (*GroupEvent) Wait

func (self *GroupEvent) Wait(timeout uint32) (*protocol.LockResultCommand, error)

func (*GroupEvent) WaitAndTimeoutRetryClear

func (self *GroupEvent) WaitAndTimeoutRetryClear(timeout uint32) (*protocol.LockResultCommand, error)

func (*GroupEvent) Wakeup

func (self *GroupEvent) Wakeup() (*protocol.LockResultCommand, error)

func (*GroupEvent) WakeupWithData

func (self *GroupEvent) WakeupWithData(data *protocol.LockCommandData) (*protocol.LockResultCommand, error)

type IClient

type IClient interface {
	Open() error
	Close() error
	SelectDB(dbId uint8) *Database
	ExecuteCommand(command protocol.ICommand, timeout int) (protocol.ICommand, error)
	SendCommand(command protocol.ICommand) error
	Lock(lockKey [16]byte, timeout uint32, expried uint32) *Lock
	Event(eventKey [16]byte, timeout uint32, expried uint32, defaultSeted bool) *Event
	GroupEvent(groupKey [16]byte, clientId uint64, versionId uint64, timeout uint32, expried uint32) *GroupEvent
	Semaphore(semaphoreKey [16]byte, timeout uint32, expried uint32, count uint16) *Semaphore
	RWLock(lockKey [16]byte, timeout uint32, expried uint32) *RWLock
	RLock(lockKey [16]byte, timeout uint32, expried uint32) *RLock
	MaxConcurrentFlow(flowKey [16]byte, count uint16, timeout uint32, expried uint32) *MaxConcurrentFlow
	TokenBucketFlow(flowKey [16]byte, count uint16, timeout uint32, period float64) *TokenBucketFlow
	TreeLock(lockKey [16]byte, parentKey [16]byte, timeout uint32, expried uint32) *TreeLock
	Subscribe(expried uint32, maxSize uint32) (ISubscriber, error)
	SubscribeMask(lockKeyMask [16]byte, expried uint32, maxSize uint32) (ISubscriber, error)
	CloseSubscribe(subscriber ISubscriber) error
	UpdateSubscribe(subscriber ISubscriber) error
	GenRequestId() [16]byte
	Unavailable() chan bool
	SetDefaultTimeoutFlag(timeoutFlag uint16)
	SetDefaultExpriedFlag(expriedFlag uint16)
	GetDefaultTimeoutFlag() uint16
	GetDefaultExpriedFlag() uint16
}

type ISubscriber

type ISubscriber interface {
	Close() error
	Wait() (*protocol.LockResultCommand, error)
	Push(resultCommand *protocol.LockResultCommand) error
}

type Lock

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

func NewLock

func NewLock(db *Database, lockKey [16]byte, timeout uint32, expried uint32) *Lock

func (*Lock) CancelWait

func (self *Lock) CancelWait() (*protocol.LockResultCommand, error)

func (*Lock) GetCount

func (self *Lock) GetCount() uint16

func (*Lock) GetExpried

func (self *Lock) GetExpried() uint16

func (*Lock) GetExpriedFlag

func (self *Lock) GetExpriedFlag() uint16

func (*Lock) GetLockId

func (self *Lock) GetLockId() [16]byte

func (*Lock) GetLockKey

func (self *Lock) GetLockKey() [16]byte

func (*Lock) GetRcount

func (self *Lock) GetRcount() uint8

func (*Lock) GetTimeout

func (self *Lock) GetTimeout() uint16

func (*Lock) GetTimeoutFlag

func (self *Lock) GetTimeoutFlag() uint16

func (*Lock) Lock

func (self *Lock) Lock() (*protocol.LockResultCommand, error)

func (*Lock) LockShow

func (self *Lock) LockShow() (*protocol.LockResultCommand, error)

func (*Lock) LockUpdate

func (self *Lock) LockUpdate() (*protocol.LockResultCommand, error)

func (*Lock) LockUpdateWithData

func (self *Lock) LockUpdateWithData(data *protocol.LockCommandData) (*protocol.LockResultCommand, error)

func (*Lock) LockWithData

func (self *Lock) LockWithData(data *protocol.LockCommandData) (*protocol.LockResultCommand, error)

func (*Lock) SendLock

func (self *Lock) SendLock() error

func (*Lock) SendLockWithData

func (self *Lock) SendLockWithData(data *protocol.LockCommandData) error

func (*Lock) SendUnlock

func (self *Lock) SendUnlock() error

func (*Lock) SendUnlockWithData

func (self *Lock) SendUnlockWithData(data *protocol.LockCommandData) error

func (*Lock) SetCount

func (self *Lock) SetCount(count uint16) uint16

func (*Lock) SetExpriedFlag

func (self *Lock) SetExpriedFlag(flag uint16) uint16

func (*Lock) SetRcount

func (self *Lock) SetRcount(rcount uint8) uint8

func (*Lock) SetTimeoutFlag

func (self *Lock) SetTimeoutFlag(flag uint16) uint16

func (*Lock) Unlock

func (self *Lock) Unlock() (*protocol.LockResultCommand, error)

func (*Lock) UnlockHead

func (self *Lock) UnlockHead() (*protocol.LockResultCommand, error)

func (*Lock) UnlockHeadRetoLockWait

func (self *Lock) UnlockHeadRetoLockWait() (*protocol.LockResultCommand, error)

func (*Lock) UnlockHeadRetoLockWaitWithData

func (self *Lock) UnlockHeadRetoLockWaitWithData(data *protocol.LockCommandData) (*protocol.LockResultCommand, error)

func (*Lock) UnlockHeadWithData

func (self *Lock) UnlockHeadWithData(data *protocol.LockCommandData) (*protocol.LockResultCommand, error)

func (*Lock) UnlockRetoLockWait

func (self *Lock) UnlockRetoLockWait() (*protocol.LockResultCommand, error)

func (*Lock) UnlockRetoLockWaitWithData

func (self *Lock) UnlockRetoLockWaitWithData(data *protocol.LockCommandData) (*protocol.LockResultCommand, error)

func (*Lock) UnlockWithData

func (self *Lock) UnlockWithData(data *protocol.LockCommandData) (*protocol.LockResultCommand, error)

type LockError

type LockError struct {
	Result        uint8
	CommandResult *protocol.LockResultCommand
	Err           error
}

func (*LockError) Error

func (self *LockError) Error() string

func (*LockError) GetBytesData

func (self *LockError) GetBytesData() []byte

func (*LockError) GetLockData

func (self *LockError) GetLockData() *protocol.LockResultCommandData

func (*LockError) GetStringData

func (self *LockError) GetStringData() string

type MaxConcurrentFlow

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

func NewMaxConcurrentFlow

func NewMaxConcurrentFlow(db *Database, flowKey [16]byte, count uint16, timeout uint32, expried uint32) *MaxConcurrentFlow

func (*MaxConcurrentFlow) Acquire

func (self *MaxConcurrentFlow) Acquire() (*protocol.LockResultCommand, error)

func (*MaxConcurrentFlow) GetExpriedFlag

func (self *MaxConcurrentFlow) GetExpriedFlag() uint16

func (*MaxConcurrentFlow) GetTimeoutFlag

func (self *MaxConcurrentFlow) GetTimeoutFlag() uint16

func (*MaxConcurrentFlow) Release

func (self *MaxConcurrentFlow) Release() (*protocol.LockResultCommand, error)

func (*MaxConcurrentFlow) SetExpriedFlag

func (self *MaxConcurrentFlow) SetExpriedFlag(flag uint16) uint16

func (*MaxConcurrentFlow) SetTimeoutFlag

func (self *MaxConcurrentFlow) SetTimeoutFlag(flag uint16) uint16

type RLock

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

func NewRLock

func NewRLock(db *Database, lockKey [16]byte, timeout uint32, expried uint32) *RLock

func (*RLock) GetExpried

func (self *RLock) GetExpried() uint32

func (*RLock) GetLockKey

func (self *RLock) GetLockKey() [16]byte

func (*RLock) GetTimeout

func (self *RLock) GetTimeout() uint32

func (*RLock) Lock

func (self *RLock) Lock() (*protocol.LockResultCommand, error)

func (*RLock) LockWithData

func (self *RLock) LockWithData(data *protocol.LockCommandData) (*protocol.LockResultCommand, error)

func (*RLock) Unlock

func (self *RLock) Unlock() (*protocol.LockResultCommand, error)

func (*RLock) UnlockWithData

func (self *RLock) UnlockWithData(data *protocol.LockCommandData) (*protocol.LockResultCommand, error)

type RWLock

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

func NewRWLock

func NewRWLock(db *Database, lockKey [16]byte, timeout uint32, expried uint32) *RWLock

func (*RWLock) GetExpried

func (self *RWLock) GetExpried() uint32

func (*RWLock) GetLockKey

func (self *RWLock) GetLockKey() [16]byte

func (*RWLock) GetTimeout

func (self *RWLock) GetTimeout() uint32

func (*RWLock) Lock

func (self *RWLock) Lock() (*protocol.LockResultCommand, error)

func (*RWLock) LockWithData

func (self *RWLock) LockWithData(data *protocol.LockCommandData) (*protocol.LockResultCommand, error)

func (*RWLock) RLock

func (self *RWLock) RLock() (*protocol.LockResultCommand, error)

func (*RWLock) RLockWithData

func (self *RWLock) RLockWithData(data *protocol.LockCommandData) (*protocol.LockResultCommand, error)

func (*RWLock) RUnlock

func (self *RWLock) RUnlock() (*protocol.LockResultCommand, error)

func (*RWLock) RUnlockWithData

func (self *RWLock) RUnlockWithData(data *protocol.LockCommandData) (*protocol.LockResultCommand, error)

func (*RWLock) Unlock

func (self *RWLock) Unlock() (*protocol.LockResultCommand, error)

func (*RWLock) UnlockWithData

func (self *RWLock) UnlockWithData(data *protocol.LockCommandData) (*protocol.LockResultCommand, error)

type ReplsetClient

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

func NewReplsetClient

func NewReplsetClient(hosts []string) *ReplsetClient

func (*ReplsetClient) Close

func (self *ReplsetClient) Close() error

func (*ReplsetClient) CloseSubscribe

func (self *ReplsetClient) CloseSubscribe(s ISubscriber) error

func (*ReplsetClient) Event

func (self *ReplsetClient) Event(eventKey [16]byte, timeout uint32, expried uint32, defaultSeted bool) *Event

func (*ReplsetClient) ExecuteCommand

func (self *ReplsetClient) ExecuteCommand(command protocol.ICommand, timeout int) (protocol.ICommand, error)

func (*ReplsetClient) GenRequestId

func (self *ReplsetClient) GenRequestId() [16]byte

func (*ReplsetClient) GetClient

func (self *ReplsetClient) GetClient() *Client

func (*ReplsetClient) GetDefaultExpriedFlag

func (self *ReplsetClient) GetDefaultExpriedFlag() uint16

func (*ReplsetClient) GetDefaultTimeoutFlag

func (self *ReplsetClient) GetDefaultTimeoutFlag() uint16

func (*ReplsetClient) GroupEvent

func (self *ReplsetClient) GroupEvent(groupKey [16]byte, clientId uint64, versionId uint64, timeout uint32, expried uint32) *GroupEvent

func (*ReplsetClient) Lock

func (self *ReplsetClient) Lock(lockKey [16]byte, timeout uint32, expried uint32) *Lock

func (*ReplsetClient) MaxConcurrentFlow

func (self *ReplsetClient) MaxConcurrentFlow(flowKey [16]byte, count uint16, timeout uint32, expried uint32) *MaxConcurrentFlow

func (*ReplsetClient) Open

func (self *ReplsetClient) Open() error

func (*ReplsetClient) RLock

func (self *ReplsetClient) RLock(lockKey [16]byte, timeout uint32, expried uint32) *RLock

func (*ReplsetClient) RWLock

func (self *ReplsetClient) RWLock(lockKey [16]byte, timeout uint32, expried uint32) *RWLock

func (*ReplsetClient) SelectDB

func (self *ReplsetClient) SelectDB(dbId uint8) *Database

func (*ReplsetClient) Semaphore

func (self *ReplsetClient) Semaphore(semaphoreKey [16]byte, timeout uint32, expried uint32, count uint16) *Semaphore

func (*ReplsetClient) SendCommand

func (self *ReplsetClient) SendCommand(command protocol.ICommand) error

func (*ReplsetClient) SetDefaultExpriedFlag

func (self *ReplsetClient) SetDefaultExpriedFlag(expriedFlag uint16)

func (*ReplsetClient) SetDefaultTimeoutFlag

func (self *ReplsetClient) SetDefaultTimeoutFlag(timeoutFlag uint16)

func (*ReplsetClient) Subscribe

func (self *ReplsetClient) Subscribe(expried uint32, maxSize uint32) (ISubscriber, error)

func (*ReplsetClient) SubscribeMask

func (self *ReplsetClient) SubscribeMask(lockKeyMask [16]byte, expried uint32, maxSize uint32) (ISubscriber, error)

func (*ReplsetClient) TokenBucketFlow

func (self *ReplsetClient) TokenBucketFlow(flowKey [16]byte, count uint16, timeout uint32, period float64) *TokenBucketFlow

func (*ReplsetClient) TreeLock

func (self *ReplsetClient) TreeLock(lockKey [16]byte, parentKey [16]byte, timeout uint32, expried uint32) *TreeLock

func (*ReplsetClient) Unavailable

func (self *ReplsetClient) Unavailable() chan bool

func (*ReplsetClient) UpdateSubscribe

func (self *ReplsetClient) UpdateSubscribe(s ISubscriber) error

type ReplsetSubscriber

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

func NewReplsetSubscriber

func NewReplsetSubscriber(client *ReplsetClient, lockKeyMask [16]byte, expried uint32, maxSize uint32) *ReplsetSubscriber

func (*ReplsetSubscriber) Close

func (self *ReplsetSubscriber) Close() error

func (*ReplsetSubscriber) Push

func (self *ReplsetSubscriber) Push(resultCommand *protocol.LockResultCommand) error

func (*ReplsetSubscriber) Wait

type Semaphore

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

func NewSemaphore

func NewSemaphore(db *Database, semaphoreKey [16]byte, timeout uint32, expried uint32, count uint16) *Semaphore

func (*Semaphore) Acquire

func (self *Semaphore) Acquire() (*protocol.LockResultCommand, error)

func (*Semaphore) Count

func (self *Semaphore) Count() (int, error)

func (*Semaphore) GetExpried

func (self *Semaphore) GetExpried() uint32

func (*Semaphore) GetSemaphoreKey

func (self *Semaphore) GetSemaphoreKey() [16]byte

func (*Semaphore) GetTimeout

func (self *Semaphore) GetTimeout() uint32

func (*Semaphore) Release

func (self *Semaphore) Release() (*protocol.LockResultCommand, error)

func (*Semaphore) ReleaseAll

func (self *Semaphore) ReleaseAll() error

func (*Semaphore) ReleaseN

func (self *Semaphore) ReleaseN(n int) (int, error)

type Stream

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

func NewStream

func NewStream(conn net.Conn) *Stream

func (*Stream) Close

func (self *Stream) Close() error

func (*Stream) LocalAddr

func (self *Stream) LocalAddr() net.Addr

func (*Stream) Read

func (self *Stream) Read(buf []byte) (int, error)

func (*Stream) ReadBytes

func (self *Stream) ReadBytes(buf []byte) (int, error)

func (*Stream) ReadBytesFrame

func (self *Stream) ReadBytesFrame() ([]byte, error)

func (*Stream) ReadBytesSize

func (self *Stream) ReadBytesSize(size int) ([]byte, error)

func (*Stream) ReadFromConn

func (self *Stream) ReadFromConn(buf []byte) (int, error)

func (*Stream) ReadSize

func (self *Stream) ReadSize(size int) ([]byte, error)

func (*Stream) RemoteAddr

func (self *Stream) RemoteAddr() net.Addr

func (*Stream) SetDeadline

func (self *Stream) SetDeadline(t time.Time) error

func (*Stream) SetReadDeadline

func (self *Stream) SetReadDeadline(t time.Time) error

func (*Stream) SetWriteDeadline

func (self *Stream) SetWriteDeadline(t time.Time) error

func (*Stream) Write

func (self *Stream) Write(b []byte) (int, error)

func (*Stream) WriteBytes

func (self *Stream) WriteBytes(b []byte) error

type StreamReaderBuffer

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

func NewStreamReaderBuffer

func NewStreamReaderBuffer(size int) *StreamReaderBuffer

func (*StreamReaderBuffer) GetCapSize

func (self *StreamReaderBuffer) GetCapSize() int

func (*StreamReaderBuffer) GetSize

func (self *StreamReaderBuffer) GetSize() int

func (*StreamReaderBuffer) Read

func (self *StreamReaderBuffer) Read(buf []byte) int

func (*StreamReaderBuffer) ReadBytesSize

func (self *StreamReaderBuffer) ReadBytesSize(size int) []byte

func (*StreamReaderBuffer) ReadFromConn

func (self *StreamReaderBuffer) ReadFromConn(conn net.Conn, size int) (int, error)

type Subscriber

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

func NewSubscriber

func NewSubscriber(client *Client, clientId uint32, subscribeId uint32, lockKeyMask [16]byte, expried uint32, maxSize uint32) *Subscriber

func (*Subscriber) Close

func (self *Subscriber) Close() error

func (*Subscriber) Push

func (self *Subscriber) Push(resultCommand *protocol.LockResultCommand) error

func (*Subscriber) Wait

func (self *Subscriber) Wait() (*protocol.LockResultCommand, error)

type TextClientProtocol

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

func NewTextClientProtocol

func NewTextClientProtocol(stream *Stream) *TextClientProtocol

func (*TextClientProtocol) ArgsToLockComandResult

func (self *TextClientProtocol) ArgsToLockComandResult(args []string) (*protocol.LockResultCommand, error)

func (*TextClientProtocol) ArgsToLockComandResultParseId

func (self *TextClientProtocol) ArgsToLockComandResultParseId(argId string, lockId *[16]byte)

func (*TextClientProtocol) Close

func (self *TextClientProtocol) Close() error

func (*TextClientProtocol) GetParser

func (self *TextClientProtocol) GetParser() *protocol.TextParser

func (*TextClientProtocol) GetStream

func (self *TextClientProtocol) GetStream() *Stream

func (*TextClientProtocol) LocalAddr

func (self *TextClientProtocol) LocalAddr() net.Addr

func (*TextClientProtocol) Read

func (*TextClientProtocol) ReadCommand

func (self *TextClientProtocol) ReadCommand() (protocol.CommandDecode, error)

func (*TextClientProtocol) RemoteAddr

func (self *TextClientProtocol) RemoteAddr() net.Addr

func (*TextClientProtocol) Write

func (self *TextClientProtocol) Write(result protocol.CommandEncode) error

func (*TextClientProtocol) WriteCommand

func (self *TextClientProtocol) WriteCommand(result protocol.CommandEncode) error

type TokenBucketFlow

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

func NewTokenBucketFlow

func NewTokenBucketFlow(db *Database, flowKey [16]byte, count uint16, timeout uint32, period float64) *TokenBucketFlow

func (*TokenBucketFlow) Acquire

func (self *TokenBucketFlow) Acquire() (*protocol.LockResultCommand, error)

func (*TokenBucketFlow) GetExpriedFlag

func (self *TokenBucketFlow) GetExpriedFlag() uint16

func (*TokenBucketFlow) GetTimeoutFlag

func (self *TokenBucketFlow) GetTimeoutFlag() uint16

func (*TokenBucketFlow) SetExpriedFlag

func (self *TokenBucketFlow) SetExpriedFlag(flag uint16) uint16

func (*TokenBucketFlow) SetTimeoutFlag

func (self *TokenBucketFlow) SetTimeoutFlag(flag uint16) uint16

type TreeLeafLock

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

func (*TreeLeafLock) GetLockId

func (self *TreeLeafLock) GetLockId() [16]byte

func (*TreeLeafLock) GetLockKey

func (self *TreeLeafLock) GetLockKey() [16]byte

func (*TreeLeafLock) Lock

func (self *TreeLeafLock) Lock() (*protocol.LockResultCommand, error)

func (*TreeLeafLock) Unlock

func (self *TreeLeafLock) Unlock() (*protocol.LockResultCommand, error)

func (*TreeLeafLock) UnlockWithData

func (self *TreeLeafLock) UnlockWithData(data *protocol.LockCommandData) (*protocol.LockResultCommand, error)

type TreeLock

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

func NewTreeLock

func NewTreeLock(db *Database, lockKey [16]byte, parentKey [16]byte, timeout uint32, expried uint32) *TreeLock

func (*TreeLock) GetLockKey

func (self *TreeLock) GetLockKey() [16]byte

func (*TreeLock) GetParentKey

func (self *TreeLock) GetParentKey() [16]byte

func (*TreeLock) LoadChild

func (self *TreeLock) LoadChild(lockKey [16]byte) *TreeLock

func (*TreeLock) LoadLeafLock

func (self *TreeLock) LoadLeafLock(lockId [16]byte) *TreeLeafLock

func (*TreeLock) Lock

func (self *TreeLock) Lock() (*protocol.LockResultCommand, error)

func (*TreeLock) NewChild

func (self *TreeLock) NewChild() *TreeLock

func (*TreeLock) NewLeafLock

func (self *TreeLock) NewLeafLock() *TreeLeafLock

func (*TreeLock) Unlock

func (self *TreeLock) Unlock() (*protocol.LockResultCommand, error)

func (*TreeLock) UnlockWithData

func (self *TreeLock) UnlockWithData(data *protocol.LockCommandData) (*protocol.LockResultCommand, error)

func (*TreeLock) Wait

func (self *TreeLock) Wait(timeout uint32) (*protocol.LockResultCommand, error)

Jump to

Keyboard shortcuts

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