privateapi

package
v0.0.0-...-39cfe40 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2024 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Overview

Package privateapi is a generated protocol buffer package.

It is generated from these files:

pkg/privateapi/cluster.proto

It has these top-level messages:

PingRequest
PingResponse
PeerInfo
View
LeaderNotificationRequest
LeaderNotificationResponse

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterClusterServiceServer

func RegisterClusterServiceServer(s *grpc.Server, srv ClusterServiceServer)

Types

type ClusterServiceClient

type ClusterServiceClient interface {
	// Ping just pings another node, part of the discovery protocol
	Ping(ctx context.Context, in *PingRequest, opts ...grpc.CallOption) (*PingResponse, error)
	// LeaderNotification is sent by a node that (thinks it) is the leader
	LeaderNotification(ctx context.Context, in *LeaderNotificationRequest, opts ...grpc.CallOption) (*LeaderNotificationResponse, error)
}

func NewClusterServiceClient

func NewClusterServiceClient(cc *grpc.ClientConn) ClusterServiceClient

type ClusterServiceServer

type ClusterServiceServer interface {
	// Ping just pings another node, part of the discovery protocol
	Ping(context.Context, *PingRequest) (*PingResponse, error)
	// LeaderNotification is sent by a node that (thinks it) is the leader
	LeaderNotification(context.Context, *LeaderNotificationRequest) (*LeaderNotificationResponse, error)
}

type LeaderNotificationRequest

type LeaderNotificationRequest struct {
	View *View `protobuf:"bytes,1,opt,name=view" json:"view,omitempty"`
}

func (*LeaderNotificationRequest) Descriptor

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

func (*LeaderNotificationRequest) GetView

func (m *LeaderNotificationRequest) GetView() *View

func (*LeaderNotificationRequest) ProtoMessage

func (*LeaderNotificationRequest) ProtoMessage()

func (*LeaderNotificationRequest) Reset

func (m *LeaderNotificationRequest) Reset()

func (*LeaderNotificationRequest) String

func (m *LeaderNotificationRequest) String() string

type LeaderNotificationResponse

type LeaderNotificationResponse struct {
	// True if this node acknowledges the new leader
	Accepted bool `protobuf:"varint,1,opt,name=accepted" json:"accepted,omitempty"`
	// If the node has a different (bigger) view, it rejects the leadership bid and sends the view
	View *View `protobuf:"bytes,2,opt,name=view" json:"view,omitempty"`
}

func (*LeaderNotificationResponse) Descriptor

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

func (*LeaderNotificationResponse) GetAccepted

func (m *LeaderNotificationResponse) GetAccepted() bool

func (*LeaderNotificationResponse) GetView

func (m *LeaderNotificationResponse) GetView() *View

func (*LeaderNotificationResponse) ProtoMessage

func (*LeaderNotificationResponse) ProtoMessage()

func (*LeaderNotificationResponse) Reset

func (m *LeaderNotificationResponse) Reset()

func (*LeaderNotificationResponse) String

func (m *LeaderNotificationResponse) String() string

type PeerId

type PeerId string

func PersistentPeerId

func PersistentPeerId(basedir string) (PeerId, error)

PersistentPeerId reads the id from the base directory, creating and saving it if it does not exists

type PeerInfo

type PeerInfo struct {
	Id        string   `protobuf:"bytes,1,opt,name=id" json:"id,omitempty"`
	Endpoints []string `protobuf:"bytes,2,rep,name=endpoints" json:"endpoints,omitempty"`
}

func (*PeerInfo) Descriptor

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

func (*PeerInfo) GetEndpoints

func (m *PeerInfo) GetEndpoints() []string

func (*PeerInfo) GetId

func (m *PeerInfo) GetId() string

func (*PeerInfo) ProtoMessage

func (*PeerInfo) ProtoMessage()

func (*PeerInfo) Reset

func (m *PeerInfo) Reset()

func (*PeerInfo) String

func (m *PeerInfo) String() string

type Peers

