Documentation
¶
Overview ¶
Package api implements protobuf gRPC coordination and loopback HTTP health.
Index ¶
- Constants
- Variables
- func Follow(ctx context.Context, client CoordinationClient, outbound <-chan *ClientMessage, ...) error
- func NewHealthHandler(healthy func() bool) http.Handler
- func RegisterCoordinationServer(s grpc.ServiceRegistrar, srv CoordinationServer)
- type Ack
- type ClientMessage
- func (*ClientMessage) Descriptor() ([]byte, []int)deprecated
- func (x *ClientMessage) GetDrain() *Drain
- func (x *ClientMessage) GetHello() *Hello
- func (x *ClientMessage) GetMessage() isClientMessage_Message
- func (x *ClientMessage) GetNodeState() *NodeState
- func (*ClientMessage) ProtoMessage()
- func (x *ClientMessage) ProtoReflect() protoreflect.Message
- func (x *ClientMessage) Reset()
- func (x *ClientMessage) String() string
- type ClientMessage_Drain
- type ClientMessage_Hello
- type ClientMessage_NodeState
- type CoordinationClient
- type CoordinationServer
- type Coordination_SyncClient
- type Coordination_SyncServer
- type Drain
- type Endpoint
- func (*Endpoint) Descriptor() ([]byte, []int)deprecated
- func (x *Endpoint) GetAddress() string
- func (x *Endpoint) GetNamespace() string
- func (x *Endpoint) GetNodeGroup() string
- func (x *Endpoint) GetPodUid() string
- func (x *Endpoint) GetPorts() []*TargetPort
- func (x *Endpoint) GetService() string
- func (*Endpoint) ProtoMessage()
- func (x *Endpoint) ProtoReflect() protoreflect.Message
- func (x *Endpoint) Reset()
- func (x *Endpoint) String() string
- type Hello
- func (*Hello) Descriptor() ([]byte, []int)deprecated
- func (x *Hello) GetCluster() string
- func (x *Hello) GetConfigDigest() string
- func (x *Hello) GetIpv6Prefix() string
- func (x *Hello) GetNodeGroup() string
- func (x *Hello) GetNodeId() string
- func (x *Hello) GetServices() []*Service
- func (x *Hello) GetSessionId() string
- func (*Hello) ProtoMessage()
- func (x *Hello) ProtoReflect() protoreflect.Message
- func (x *Hello) Reset()
- func (x *Hello) String() string
- type NodeState
- func (*NodeState) Descriptor() ([]byte, []int)deprecated
- func (x *NodeState) GetConfigDigest() string
- func (x *NodeState) GetEndpoints() []*Endpoint
- func (x *NodeState) GetSequence() uint64
- func (x *NodeState) GetSessionId() string
- func (*NodeState) ProtoMessage()
- func (x *NodeState) ProtoReflect() protoreflect.Message
- func (x *NodeState) Reset()
- func (x *NodeState) String() string
- type Server
- type ServerMessage
- func (*ServerMessage) Descriptor() ([]byte, []int)deprecated
- func (x *ServerMessage) GetAck() *Ack
- func (x *ServerMessage) GetMessage() isServerMessage_Message
- func (x *ServerMessage) GetSnapshot() *Snapshot
- func (*ServerMessage) ProtoMessage()
- func (x *ServerMessage) ProtoReflect() protoreflect.Message
- func (x *ServerMessage) Reset()
- func (x *ServerMessage) String() string
- type ServerMessage_Ack
- type ServerMessage_Snapshot
- type Service
- func (*Service) Descriptor() ([]byte, []int)deprecated
- func (x *Service) GetBackends() []*Endpoint
- func (x *Service) GetFqdn() string
- func (x *Service) GetName() string
- func (x *Service) GetNamespace() string
- func (x *Service) GetNodeGroup() string
- func (x *Service) GetPorts() []*TargetPort
- func (x *Service) GetVip() string
- func (*Service) ProtoMessage()
- func (x *Service) ProtoReflect() protoreflect.Message
- func (x *Service) Reset()
- func (x *Service) String() string
- type Snapshot
- func (*Snapshot) Descriptor() ([]byte, []int)deprecated
- func (x *Snapshot) GetConfigDigest() string
- func (x *Snapshot) GetGeneration() uint64
- func (x *Snapshot) GetLeaderId() string
- func (x *Snapshot) GetRevision() uint64
- func (x *Snapshot) GetServices() []*Service
- func (*Snapshot) ProtoMessage()
- func (x *Snapshot) ProtoReflect() protoreflect.Message
- func (x *Snapshot) Reset()
- func (x *Snapshot) String() string
- type SyncBackend
- type TargetPort
- func (*TargetPort) Descriptor() ([]byte, []int)deprecated
- func (x *TargetPort) GetName() string
- func (x *TargetPort) GetProtocol() string
- func (x *TargetPort) GetServicePort() uint32
- func (x *TargetPort) GetTargetPort() uint32
- func (*TargetPort) ProtoMessage()
- func (x *TargetPort) ProtoReflect() protoreflect.Message
- func (x *TargetPort) Reset()
- func (x *TargetPort) String() string
- type UnimplementedCoordinationServer
- type UnsafeCoordinationServer
Constants ¶
const (
Coordination_Sync_FullMethodName = "/podmin.agent.api.v1.Coordination/Sync"
)
Variables ¶
var Coordination_ServiceDesc = grpc.ServiceDesc{ ServiceName: "podmin.agent.api.v1.Coordination", HandlerType: (*CoordinationServer)(nil), Methods: []grpc.MethodDesc{}, Streams: []grpc.StreamDesc{ { StreamName: "Sync", Handler: _Coordination_Sync_Handler, ServerStreams: true, ClientStreams: true, }, }, Metadata: "proto/coordination.proto", }
Coordination_ServiceDesc is the grpc.ServiceDesc for Coordination service. It's only intended for direct use with grpc.RegisterService, and not to be introspected or modified (even as a copy)
var File_proto_coordination_proto protoreflect.FileDescriptor
Functions ¶
func Follow ¶
func Follow(ctx context.Context, client CoordinationClient, outbound <-chan *ClientMessage, apply func(*ServerMessage) error) error
Follow opens Sync, sends outbound complete-state messages, and applies server messages.
func NewHealthHandler ¶
NewHealthHandler constructs the loopback health transport.
func RegisterCoordinationServer ¶
func RegisterCoordinationServer(s grpc.ServiceRegistrar, srv CoordinationServer)
Types ¶
type Ack ¶
type Ack struct {
Sequence uint64 `protobuf:"varint,1,opt,name=sequence,proto3" json:"sequence,omitempty"`
// contains filtered or unexported fields
}
Ack confirms that the leader accepted a NodeState sequence.
func (*Ack) Descriptor
deprecated
func (*Ack) GetSequence ¶
func (*Ack) ProtoMessage ¶
func (*Ack) ProtoMessage()
func (*Ack) ProtoReflect ¶
func (x *Ack) ProtoReflect() protoreflect.Message
type ClientMessage ¶
type ClientMessage struct {
// Types that are valid to be assigned to Message:
//
// *ClientMessage_Hello
// *ClientMessage_NodeState
// *ClientMessage_Drain
Message isClientMessage_Message `protobuf_oneof:"message"`
// contains filtered or unexported fields
}
ClientMessage carries one node-to-leader coordination event.
func (*ClientMessage) Descriptor
deprecated
func (*ClientMessage) Descriptor() ([]byte, []int)
Deprecated: Use ClientMessage.ProtoReflect.Descriptor instead.
func (*ClientMessage) GetDrain ¶
func (x *ClientMessage) GetDrain() *Drain
func (*ClientMessage) GetHello ¶
func (x *ClientMessage) GetHello() *Hello
func (*ClientMessage) GetMessage ¶
func (x *ClientMessage) GetMessage() isClientMessage_Message
func (*ClientMessage) GetNodeState ¶
func (x *ClientMessage) GetNodeState() *NodeState
func (*ClientMessage) ProtoMessage ¶
func (*ClientMessage) ProtoMessage()
func (*ClientMessage) ProtoReflect ¶
func (x *ClientMessage) ProtoReflect() protoreflect.Message
func (*ClientMessage) Reset ¶
func (x *ClientMessage) Reset()
func (*ClientMessage) String ¶
func (x *ClientMessage) String() string
type ClientMessage_Drain ¶
type ClientMessage_Drain struct {
Drain *Drain `protobuf:"bytes,3,opt,name=drain,proto3,oneof"`
}
type ClientMessage_Hello ¶
type ClientMessage_Hello struct {
Hello *Hello `protobuf:"bytes,1,opt,name=hello,proto3,oneof"`
}
type ClientMessage_NodeState ¶
type ClientMessage_NodeState struct {
NodeState *NodeState `protobuf:"bytes,2,opt,name=node_state,json=nodeState,proto3,oneof"`
}
type CoordinationClient ¶
type CoordinationClient interface {
// Sync maintains one bidirectional coordination session between a follower node and the leader node.
Sync(ctx context.Context, opts ...grpc.CallOption) (grpc.BidiStreamingClient[ClientMessage, ServerMessage], error)
}
CoordinationClient is the client API for Coordination service.
For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
Coordination synchronizes node state and complete Service snapshots with the elected leader.
func NewCoordinationClient ¶
func NewCoordinationClient(cc grpc.ClientConnInterface) CoordinationClient
type CoordinationServer ¶
type CoordinationServer interface {
// Sync maintains one bidirectional coordination session between a follower node and the leader node.
Sync(grpc.BidiStreamingServer[ClientMessage, ServerMessage]) error
// contains filtered or unexported methods
}
CoordinationServer is the server API for Coordination service. All implementations must embed UnimplementedCoordinationServer for forward compatibility.
Coordination synchronizes node state and complete Service snapshots with the elected leader.
type Coordination_SyncClient ¶
type Coordination_SyncClient = grpc.BidiStreamingClient[ClientMessage, ServerMessage]
This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name.
type Coordination_SyncServer ¶
type Coordination_SyncServer = grpc.BidiStreamingServer[ClientMessage, ServerMessage]
This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name.
type Drain ¶
type Drain struct {
SessionId string `protobuf:"bytes,1,opt,name=session_id,json=sessionId,proto3" json:"session_id,omitempty"`
// contains filtered or unexported fields
}
Drain asks the leader to withdraw a terminating node session immediately.
func (*Drain) Descriptor
deprecated
func (*Drain) GetSessionId ¶
func (*Drain) ProtoMessage ¶
func (*Drain) ProtoMessage()
func (*Drain) ProtoReflect ¶
func (x *Drain) ProtoReflect() protoreflect.Message
type Endpoint ¶
type Endpoint struct {
Service string `protobuf:"bytes,1,opt,name=service,proto3" json:"service,omitempty"`
PodUid string `protobuf:"bytes,2,opt,name=pod_uid,json=podUid,proto3" json:"pod_uid,omitempty"`
Address string `protobuf:"bytes,3,opt,name=address,proto3" json:"address,omitempty"`
Ports []*TargetPort `protobuf:"bytes,4,rep,name=ports,proto3" json:"ports,omitempty"`
NodeGroup string `protobuf:"bytes,5,opt,name=node_group,json=nodeGroup,proto3" json:"node_group,omitempty"`
Namespace string `protobuf:"bytes,6,opt,name=namespace,proto3" json:"namespace,omitempty"`
// contains filtered or unexported fields
}
Endpoint describes one ready Pod backend for a Service.
func (*Endpoint) Descriptor
deprecated
func (*Endpoint) GetAddress ¶
func (*Endpoint) GetNamespace ¶
func (*Endpoint) GetNodeGroup ¶
func (*Endpoint) GetPorts ¶
func (x *Endpoint) GetPorts() []*TargetPort
func (*Endpoint) GetService ¶
func (*Endpoint) ProtoMessage ¶
func (*Endpoint) ProtoMessage()
func (*Endpoint) ProtoReflect ¶
func (x *Endpoint) ProtoReflect() protoreflect.Message
type Hello ¶
type Hello struct {
NodeId string `protobuf:"bytes,1,opt,name=node_id,json=nodeId,proto3" json:"node_id,omitempty"`
Cluster string `protobuf:"bytes,2,opt,name=cluster,proto3" json:"cluster,omitempty"`
NodeGroup string `protobuf:"bytes,3,opt,name=node_group,json=nodeGroup,proto3" json:"node_group,omitempty"`
SessionId string `protobuf:"bytes,4,opt,name=session_id,json=sessionId,proto3" json:"session_id,omitempty"`
ConfigDigest string `protobuf:"bytes,5,opt,name=config_digest,json=configDigest,proto3" json:"config_digest,omitempty"`
Services []*Service `protobuf:"bytes,6,rep,name=services,proto3" json:"services,omitempty"`
Ipv6Prefix string `protobuf:"bytes,7,opt,name=ipv6_prefix,json=ipv6Prefix,proto3" json:"ipv6_prefix,omitempty"`
// contains filtered or unexported fields
}
Hello identifies a node session and declares its complete Service contract and IPv6 prefix.
func (*Hello) Descriptor
deprecated
func (*Hello) GetCluster ¶
func (*Hello) GetConfigDigest ¶
func (*Hello) GetIpv6Prefix ¶
func (*Hello) GetNodeGroup ¶
func (*Hello) GetServices ¶
func (*Hello) GetSessionId ¶
func (*Hello) ProtoMessage ¶
func (*Hello) ProtoMessage()
func (*Hello) ProtoReflect ¶
func (x *Hello) ProtoReflect() protoreflect.Message
type NodeState ¶
type NodeState struct {
SessionId string `protobuf:"bytes,1,opt,name=session_id,json=sessionId,proto3" json:"session_id,omitempty"`
Sequence uint64 `protobuf:"varint,2,opt,name=sequence,proto3" json:"sequence,omitempty"`
ConfigDigest string `protobuf:"bytes,3,opt,name=config_digest,json=configDigest,proto3" json:"config_digest,omitempty"`
Endpoints []*Endpoint `protobuf:"bytes,4,rep,name=endpoints,proto3" json:"endpoints,omitempty"`
// contains filtered or unexported fields
}
NodeState replaces a node session's complete set of ready endpoints.
func (*NodeState) Descriptor
deprecated
func (*NodeState) GetConfigDigest ¶
func (*NodeState) GetEndpoints ¶
func (*NodeState) GetSequence ¶
func (*NodeState) GetSessionId ¶
func (*NodeState) ProtoMessage ¶
func (*NodeState) ProtoMessage()
func (*NodeState) ProtoReflect ¶
func (x *NodeState) ProtoReflect() protoreflect.Message
type Server ¶
type Server struct {
UnimplementedCoordinationServer
Backend SyncBackend
}
Server adapts a SyncBackend to the generated coordination server.
func (*Server) Sync ¶
func (s *Server) Sync(stream grpc.BidiStreamingServer[ClientMessage, ServerMessage]) error
Sync serves one bidirectional coordination stream.
type ServerMessage ¶
type ServerMessage struct {
// Types that are valid to be assigned to Message:
//
// *ServerMessage_Ack
// *ServerMessage_Snapshot
Message isServerMessage_Message `protobuf_oneof:"message"`
// contains filtered or unexported fields
}
ServerMessage carries one leader-to-node acknowledgement or complete snapshot.
func (*ServerMessage) Descriptor
deprecated
func (*ServerMessage) Descriptor() ([]byte, []int)
Deprecated: Use ServerMessage.ProtoReflect.Descriptor instead.
func (*ServerMessage) GetAck ¶
func (x *ServerMessage) GetAck() *Ack
func (*ServerMessage) GetMessage ¶
func (x *ServerMessage) GetMessage() isServerMessage_Message
func (*ServerMessage) GetSnapshot ¶
func (x *ServerMessage) GetSnapshot() *Snapshot
func (*ServerMessage) ProtoMessage ¶
func (*ServerMessage) ProtoMessage()
func (*ServerMessage) ProtoReflect ¶
func (x *ServerMessage) ProtoReflect() protoreflect.Message
func (*ServerMessage) Reset ¶
func (x *ServerMessage) Reset()
func (*ServerMessage) String ¶
func (x *ServerMessage) String() string
type ServerMessage_Ack ¶
type ServerMessage_Ack struct {
Ack *Ack `protobuf:"bytes,1,opt,name=ack,proto3,oneof"`
}
type ServerMessage_Snapshot ¶
type ServerMessage_Snapshot struct {
Snapshot *Snapshot `protobuf:"bytes,2,opt,name=snapshot,proto3,oneof"`
}
type Service ¶
type Service struct {
Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
Fqdn string `protobuf:"bytes,2,opt,name=fqdn,proto3" json:"fqdn,omitempty"`
Vip string `protobuf:"bytes,3,opt,name=vip,proto3" json:"vip,omitempty"`
Ports []*TargetPort `protobuf:"bytes,4,rep,name=ports,proto3" json:"ports,omitempty"`
Backends []*Endpoint `protobuf:"bytes,5,rep,name=backends,proto3" json:"backends,omitempty"`
NodeGroup string `protobuf:"bytes,6,opt,name=node_group,json=nodeGroup,proto3" json:"node_group,omitempty"`
Namespace string `protobuf:"bytes,7,opt,name=namespace,proto3" json:"namespace,omitempty"`
// contains filtered or unexported fields
}
Service describes one desired Service and its optional ready backends.
func (*Service) Descriptor
deprecated
func (*Service) GetBackends ¶
func (*Service) GetNamespace ¶
func (*Service) GetNodeGroup ¶
func (*Service) GetPorts ¶
func (x *Service) GetPorts() []*TargetPort
func (*Service) ProtoMessage ¶
func (*Service) ProtoMessage()
func (*Service) ProtoReflect ¶
func (x *Service) ProtoReflect() protoreflect.Message
type Snapshot ¶
type Snapshot struct {
Generation uint64 `protobuf:"varint,1,opt,name=generation,proto3" json:"generation,omitempty"`
Revision uint64 `protobuf:"varint,2,opt,name=revision,proto3" json:"revision,omitempty"`
LeaderId string `protobuf:"bytes,3,opt,name=leader_id,json=leaderId,proto3" json:"leader_id,omitempty"`
ConfigDigest string `protobuf:"bytes,4,opt,name=config_digest,json=configDigest,proto3" json:"config_digest,omitempty"`
Services []*Service `protobuf:"bytes,5,rep,name=services,proto3" json:"services,omitempty"`
// contains filtered or unexported fields
}
Snapshot contains the complete generation and revision of cluster Service state.
func (*Snapshot) Descriptor
deprecated
func (*Snapshot) GetConfigDigest ¶
func (*Snapshot) GetGeneration ¶
func (*Snapshot) GetLeaderId ¶
func (*Snapshot) GetRevision ¶
func (*Snapshot) GetServices ¶
func (*Snapshot) ProtoMessage ¶
func (*Snapshot) ProtoMessage()
func (*Snapshot) ProtoReflect ¶
func (x *Snapshot) ProtoReflect() protoreflect.Message
type SyncBackend ¶
type SyncBackend interface {
Handle(context.Context, *ClientMessage) ([]*ServerMessage, error)
Subscribe() (<-chan *ServerMessage, func())
}
SyncBackend processes one client message and returns server messages to send.
type TargetPort ¶
type TargetPort struct {
Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
Protocol string `protobuf:"bytes,2,opt,name=protocol,proto3" json:"protocol,omitempty"`
ServicePort uint32 `protobuf:"varint,3,opt,name=service_port,json=servicePort,proto3" json:"service_port,omitempty"`
TargetPort uint32 `protobuf:"varint,4,opt,name=target_port,json=targetPort,proto3" json:"target_port,omitempty"`
// contains filtered or unexported fields
}
TargetPort maps one Service port to the corresponding Pod port.
func (*TargetPort) Descriptor
deprecated
func (*TargetPort) Descriptor() ([]byte, []int)
Deprecated: Use TargetPort.ProtoReflect.Descriptor instead.
func (*TargetPort) GetName ¶
func (x *TargetPort) GetName() string
func (*TargetPort) GetProtocol ¶
func (x *TargetPort) GetProtocol() string
func (*TargetPort) GetServicePort ¶
func (x *TargetPort) GetServicePort() uint32
func (*TargetPort) GetTargetPort ¶
func (x *TargetPort) GetTargetPort() uint32
func (*TargetPort) ProtoMessage ¶
func (*TargetPort) ProtoMessage()
func (*TargetPort) ProtoReflect ¶
func (x *TargetPort) ProtoReflect() protoreflect.Message
func (*TargetPort) Reset ¶
func (x *TargetPort) Reset()
func (*TargetPort) String ¶
func (x *TargetPort) String() string
type UnimplementedCoordinationServer ¶
type UnimplementedCoordinationServer struct{}
UnimplementedCoordinationServer must be embedded to have forward compatible implementations.
NOTE: this should be embedded by value instead of pointer to avoid a nil pointer dereference when methods are called.
type UnsafeCoordinationServer ¶
type UnsafeCoordinationServer interface {
// contains filtered or unexported methods
}
UnsafeCoordinationServer may be embedded to opt out of forward compatibility for this service. Use of this interface is not recommended, as added methods to CoordinationServer will result in compilation errors.