lock

package
v0.10.9 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2022 License: Apache-2.0 Imports: 16 Imported by: 3

Documentation

Overview

Code generated by atomix-go-framework. DO NOT EDIT.

Code generated by atomix-go-framework. DO NOT EDIT.

Index

Constants

View Source
const Type = "Lock"

Variables

View Source
var (
	ErrInvalidLengthState        = fmt.Errorf("proto: negative length found during unmarshaling")
	ErrIntOverflowState          = fmt.Errorf("proto: integer overflow")
	ErrUnexpectedEndOfGroupState = fmt.Errorf("proto: unexpected end of group")
)

Functions

func RegisterService

func RegisterService(node *rsm.Node)

RegisterService registers the election primitive service on the given node

Types

type GetLockQuery added in v0.9.1

type GetLockQuery interface {
	Query
	Request() *lock.GetLockRequest
}

type LockProposal

type LockProposal interface {
	Proposal
	Request() *lock.LockRequest
	Reply(*lock.LockResponse)
	Fail(error)
}

type LockProposals

type LockProposals interface {
	Get(ProposalID) (LockProposal, bool)
	List() []LockProposal
}

type LockRequest

type LockRequest struct {
	ProposalID ProposalID `protobuf:"varint,1,opt,name=proposal_id,json=proposalId,proto3,casttype=ProposalID" json:"proposal_id,omitempty"`
	SessionID  SessionID  `protobuf:"varint,2,opt,name=session_id,json=sessionId,proto3,casttype=SessionID" json:"session_id,omitempty"`
	Expire     *time.Time `protobuf:"bytes,3,opt,name=expire,proto3,stdtime" json:"expire,omitempty"`
}

func (*LockRequest) Descriptor

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

func (*LockRequest) GetExpire

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

func (*LockRequest) GetProposalID

func (m *LockRequest) GetProposalID() ProposalID

func (*LockRequest) GetSessionID

func (m *LockRequest) GetSessionID() SessionID

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 LockState

type LockState struct {
	Owner    *LockRequest  `protobuf:"bytes,1,opt,name=owner,proto3" json:"owner,omitempty"`
	Requests []LockRequest `protobuf:"bytes,2,rep,name=requests,proto3" json:"requests"`
}

func (*LockState) Descriptor

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

func (*LockState) GetOwner

func (m *LockState) GetOwner() *LockRequest

func (*LockState) GetRequests

func (m *LockState) GetRequests() []LockRequest

func (*LockState) Marshal

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

func (*LockState) MarshalTo

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

func (*LockState) MarshalToSizedBuffer

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

func (*LockState) ProtoMessage

func (*LockState) ProtoMessage()

func (*LockState) Reset

func (m *LockState) Reset()

func (*LockState) Size

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

func (*LockState) String

func (m *LockState) String() string

func (*LockState) Unmarshal

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

func (*LockState) XXX_DiscardUnknown

func (m *LockState) XXX_DiscardUnknown()

func (*LockState) XXX_Marshal

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

func (*LockState) XXX_Merge

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

func (*LockState) XXX_Size

func (m *LockState) XXX_Size() int

func (*LockState) XXX_Unmarshal

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

type NewServiceFunc

type NewServiceFunc func(ServiceContext) Service

type Proposal

type Proposal interface {
	fmt.Stringer
	ID() ProposalID
	Session() Session
	State() ProposalState
	Watch(func(ProposalState)) Watcher
}

type ProposalID

type ProposalID uint64

type ProposalState added in v0.9.1

type ProposalState int
const (
	ProposalComplete ProposalState = iota
	ProposalOpen
)

type Proposals

type Proposals interface {
	Lock() LockProposals
	Unlock() UnlockProposals
}

type Query added in v0.9.1

type Query interface {
	fmt.Stringer
	Session() Session
}

type Service

type Service interface {
	ServiceContext
	Backup(SnapshotWriter) error
	Restore(SnapshotReader) error
	// Lock attempts to acquire the lock
	Lock(LockProposal)
	// Unlock releases the lock
	Unlock(UnlockProposal) (*lock.UnlockResponse, error)
	// GetLock gets the lock state
	GetLock(GetLockQuery) (*lock.GetLockResponse, error)
}

type ServiceAdaptor

type ServiceAdaptor struct {
	rsm.ServiceContext
	// contains filtered or unexported fields
}

func (*ServiceAdaptor) Backup

func (s *ServiceAdaptor) Backup(writer io.Writer) error

func (*ServiceAdaptor) ExecuteCommand added in v0.9.1

func (s *ServiceAdaptor) ExecuteCommand(command rsm.Command)

func (*ServiceAdaptor) ExecuteQuery added in v0.9.1

func (s *ServiceAdaptor) ExecuteQuery(query rsm.Query)

func (*ServiceAdaptor) Restore

func (s *ServiceAdaptor) Restore(reader io.Reader) error

type ServiceContext

type ServiceContext interface {
	Scheduler() rsm.Scheduler
	Sessions() Sessions
	Proposals() Proposals
}

type Session

type Session interface {
	ID() SessionID
	State() SessionState
	Watch(func(SessionState)) Watcher
	Proposals() Proposals
}

type SessionID

type SessionID uint64

type SessionState

type SessionState int
const (
	SessionClosed SessionState = iota
	SessionOpen
)

type Sessions

type Sessions interface {
	Get(SessionID) (Session, bool)
	List() []Session
}

type SnapshotReader

type SnapshotReader interface {
	ReadState() (*LockState, error)
}

type SnapshotWriter

type SnapshotWriter interface {
	WriteState(*LockState) error
}

type UnlockProposal

type UnlockProposal interface {
	Proposal
	Request() *lock.UnlockRequest
}

type UnlockProposals

type UnlockProposals interface {
	Get(ProposalID) (UnlockProposal, bool)
	List() []UnlockProposal
}

type Watcher

type Watcher interface {
	Cancel()
}

Jump to

Keyboard shortcuts

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