leader

package
v0.0.0-...-1bf965b Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2020 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidLengthLatch        = fmt.Errorf("proto: negative length found during unmarshaling")
	ErrIntOverflowLatch          = fmt.Errorf("proto: integer overflow")
	ErrUnexpectedEndOfGroupLatch = fmt.Errorf("proto: unexpected end of group")
)
View Source
var ListenResponse_Type_name = map[int32]string{
	0: "CHANGED",
}
View Source
var ListenResponse_Type_value = map[string]int32{
	"CHANGED": 0,
}

Functions

This section is empty.

Types

type GetRequest

type GetRequest struct {
}

func (*GetRequest) Descriptor

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

func (*GetRequest) Marshal

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

func (*GetRequest) MarshalTo

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

func (*GetRequest) MarshalToSizedBuffer

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

func (*GetRequest) ProtoMessage

func (*GetRequest) ProtoMessage()

func (*GetRequest) Reset

func (m *GetRequest) Reset()

func (*GetRequest) Size

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

func (*GetRequest) String

func (m *GetRequest) String() string

func (*GetRequest) Unmarshal

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

func (*GetRequest) XXX_DiscardUnknown

func (m *GetRequest) XXX_DiscardUnknown()

func (*GetRequest) XXX_Marshal

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

func (*GetRequest) XXX_Merge

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

func (*GetRequest) XXX_Size

func (m *GetRequest) XXX_Size() int

func (*GetRequest) XXX_Unmarshal

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

type GetResponse

type GetResponse struct {
	Latch *Latch `protobuf:"bytes,2,opt,name=latch,proto3" json:"latch,omitempty"`
}

func (*GetResponse) Descriptor

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

func (*GetResponse) GetLatch

func (m *GetResponse) GetLatch() *Latch

func (*GetResponse) Marshal

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

func (*GetResponse) MarshalTo

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

func (*GetResponse) MarshalToSizedBuffer

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

func (*GetResponse) ProtoMessage

func (*GetResponse) ProtoMessage()

func (*GetResponse) Reset

func (m *GetResponse) Reset()

func (*GetResponse) Size

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

func (*GetResponse) String

func (m *GetResponse) String() string

func (*GetResponse) Unmarshal

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

func (*GetResponse) XXX_DiscardUnknown

func (m *GetResponse) XXX_DiscardUnknown()

func (*GetResponse) XXX_Marshal

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

func (*GetResponse) XXX_Merge

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

func (*GetResponse) XXX_Size

func (m *GetResponse) XXX_Size() int

func (*GetResponse) XXX_Unmarshal

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

type Latch

type Latch struct {
	ID           uint64   `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"`
	Leader       string   `protobuf:"bytes,2,opt,name=leader,proto3" json:"leader,omitempty"`
	Participants []string `protobuf:"bytes,3,rep,name=participants,proto3" json:"participants,omitempty"`
}

func (*Latch) Descriptor

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

func (*Latch) GetID

func (m *Latch) GetID() uint64

func (*Latch) GetLeader

func (m *Latch) GetLeader() string

func (*Latch) GetParticipants

func (m *Latch) GetParticipants() []string

func (*Latch) Marshal

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

func (*Latch) MarshalTo

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

func (*Latch) MarshalToSizedBuffer

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

func (*Latch) ProtoMessage

func (*Latch) ProtoMessage()

func (*Latch) Reset

func (m *Latch) Reset()

func (*Latch) Size

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

func (*Latch) String

func (m *Latch) String() string

func (*Latch) Unmarshal

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

func (*Latch) XXX_DiscardUnknown

func (m *Latch) XXX_DiscardUnknown()

func (*Latch) XXX_Marshal

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

func (*Latch) XXX_Merge

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

func (*Latch) XXX_Size

func (m *Latch) XXX_Size() int

func (*Latch) XXX_Unmarshal

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

type LatchParticipant

type LatchParticipant struct {
	ID        string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
	SessionID uint64 `protobuf:"varint,2,opt,name=session_id,json=sessionId,proto3" json:"session_id,omitempty"`
}

Latch participant

func (*LatchParticipant) Descriptor

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

func (*LatchParticipant) GetID

func (m *LatchParticipant) GetID() string

func (*LatchParticipant) GetSessionID

func (m *LatchParticipant) GetSessionID() uint64

func (*LatchParticipant) Marshal

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

func (*LatchParticipant) MarshalTo

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

func (*LatchParticipant) MarshalToSizedBuffer

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

func (*LatchParticipant) ProtoMessage

func (*LatchParticipant) ProtoMessage()

