lock

package
v0.6.3 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2021 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

Type is the lock primitive type

Variables

View Source
var (
	ErrInvalidLengthLock        = fmt.Errorf("proto: negative length found during unmarshaling")
	ErrIntOverflowLock          = fmt.Errorf("proto: integer overflow")
	ErrUnexpectedEndOfGroupLock = fmt.Errorf("proto: unexpected end of group")
)

Functions

func RegisterPrimitive

func RegisterPrimitive(node *atomix.Node)

RegisterPrimitive registers the primitive on the given node

Types

type IsLockedRequest

type IsLockedRequest struct {
	Index int64 `protobuf:"varint,1,opt,name=index,proto3" json:"index,omitempty"`
}

func (*IsLockedRequest) Descriptor

func (*IsLockedRequest) Descriptor() ([]byte, []int)

func (*IsLockedRequest) GetIndex

func (m *IsLockedRequest) GetIndex() int64

func (*IsLockedRequest) Marshal

func (m *IsLockedRequest) Marshal() (dAtA []byte, err error)

func (*IsLockedRequest) MarshalTo

func (m *IsLockedRequest) MarshalTo(dAtA []byte) (int, error)

func (*IsLockedRequest) MarshalToSizedBuffer

func (m *IsLockedRequest) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*IsLockedRequest) ProtoMessage

func (*IsLockedRequest) ProtoMessage()

func (*IsLockedRequest) Reset

func (m *IsLockedRequest) Reset()

func (*IsLockedRequest) Size

func (m *IsLockedRequest) Size() (n int)

func (*IsLockedRequest) String

func (m *IsLockedRequest) String() string

func (*IsLockedRequest) Unmarshal

func (m *IsLockedRequest) Unmarshal(dAtA []byte) error

func (*IsLockedRequest) XXX_DiscardUnknown

func (m *IsLockedRequest) XXX_DiscardUnknown()

func (*IsLockedRequest) XXX_Marshal

func (m *IsLockedRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*IsLockedRequest) XXX_Merge

func (m *IsLockedRequest) XXX_Merge(src proto.Message)

func (*IsLockedRequest) XXX_Size

func (m *IsLockedRequest) XXX_Size() int

func (*IsLockedRequest) XXX_Unmarshal

func (m *IsLockedRequest) XXX_Unmarshal(b []byte) error

type IsLockedResponse

type IsLockedResponse struct {
	Locked bool `protobuf:"varint,1,opt,name=locked,proto3" json:"locked,omitempty"`
}

func (*IsLockedResponse) Descriptor

func (*IsLockedResponse) Descriptor() ([]byte, []int)

func (*IsLockedResponse) GetLocked

func (m *IsLockedResponse) GetLocked() bool

func (*IsLockedResponse) Marshal

func (m *IsLockedResponse) Marshal() (dAtA []byte, err error)

func (*IsLockedResponse) MarshalTo

func (m *IsLockedResponse) MarshalTo(dAtA []byte) (int, error)

func (*IsLockedResponse) MarshalToSizedBuffer

func (m *IsLockedResponse) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*IsLockedResponse) ProtoMessage

func (*IsLockedResponse) ProtoMessage()

func (*IsLockedResponse) Reset

func (m *IsLockedResponse) Reset()

func (*IsLockedResponse) Size

func (m *IsLockedResponse) Size() (n int)

func (*IsLockedResponse) String

func (m *IsLockedResponse) String() string

func (*IsLockedResponse) Unmarshal

func (m *IsLockedResponse) Unmarshal(dAtA []byte) error

func (*IsLockedResponse) XXX_DiscardUnknown

func (m *IsLockedResponse) XXX_DiscardUnknown()

func (*IsLockedResponse) XXX_Marshal

func (m *IsLockedResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*IsLockedResponse) XXX_Merge

func (m *IsLockedResponse) XXX_Merge(src proto.Message)

func (*IsLockedResponse) XXX_Size

func (m *IsLockedResponse) XXX_Size() int

func (*IsLockedResponse) XXX_Unmarshal

func (m *IsLockedResponse) XXX_Unmarshal(b []byte) error

type LockCall