type Peers interface {
	Peers() []*PeerInfo
	MyPeerId() PeerId
	GetPeerClient(peerId PeerId) (*grpc.ClientConn, error)
	BecomeLeader(ctx context.Context) ([]PeerId, string, error)
	AssertLeadership(ctx context.Context, leadershipToken string) error
	IsLeader(token string) bool
}

type PingRequest

type PingRequest struct {
	Info *PeerInfo `protobuf:"bytes,1,opt,name=info" json:"info,omitempty"`
}

func (*PingRequest) Descriptor

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

func (*PingRequest) GetInfo

func (m *PingRequest) GetInfo() *PeerInfo

func (*PingRequest) ProtoMessage

func (*PingRequest) ProtoMessage()

func (*PingRequest) Reset

func (m *PingRequest) Reset()

func (*PingRequest) String

func (m *PingRequest) String() string

type PingResponse

type PingResponse struct {
	Info *PeerInfo `protobuf:"bytes,1,opt,name=info" json:"info,omitempty"`
}

func (*PingResponse) Descriptor

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

func (*PingResponse) GetInfo

func (m *PingResponse) GetInfo() *PeerInfo

func (*PingResponse) ProtoMessage

func (*PingResponse) ProtoMessage()

func (*PingResponse) Reset

func (m *PingResponse) Reset()

func (*PingResponse) String

func (m *PingResponse) String() string

type Server

type Server struct {

	// DiscoveryPollInterval is the interval with which we request peers from discovery
	DiscoveryPollInterval time.Duration

	// PingInterval is the interval between pings to each of our peers
	PingInterval time.Duration

	// HealthyTimeout is the time after which we will consider a peer down if we have not heard a ping from it
	// HealthyTimeout should be a moderate multiple of PingInterval (e.g. 10x)
	HealthyTimeout time.Duration
	// contains filtered or unexported fields
}

func NewServer

func NewServer(ctx context.Context, myInfo PeerInfo, serverTLSConfig *tls.Config, discovery discovery.Interface, defaultPort int, dnsProvider dns.Provider, dnsSuffix string, clientTLSConfig *tls.Config, discoveryPollInterval time.Duration) (*Server, error)

func (*Server) AssertLeadership

func (s *Server) AssertLeadership(ctx context.Context, leadershipToken string) error

func (*Server) BecomeLeader

func (s *Server) BecomeLeader(ctx context.Context) ([]PeerId, string, error)

func (*Server) GetPeerClient

func (s *Server) GetPeerClient(peerId PeerId) (*grpc.ClientConn, error)

func (*Server) GrpcServer

func (s *Server) GrpcServer() *grpc.Server

func (*Server) IsLeader

func (s *Server) IsLeader(leadershipToken string) bool

func (*Server) LeaderNotification

func (s *Server) LeaderNotification(ctx grpccontext.Context, request *LeaderNotificationRequest) (*LeaderNotificationResponse, error)

func (*Server) ListenAndServe

func (s *Server) ListenAndServe(ctx context.Context, listen string) error

func (*Server) MyPeerId

func (s *Server) MyPeerId() PeerId

func (*Server) Peers

func (s *Server) Peers() []*PeerInfo

func (*Server) Ping

func (s *Server) Ping(ctx context.Context, request *PingRequest) (*PingResponse, error)

Ping is just nodes pinging each other, part of the discovery protocol

type View

type View struct {
	Leader          *PeerInfo   `protobuf:"bytes,1,opt,name=leader" json:"leader,omitempty"`
	LeadershipToken string      `protobuf:"bytes,2,opt,name=leadership_token,json=leadershipToken" json:"leadership_token,omitempty"`
	Healthy         []*PeerInfo `protobuf:"bytes,3,rep,name=healthy" json:"healthy,omitempty"`
}

func (*View) Descriptor

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

func (*View) GetHealthy

func (m *View) GetHealthy() []*PeerInfo

func (*View) GetLeader

func (m *View) GetLeader() *PeerInfo

func (*View) GetLeadershipToken

func (m *View) GetLeadershipToken() string

func (*View) ProtoMessage

func (*View) ProtoMessage()

func (*View) Reset

func (m *View) Reset()

func (*View) String

func (m *View) String() string

Directories

Path Synopsis
vfs

Jump to

Keyboard shortcuts

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