func (*LatchParticipant) Reset

func (m *LatchParticipant) Reset()

func (*LatchParticipant) Size

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

func (*LatchParticipant) String

func (m *LatchParticipant) String() string

func (*LatchParticipant) Unmarshal

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

func (*LatchParticipant) XXX_DiscardUnknown

func (m *LatchParticipant) XXX_DiscardUnknown()

func (*LatchParticipant) XXX_Marshal

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

func (*LatchParticipant) XXX_Merge

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

func (*LatchParticipant) XXX_Size

func (m *LatchParticipant) XXX_Size() int

func (*LatchParticipant) XXX_Unmarshal

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

type LatchRequest

type LatchRequest struct {
	ID string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
}

func (*LatchRequest) Descriptor

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

func (*LatchRequest) GetID

func (m *LatchRequest) GetID() string

func (*LatchRequest) Marshal

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

func (*LatchRequest) MarshalTo

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

func (*LatchRequest) MarshalToSizedBuffer

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

func (*LatchRequest) ProtoMessage

func (*LatchRequest) ProtoMessage()

func (*LatchRequest) Reset

func (m *LatchRequest) Reset()

func (*LatchRequest) Size

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

func (*LatchRequest) String

func (m *LatchRequest) String() string

func (*LatchRequest) Unmarshal

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

func (*LatchRequest) XXX_DiscardUnknown

func (m *LatchRequest) XXX_DiscardUnknown()

func (*LatchRequest) XXX_Marshal

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

func (*LatchRequest) XXX_Merge

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

func (*LatchRequest) XXX_Size

func (m *LatchRequest) XXX_Size() int

func (*LatchRequest) XXX_Unmarshal

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

type LatchResponse

type LatchResponse struct {
	Latch *Latch `protobuf:"bytes,1,opt,name=latch,proto3" json:"latch,omitempty"`
}

func (*LatchResponse) Descriptor

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

func (*LatchResponse) GetLatch

func (m *LatchResponse) GetLatch() *Latch

func (*LatchResponse) Marshal

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

func (*LatchResponse) MarshalTo

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

func (*LatchResponse) MarshalToSizedBuffer

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

func (*LatchResponse) ProtoMessage

func (*LatchResponse) ProtoMessage()

func (*LatchResponse) Reset

func (m *LatchResponse) Reset()

func (*LatchResponse) Size

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

func (*LatchResponse) String

func (m *LatchResponse) String() string

func (*LatchResponse) Unmarshal

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

func (*LatchResponse) XXX_DiscardUnknown

func (m *LatchResponse) XXX_DiscardUnknown()

func (*LatchResponse) XXX_Marshal

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

func (*LatchResponse) XXX_Merge

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

func (*LatchResponse) XXX_Size

func (m *LatchResponse) XXX_Size() int

func (*LatchResponse) XXX_Unmarshal

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

type LatchSnapshot

type LatchSnapshot struct {
	Latch        uint64              `protobuf:"varint,1,opt,name=latch,proto3" json:"latch,omitempty"`
	Leader       *LatchParticipant   `protobuf:"bytes,2,opt,name=leader,proto3" json:"leader,omitempty"`
	Participants []*LatchParticipant `protobuf:"bytes,3,rep,name=participants,proto3" json:"participants,omitempty"`
}

LatchSnapshot snapshot

func (*LatchSnapshot) Descriptor

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

func (*LatchSnapshot) GetLatch

func (m *LatchSnapshot) GetLatch() uint64

func (*LatchSnapshot) GetLeader

func (m *LatchSnapshot) GetLeader() *LatchParticipant

func (*LatchSnapshot) GetParticipants

func (m *LatchSnapshot) GetParticipants() []*LatchParticipant

func (*LatchSnapshot) Marshal

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

func (*LatchSnapshot) MarshalTo

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

func (*LatchSnapshot) MarshalToSizedBuffer

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

func (*LatchSnapshot) ProtoMessage

func (*LatchSnapshot) ProtoMessage()

func (*LatchSnapshot) Reset

func (m *LatchSnapshot) Reset()

func (*LatchSnapshot) Size

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

func (*LatchSnapshot) String

func (m *LatchSnapshot) String() string

func (*LatchSnapshot) Unmarshal

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

func (*LatchSnapshot) XXX_DiscardUnknown

func (m *LatchSnapshot) XXX_DiscardUnknown()

func (*LatchSnapshot) XXX_Marshal

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

func (*LatchSnapshot) XXX_Merge

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

func (*LatchSnapshot) XXX_Size