type LockCall struct {
	Index     int64      `protobuf:"varint,1,opt,name=index,proto3" json:"index,omitempty"`
	SessionId int64      `protobuf:"varint,2,opt,name=session_id,json=sessionId,proto3" json:"session_id,omitempty"`
	Expire    *time.Time `protobuf:"bytes,3,opt,name=expire,proto3,stdtime" json:"expire,omitempty"`
}

Lock call

func (*LockCall) Descriptor

func (*LockCall) Descriptor() ([]byte, []int)

func (*LockCall) GetExpire

func (m *LockCall) GetExpire() *time.Time

func (*LockCall) GetIndex

func (m *LockCall) GetIndex() int64

func (*LockCall) GetSessionId

func (m *LockCall) GetSessionId() int64

func (*LockCall) Marshal

func (m *LockCall) Marshal() (dAtA []byte, err error)

func (*LockCall) MarshalTo

func (m *LockCall) MarshalTo(dAtA []byte) (int, error)

func (*LockCall) MarshalToSizedBuffer

func (m *LockCall) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*LockCall) ProtoMessage

func (*LockCall) ProtoMessage()

func (*LockCall) Reset

func (m *LockCall) Reset()

func (*LockCall) Size

func (m *LockCall) Size() (n int)

func (*LockCall) String

func (m *LockCall) String() string

func (*LockCall) Unmarshal

func (m *LockCall) Unmarshal(dAtA []byte) error

func (*LockCall) XXX_DiscardUnknown

func (m *LockCall) XXX_DiscardUnknown()

func (*LockCall) XXX_Marshal

func (m *LockCall) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*LockCall) XXX_Merge

func (m *LockCall) XXX_Merge(src proto.Message)

func (*LockCall) XXX_Size

func (m *LockCall) XXX_Size() int

func (*LockCall) XXX_Unmarshal

func (m *LockCall) XXX_Unmarshal(b []byte) error

type LockRequest

type LockRequest struct {
	Timeout *time.Duration `protobuf:"bytes,1,opt,name=timeout,proto3,stdduration" json:"timeout,omitempty"`
}

func (*LockRequest) Descriptor

func (*LockRequest) Descriptor() ([]byte, []int)

func (*LockRequest) GetTimeout

func (m *LockRequest) GetTimeout() *time.Duration

func (*LockRequest) Marshal

func (m *LockRequest) Marshal() (dAtA []byte, err error)

func (*LockRequest) MarshalTo

func (m *LockRequest) MarshalTo(dAtA []byte) (int, error)

func (*LockRequest) MarshalToSizedBuffer

func (m *LockRequest) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*LockRequest) ProtoMessage

func (*LockRequest) ProtoMessage()

func (*LockRequest) Reset

func (m *LockRequest) Reset()

func (*LockRequest) Size

func (m *LockRequest) Size() (n int)

func (*LockRequest) String

func (m *LockRequest) String() string

func (*LockRequest) Unmarshal

func (m *LockRequest) Unmarshal(dAtA []byte) error

func (*LockRequest) XXX_DiscardUnknown

func (m *LockRequest) XXX_DiscardUnknown()

func (*LockRequest) XXX_Marshal

func (m *LockRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*LockRequest) XXX_Merge

func (m *LockRequest) XXX_Merge(src proto.Message)

func (*LockRequest) XXX_Size

func (m *LockRequest) XXX_Size() int

func (*LockRequest) XXX_Unmarshal

func (m *LockRequest) XXX_Unmarshal(b []byte) error

type LockResponse

type LockResponse struct {
	Index    int64 `protobuf:"varint,1,opt,name=index,proto3" json:"index,omitempty"`
	Acquired bool  `protobuf:"varint,2,opt,name=acquired,proto3" json:"acquired,omitempty"`
}

func (*LockResponse) Descriptor

func (*LockResponse) Descriptor() ([]byte, []int)

func (*LockResponse) GetAcquired

func (m *LockResponse) GetAcquired() bool

func (*LockResponse) GetIndex

func (m *LockResponse) GetIndex() int64

func (*LockResponse) Marshal

func (m *LockResponse) Marshal() (dAtA []byte, err error)

func (*LockResponse) MarshalTo

func (m *LockResponse) MarshalTo(dAtA []byte) (int, error)

func (*LockResponse) MarshalToSizedBuffer

func (m *LockResponse) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*LockResponse) ProtoMessage

func (*LockResponse) ProtoMessage()

func (*LockResponse) Reset

func (m *LockResponse) Reset()

