api

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package api implements protobuf gRPC coordination and loopback HTTP health.

Index

Constants

View Source
const (
	Coordination_Sync_FullMethodName = "/podmin.agent.api.v1.Coordination/Sync"
)

Variables

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

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

func NewHealthHandler(healthy func() bool) http.Handler

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) Descriptor() ([]byte, []int)

Deprecated: Use Ack.ProtoReflect.Descriptor instead.

func (*Ack) GetSequence

func (x *Ack) GetSequence() uint64

func (*Ack) ProtoMessage

func (*Ack) ProtoMessage()

func (*Ack) ProtoReflect

func (x *Ack) ProtoReflect() protoreflect.Message

func (*Ack) Reset

func (x *Ack) Reset()

func (*Ack) String

func (x *Ack) String() string

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.

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) Descriptor() ([]byte, []int)

Deprecated: Use Drain.ProtoReflect.Descriptor instead.

func (*Drain) GetSessionId

func (x *Drain) GetSessionId() string

func (*Drain) ProtoMessage

func (*Drain) ProtoMessage()

func (*Drain) ProtoReflect

func (x *Drain) ProtoReflect() protoreflect.Message

func (*Drain) Reset

func (x *Drain) Reset()

func (*Drain) String

func (x *Drain) String() string

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) Descriptor() ([]byte, []int)

Deprecated: Use Endpoint.ProtoReflect.Descriptor instead.

func (*Endpoint) GetAddress

func (x *Endpoint) GetAddress() string

func (*Endpoint) GetNamespace

func (x *Endpoint) GetNamespace() string

func (*Endpoint) GetNodeGroup

func (x *Endpoint) GetNodeGroup() string

func (*Endpoint) GetPodUid

func (x *Endpoint) GetPodUid() string

func (*Endpoint) GetPorts

func (x *Endpoint) GetPorts() []*TargetPort

func (*Endpoint) GetService

func (x *Endpoint) GetService() string

func (*Endpoint) ProtoMessage

func (*Endpoint) ProtoMessage()

func (*Endpoint) ProtoReflect

func (x *Endpoint) ProtoReflect() protoreflect.Message

func (*Endpoint) Reset

func (x *Endpoint) Reset()

func (*Endpoint) String

func (x *Endpoint) String() string

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) Descriptor() ([]byte, []int)

Deprecated: Use Hello.ProtoReflect.Descriptor instead.

func (*Hello) GetCluster

func (x *Hello) GetCluster() string

func (*Hello) GetConfigDigest

func (x *Hello) GetConfigDigest() string

func (*Hello) GetIpv6Prefix

func (x *Hello) GetIpv6Prefix() string

func (*Hello) GetNodeGroup

func (x *Hello) GetNodeGroup() string

func (*Hello) GetNodeId

func (x *Hello) GetNodeId() string

func (*Hello) GetServices

func (x *Hello) GetServices() []*Service

func (*Hello) GetSessionId

func (x *Hello) GetSessionId() string

func (*Hello) ProtoMessage

func (*Hello) ProtoMessage()

func (*Hello) ProtoReflect

func (x *Hello) ProtoReflect() protoreflect.Message

func (*Hello) Reset

func (x *Hello) Reset()

func (*Hello) String

func (x *Hello) String() string

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) Descriptor() ([]byte, []int)

Deprecated: Use NodeState.ProtoReflect.Descriptor instead.

func (*NodeState) GetConfigDigest

func (x *NodeState) GetConfigDigest() string

func (*NodeState) GetEndpoints

func (x *NodeState) GetEndpoints() []*Endpoint

func (*NodeState) GetSequence

func (x *NodeState) GetSequence() uint64

func (*NodeState) GetSessionId

func (x *NodeState) GetSessionId() string

func (*NodeState) ProtoMessage

func (*NodeState) ProtoMessage()

func (*NodeState) ProtoReflect

func (x *NodeState) ProtoReflect() protoreflect.Message

func (*NodeState) Reset

func (x *NodeState) Reset()

func (*NodeState) String

func (x *NodeState) String() string

type Server

type Server struct {
	UnimplementedCoordinationServer
	Backend SyncBackend
}

Server adapts a SyncBackend to the generated coordination server.

func (*Server) Sync

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) Descriptor() ([]byte, []int)

Deprecated: Use Service.ProtoReflect.Descriptor instead.

func (*Service) GetBackends

func (x *Service) GetBackends() []*Endpoint

func (*Service) GetFqdn

func (x *Service) GetFqdn() string

func (*Service) GetName

func (x *Service) GetName() string

func (*Service) GetNamespace

func (x *Service) GetNamespace() string

func (*Service) GetNodeGroup

func (x *Service) GetNodeGroup() string

func (*Service) GetPorts

func (x *Service) GetPorts() []*TargetPort

func (*Service) GetVip

func (x *Service) GetVip() string

func (*Service) ProtoMessage

func (*Service) ProtoMessage()

func (*Service) ProtoReflect

func (x *Service) ProtoReflect() protoreflect.Message

func (*Service) Reset

func (x *Service) Reset()

func (*Service) String

func (x *Service) String() string

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) Descriptor() ([]byte, []int)

Deprecated: Use Snapshot.ProtoReflect.Descriptor instead.

func (*Snapshot) GetConfigDigest

func (x *Snapshot) GetConfigDigest() string

func (*Snapshot) GetGeneration

func (x *Snapshot) GetGeneration() uint64

func (*Snapshot) GetLeaderId

func (x *Snapshot) GetLeaderId() string

func (*Snapshot) GetRevision

func (x *Snapshot) GetRevision() uint64

func (*Snapshot) GetServices

func (x *Snapshot) GetServices() []*Service

func (*Snapshot) ProtoMessage

func (*Snapshot) ProtoMessage()

func (*Snapshot) ProtoReflect

func (x *Snapshot) ProtoReflect() protoreflect.Message

func (*Snapshot) Reset

func (x *Snapshot) Reset()

func (*Snapshot) String

func (x *Snapshot) String() string

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.

func (UnimplementedCoordinationServer) Sync

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.

Jump to

Keyboard shortcuts

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