func (m *LatchSnapshot) XXX_Size() int

func (*LatchSnapshot) XXX_Unmarshal

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

type ListenRequest

type ListenRequest struct {
}

func (*ListenRequest) Descriptor

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

func (*ListenRequest) Marshal

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

func (*ListenRequest) MarshalTo

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

func (*ListenRequest) MarshalToSizedBuffer

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

func (*ListenRequest) ProtoMessage

func (*ListenRequest) ProtoMessage()

func (*ListenRequest) Reset

func (m *ListenRequest) Reset()

func (*ListenRequest) Size

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

func (*ListenRequest) String

func (m *ListenRequest) String() string

func (*ListenRequest) Unmarshal

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

func (*ListenRequest) XXX_DiscardUnknown

func (m *ListenRequest) XXX_DiscardUnknown()

func (*ListenRequest) XXX_Marshal

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

func (*ListenRequest) XXX_Merge

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

func (*ListenRequest) XXX_Size

func (m *ListenRequest) XXX_Size() int

func (*ListenRequest) XXX_Unmarshal

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

type ListenResponse

type ListenResponse struct {
	Type  ListenResponse_Type `protobuf:"varint,1,opt,name=type,proto3,enum=atomix.latch.service.ListenResponse_Type" json:"type,omitempty"`
	Latch *Latch              `protobuf:"bytes,2,opt,name=latch,proto3" json:"latch,omitempty"`
}

func (*ListenResponse) Descriptor

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

func (*ListenResponse) GetLatch

func (m *ListenResponse) GetLatch() *Latch

func (*ListenResponse) GetType

func (m *ListenResponse) GetType() ListenResponse_Type

func (*ListenResponse) Marshal

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

func (*ListenResponse) MarshalTo

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

func (*ListenResponse) MarshalToSizedBuffer

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

func (*ListenResponse) ProtoMessage

func (*ListenResponse) ProtoMessage()

func (*ListenResponse) Reset

func (m *ListenResponse) Reset()

func (*ListenResponse) Size

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

func (*ListenResponse) String

func (m *ListenResponse) String() string

func (*ListenResponse) Unmarshal

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

func (*ListenResponse) XXX_DiscardUnknown

func (m *ListenResponse) XXX_DiscardUnknown()

func (*ListenResponse) XXX_Marshal

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

func (*ListenResponse) XXX_Merge

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

func (*ListenResponse) XXX_Size

func (m *ListenResponse) XXX_Size() int

func (*ListenResponse) XXX_Unmarshal

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

type ListenResponse_Type

type ListenResponse_Type int32
const (
	ListenResponse_CHANGED ListenResponse_Type = 0
)

func (ListenResponse_Type) EnumDescriptor

func (ListenResponse_Type) EnumDescriptor() ([]byte, []int)

func (ListenResponse_Type) String

func (x ListenResponse_Type) String() string

type Server

type Server struct {
	*server.SessionizedServer
}

Server is an implementation of LeaderElectionServiceServer for the election 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) Events

Events lists for election change events

func (*Server) Get

func (s *Server) Get(ctx context.Context, request *api.GetRequest) (*api.GetResponse, error)

Get gets the current latch

func (*Server) KeepAlive

func (s *Server) KeepAlive(ctx context.Context, request *api.KeepAliveRequest) (*api.KeepAliveResponse, error)

KeepAlive keeps an existing session alive

func (*Server) Latch

func (s *Server) Latch(ctx context.Context, request *api.LatchRequest) (*api.LatchResponse, error)

Latch enters a candidate in the election

type Service

type Service struct {
	*service.SessionizedService
	// contains filtered or unexported fields
}

Service is a state machine for an election primitive

func (*Service) Events

func (e *Service) Events(bytes []byte, stream stream.WriteStream)

Events registers the given channel to receive election events

func (*Service) GetLatch

func (e *Service) GetLatch(bytes []byte) ([]byte, error)

GetLatch gets the current latch

func (*Service) Install

func (e *Service) Install(reader io.Reader) error

Install restores the service from a snapshot

func (*Service) Latch

func (e *Service) Latch(bytes []byte) ([]byte, error)

Latch attempts to acquire the latch

func (*Service) OnClose

func (e *Service) OnClose(session *service.Session)

OnClose is called when a session is closed by the client

func (*Service) OnExpire

func (e *Service) OnExpire(session *service.Session)

OnExpire is called when a session is expired by the server

func (*Service) Snapshot

func (e *Service) Snapshot(writer io.Writer) error

Snapshot takes a snapshot of the service

Jump to

Keyboard shortcuts

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