func (*LockResponse) Size

func (m *LockResponse) Size() (n int)

func (*LockResponse) String

func (m *LockResponse) String() string

func (*LockResponse) Unmarshal

func (m *LockResponse) Unmarshal(dAtA []byte) error

func (*LockResponse) XXX_DiscardUnknown

func (m *LockResponse) XXX_DiscardUnknown()

func (*LockResponse) XXX_Marshal

func (m *LockResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*LockResponse) XXX_Merge

func (m *LockResponse) XXX_Merge(src proto.Message)

func (*LockResponse) XXX_Size

func (m *LockResponse) XXX_Size() int

func (*LockResponse) XXX_Unmarshal

func (m *LockResponse) XXX_Unmarshal(b []byte) error

type LockSnapshot

type LockSnapshot struct {
	Lock  *LockCall   `protobuf:"bytes,1,opt,name=lock,proto3" json:"lock,omitempty"`
	Queue []*LockCall `protobuf:"bytes,2,rep,name=queue,proto3" json:"queue,omitempty"`
}

Lock snapshot

func (*LockSnapshot) Descriptor

func (*LockSnapshot) Descriptor() ([]byte, []int)

func (*LockSnapshot) GetLock

func (m *LockSnapshot) GetLock() *LockCall

func (*LockSnapshot) GetQueue

func (m *LockSnapshot) GetQueue() []*LockCall

func (*LockSnapshot) Marshal

func (m *LockSnapshot) Marshal() (dAtA []byte, err error)

func (*LockSnapshot) MarshalTo

func (m *LockSnapshot) MarshalTo(dAtA []byte) (int, error)

func (*LockSnapshot) MarshalToSizedBuffer

func (m *LockSnapshot) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*LockSnapshot) ProtoMessage

func (*LockSnapshot) ProtoMessage()

func (*LockSnapshot) Reset

func (m *LockSnapshot) Reset()

func (*LockSnapshot) Size

func (m *LockSnapshot) Size() (n int)

func (*LockSnapshot) String

func (m *LockSnapshot) String() string

func (*LockSnapshot) Unmarshal

func (m *LockSnapshot) Unmarshal(dAtA []byte) error

func (*LockSnapshot) XXX_DiscardUnknown

func (m *LockSnapshot) XXX_DiscardUnknown()

func (*LockSnapshot) XXX_Marshal

func (m *LockSnapshot) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*LockSnapshot) XXX_Merge

func (m *LockSnapshot) XXX_Merge(src proto.Message)

func (*LockSnapshot) XXX_Size

func (m *LockSnapshot) XXX_Size() int

func (*LockSnapshot) XXX_Unmarshal

func (m *LockSnapshot) XXX_Unmarshal(b []byte) error

type Primitive

type Primitive struct{}

Primitive is the counter primitive

func (*Primitive) NewService

func (p *Primitive) NewService(scheduler primitive.Scheduler, context primitive.ServiceContext) primitive.Service

NewService creates a new lock service

func (*Primitive) RegisterServer

func (p *Primitive) RegisterServer(server *grpc.Server, protocol primitive.Protocol)

RegisterServer registers the lock server with the protocol

type Server

type Server struct {
	*primitive.Server
}

Server is an implementation of MapServiceServer for the map primitive

func (*Server) Close

func (s *Server) Close(ctx context.Context, request *api.CloseRequest) (*api.CloseResponse, error)

Close closes a session

func (*Server) Create

func (s *Server) Create(ctx context.Context, request *api.CreateRequest) (*api.CreateResponse, error)

Create opens a new session

func (*Server) IsLocked

func (s *Server) IsLocked(ctx context.Context, request *api.IsLockedRequest) (*api.IsLockedResponse, error)

IsLocked checks whether the lock is held by any session

func (*Server) Lock

func (s *Server) Lock(ctx context.Context, request *api.LockRequest) (*api.LockResponse, error)

Lock acquires a lock

func (*Server) Unlock

func (s *Server) Unlock(ctx context.Context, request *api.UnlockRequest) (*api.UnlockResponse, error)

Unlock releases the lock

type Service

type Service struct {
	primitive.Service
	// contains filtered or unexported fields
}

Service is a state machine for a list primitive

func (*Service) Backup

func (l *Service) Backup(writer io.Writer) error

