client

package
v2.1.6+incompatible Latest Latest
Warning

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

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

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

View Source
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

View Source
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

func NewNoOPSession(clusterID uint64, rng random.Source) *Session

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

func NewSession(clusterID uint64, rng random.Source) *Session

NewSession returns a new client session not registered yet. This function is not expected to be directly invoked by application.

func (*Session) ClusterIDMustMatch

func (cs *Session) ClusterIDMustMatch(clusterID uint64)

ClusterIDMustMatch asserts that the input cluster id matches the cluster id of the client session.

func (*Session) Descriptor

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

func (*Session) GetClientID

func (m *Session) GetClientID() uint64

func (*Session) GetClusterID

func (m *Session) GetClusterID() uint64

func (*Session) GetRespondedTo

func (m *Session) GetRespondedTo() uint64

func (*Session) GetSeriesID

func (m *Session) GetSeriesID() uint64

func (*Session) Marshal

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

func (*Session) MarshalTo

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

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) Reset

func (m *Session) Reset()

func (*Session) Size

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

func (*Session) String

func (m *Session) String() string

func (*Session) Unmarshal

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

func (*Session) ValidForProposal

func (cs *Session) ValidForProposal(clusterID uint64) bool

ValidForProposal checks whether the client session object is valid for making proposals.

func (*Session) ValidForSessionOp

func (cs *Session) ValidForSessionOp(clusterID uint64) bool

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()

func (*Session) XXX_Marshal

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

func (*Session) XXX_Merge

func (dst *Session) XXX_Merge(src proto.Message)

func (*Session) XXX_Size

func (m *Session) XXX_Size() int

func (*Session) XXX_Unmarshal

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

Jump to

Keyboard shortcuts

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