Documentation ¶
Overview ¶
Package client implements the client Session struct for identifying proposal clients and their progress. Together with the LRU based session store on the server side, client Session helps to implement the at-most-once semantic. It ensures that when retrying a prviously timed out proposal, the retried proposal will not be applied twice if the previous proposal attempt actually succeed. See section 6.3 of Diego Ongaro's PhD thesis for more details.
Index ¶
- Constants
- Variables
- type Session
- func (cs *Session) ClusterIDMustMatch(clusterID uint64)
- func (*Session) Descriptor() ([]byte, []int)
- func (m *Session) GetClientID() uint64
- func (m *Session) GetClusterID() uint64
- func (m *Session) GetRespondedTo() uint64
- func (m *Session) GetSeriesID() uint64
- func (m *Session) Marshal() (dAtA []byte, err error)
- func (m *Session) MarshalTo(dAtA []byte) (int, error)
- func (cs *Session) PrepareForPropose()
- func (cs *Session) PrepareForRegister()
- func (cs *Session) PrepareForUnregister()
- func (cs *Session) ProposalCompleted()
- func (*Session) ProtoMessage()
- func (m *Session) Reset()
- func (m *Session) Size() (n int)
- func (m *Session) String() string
- func (m *Session) Unmarshal(dAtA []byte) error
- func (cs *Session) ValidForProposal(clusterID uint64) bool
- func (cs *Session) ValidForSessionOp(clusterID uint64) bool
- func (m *Session) XXX_DiscardUnknown()
- func (m *Session) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (dst *Session) XXX_Merge(src proto.Message)
- func (m *Session) XXX_Size() int
- func (m *Session) XXX_Unmarshal(b []byte) error
Constants ¶
const ( // NotSessionManagedClientID is a special client id used to indicate // that the entry is not managed by a client session. This is used when // the entry is not generated by the user, e.g. the blank entry proposed // after becoming the leader. NotSessionManagedClientID uint64 = 0 // NoOPSeriesID is a special series ID used to indicate that the client // session is a NOOP client session. NoOPSeriesID uint64 = 0 // SeriesIDForRegister is the special series id used for registering // a new client session. SeriesIDForRegister uint64 = math.MaxUint64 - 1 // SeriesIDForUnregister is the special series id used for unregistering // client session. SeriesIDForUnregister uint64 = math.MaxUint64 // SeriesIDFirstProposal is the first series id to be used for making // proposals. SeriesIDFirstProposal uint64 = 1 )
Variables ¶
var ( ErrInvalidLengthSession = fmt.Errorf("proto: negative length found during unmarshaling") ErrIntOverflowSession = fmt.Errorf("proto: integer overflow") )
Functions ¶
This section is empty.
Types ¶
type Session ¶
type Session struct { ClusterID uint64 `protobuf:"varint,1,opt,name=ClusterID" json:"ClusterID"` ClientID uint64 `protobuf:"varint,2,opt,name=ClientID" json:"ClientID"` SeriesID uint64 `protobuf:"varint,3,opt,name=SeriesID" json:"SeriesID"` RespondedTo uint64 `protobuf:"varint,4,opt,name=RespondedTo" json:"RespondedTo"` }
Session is the struct used to keep tracking the progress of a client.
func NewNoOPSession ¶
NewNoOPSession creates a new NoOP client session ready to be used for making proposals. This function is not expected to be directly invoked by application.
func NewSession ¶
NewSession returns a new client session not registered yet. This function is not expected to be directly invoked by application.
func (*Session) ClusterIDMustMatch ¶
ClusterIDMustMatch asserts that the input cluster id matches the cluster id of the client session.
func (*Session) Descriptor ¶
func (*Session) GetClientID ¶
func (*Session) GetClusterID ¶
func (*Session) GetRespondedTo ¶
func (*Session) GetSeriesID ¶
func (*Session) PrepareForPropose ¶
func (cs *Session) PrepareForPropose()
PrepareForPropose sets the series id to the first series id that can be used for making proposals.
func (*Session) PrepareForRegister ¶
func (cs *Session) PrepareForRegister()
PrepareForRegister sets the series id to the special series id for registering client session.
func (*Session) PrepareForUnregister ¶
func (cs *Session) PrepareForUnregister()
PrepareForUnregister sets the series id to the special series id for unregistering client session.
func (*Session) ProposalCompleted ¶
func (cs *Session) ProposalCompleted()
ProposalCompleted increases the series id and the RespondedTo value. ProposalCompleted is expected to be called by the application every time when a proposal is completed or aborted by the application.
func (*Session) ProtoMessage ¶
func (*Session) ProtoMessage()
func (*Session) ValidForProposal ¶
ValidForProposal checks whether the client session object is valid for making proposals.
func (*Session) ValidForSessionOp ¶
ValidForSessionOp checks whether the client session is valid for making client session related proposals, e.g. registering or unregistering a client session.
func (*Session) XXX_DiscardUnknown ¶
func (m *Session) XXX_DiscardUnknown()