Backup takes a snapshot of the service

func (*Service) IsLocked

func (l *Service) IsLocked(bytes []byte) ([]byte, error)

IsLocked checks whether the lock is held by a specific session

func (*Service) Lock

func (l *Service) Lock(bytes []byte, stream primitive.Stream)

Lock attempts to acquire the lock for the current session

func (*Service) Restore

func (l *Service) Restore(reader io.Reader) error

Restore restores the service from a snapshot

func (*Service) SessionClosed

func (l *Service) SessionClosed(session primitive.Session)

SessionClosed releases the lock when the owning session is closed

func (*Service) SessionExpired

func (l *Service) SessionExpired(session primitive.Session)

SessionExpired releases the lock when the owning session expires

func (*Service) Unlock

func (l *Service) Unlock(bytes []byte) ([]byte, error)

Unlock releases the current lock

type UnlockRequest

type UnlockRequest struct {
	Index int64 `protobuf:"varint,1,opt,name=index,proto3" json:"index,omitempty"`
}

func (*UnlockRequest) Descriptor

func (*UnlockRequest) Descriptor() ([]byte, []int)

func (*UnlockRequest) GetIndex

func (m *UnlockRequest) GetIndex() int64

func (*UnlockRequest) Marshal

func (m *UnlockRequest) Marshal() (dAtA []byte, err error)

func (*UnlockRequest) MarshalTo

func (m *UnlockRequest) MarshalTo(dAtA []byte) (int, error)

func (*UnlockRequest) MarshalToSizedBuffer

func (m *UnlockRequest) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*UnlockRequest) ProtoMessage

func (*UnlockRequest) ProtoMessage()

func (*UnlockRequest) Reset

func (m *UnlockRequest) Reset()

func (*UnlockRequest) Size

func (m *UnlockRequest) Size() (n int)

func (*UnlockRequest) String

func (m *UnlockRequest) String() string

func (*UnlockRequest) Unmarshal

func (m *UnlockRequest) Unmarshal(dAtA []byte) error

func (*UnlockRequest) XXX_DiscardUnknown

func (m *UnlockRequest) XXX_DiscardUnknown()

func (*UnlockRequest) XXX_Marshal

func (m *UnlockRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*UnlockRequest) XXX_Merge

func (m *UnlockRequest) XXX_Merge(src proto.Message)

func (*UnlockRequest) XXX_Size

func (m *UnlockRequest) XXX_Size() int

func (*UnlockRequest) XXX_Unmarshal

func (m *UnlockRequest) XXX_Unmarshal(b []byte) error

type UnlockResponse

type UnlockResponse struct {
	Succeeded bool `protobuf:"varint,1,opt,name=succeeded,proto3" json:"succeeded,omitempty"`
}

func (*UnlockResponse) Descriptor

func (*UnlockResponse) Descriptor() ([]byte, []int)

func (*UnlockResponse) GetSucceeded

func (m *UnlockResponse) GetSucceeded() bool

func (*UnlockResponse) Marshal

func (m *UnlockResponse) Marshal() (dAtA []byte, err error)

func (*UnlockResponse) MarshalTo

func (m *UnlockResponse) MarshalTo(dAtA []byte) (int, error)

func (*UnlockResponse) MarshalToSizedBuffer

func (m *UnlockResponse) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*UnlockResponse) ProtoMessage

func (*UnlockResponse) ProtoMessage()

func (*UnlockResponse) Reset

func (m *UnlockResponse) Reset()

func (*UnlockResponse) Size

func (m *UnlockResponse) Size() (n int)

func (*UnlockResponse) String

func (m *UnlockResponse) String() string

func (*UnlockResponse) Unmarshal

func (m *UnlockResponse) Unmarshal(dAtA []byte) error

func (*UnlockResponse) XXX_DiscardUnknown

func (m *UnlockResponse) XXX_DiscardUnknown()

func (*UnlockResponse) XXX_Marshal

func (m *UnlockResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*UnlockResponse) XXX_Merge

func (m *UnlockResponse) XXX_Merge(src proto.Message)

func (*UnlockResponse) XXX_Size

func (m *UnlockResponse) XXX_Size() int

func (*UnlockResponse) XXX_Unmarshal

func (m *UnlockResponse) XXX_Unmarshal(b []byte) error

Jump to

Keyboard shortcuts

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