Documentation
¶
Index ¶
- Constants
- Variables
- func GenerateCertificateRequest(_ string, _ string) ([]byte, error)
- func LoadCABundle(source CertificateSource, fileOrEnvVar string) (*x509.CertPool, error)
- func ParseCertificateChain(pemData []byte) ([]*x509.Certificate, error)
- func RegisterMeshServiceServer(s grpc.ServiceRegistrar, srv MeshServiceServer)
- type Caller
- type CertificateSource
- type FunctionHealthChecker
- type GetTopologyRequest
- func (*GetTopologyRequest) Descriptor() ([]byte, []int)deprecated
- func (x *GetTopologyRequest) GetSenderId() string
- func (*GetTopologyRequest) ProtoMessage()
- func (x *GetTopologyRequest) ProtoReflect() protoreflect.Message
- func (x *GetTopologyRequest) Reset()
- func (x *GetTopologyRequest) String() string
- type GetTopologyResponse
- func (*GetTopologyResponse) Descriptor() ([]byte, []int)deprecated
- func (x *GetTopologyResponse) GetNodes() []*TopologyNode
- func (x *GetTopologyResponse) GetVersion() int64
- func (*GetTopologyResponse) ProtoMessage()
- func (x *GetTopologyResponse) ProtoReflect() protoreflect.Message
- func (x *GetTopologyResponse) Reset()
- func (x *GetTopologyResponse) String() string
- type HealthChecker
- type HealthInfo
- type HealthRequest
- type HealthResponse
- func (*HealthResponse) Descriptor() ([]byte, []int)deprecated
- func (x *HealthResponse) GetError() string
- func (x *HealthResponse) GetLastChecked() int64
- func (x *HealthResponse) GetMessage() string
- func (x *HealthResponse) GetNodeId() string
- func (x *HealthResponse) GetStatus() string
- func (*HealthResponse) ProtoMessage()
- func (x *HealthResponse) ProtoReflect() protoreflect.Message
- func (x *HealthResponse) Reset()
- func (x *HealthResponse) String() string
- type HealthStatus
- type MeshServer
- func (ms *MeshServer) GetHealth(ctx context.Context, req *HealthRequest) (*HealthResponse, error)
- func (ms *MeshServer) GetNodeInfo(ctx context.Context, req *NodeInfoRequest) (*NodeInfoResponse, error)
- func (ms *MeshServer) GetTopology(ctx context.Context, req *GetTopologyRequest) (*GetTopologyResponse, error)
- func (ms *MeshServer) Ping(ctx context.Context, req *PingRequest) (*PingResponse, error)
- func (ms *MeshServer) RegisterService(r ServiceRegistrar)
- func (ms *MeshServer) SetTLSConfig(tlsConfig *TLSConfig)
- func (ms *MeshServer) Start() error
- func (ms *MeshServer) Stop()
- func (ms *MeshServer) SyncTopology(ctx context.Context, req *TopologySyncRequest) (*TopologySyncResponse, error)
- type MeshServiceClient
- type MeshServiceServer
- type Node
- func (n *Node) AddPeer(info PeerInfo) error
- func (n *Node) CheckHealth(ctx context.Context, checker HealthChecker) error
- func (n *Node) EnableTLS(certDir string) error
- func (n *Node) GetAllPeers() []*Peer
- func (n *Node) GetHealth() (HealthStatus, string)
- func (n *Node) GetMeshNodes() []NodeInfo
- func (n *Node) GetPeer(peerID string) (*Peer, bool)
- func (n *Node) GetPeerHealth(ctx context.Context, peerID string) (*HealthResponse, error)
- func (n *Node) GetPeerNodeInfo(ctx context.Context, peerID string) (*NodeInfoResponse, error)
- func (n *Node) GetTopologyVersion() int64
- func (n *Node) IsHealthy() bool
- func (n *Node) MarshalJSON() ([]byte, error)
- func (n *Node) PingPeer(ctx context.Context, peerID string) (*PingResponse, error)
- func (n *Node) RemovePeer(peerID string) error
- func (n *Node) SetHealth(status HealthStatus, message string, err error)
- func (n *Node) Shutdown() error
- func (n *Node) StartServer() error
- func (n *Node) StopServer()
- func (n *Node) String() string
- func (n *Node) SyncTopology(ctx context.Context, peerID string) error
- func (n *Node) SyncTopologyWithAllPeers(ctx context.Context) error
- func (n *Node) UnmarshalJSON(data []byte) error
- func (n *Node) Validate() error
- type NodeBuilder
- func (nb *NodeBuilder) Build() (*Node, error)
- func (nb *NodeBuilder) WithAddress(address string) *NodeBuilder
- func (nb *NodeBuilder) WithCertDir(certDir string) *NodeBuilder
- func (nb *NodeBuilder) WithID(id string) *NodeBuilder
- func (nb *NodeBuilder) WithName(name string) *NodeBuilder
- func (nb *NodeBuilder) WithServiceRegistration(r ServiceRegistrar) *NodeBuilder
- func (nb *NodeBuilder) WithServices(services ...ServiceInfo) *NodeBuilder
- func (nb *NodeBuilder) WithTLSOptions(opts *TLSOptions) *NodeBuilder
- func (nb *NodeBuilder) WithType(nodeType NodeType) *NodeBuilder
- type NodeInfo
- type NodeInfoRequest
- type NodeInfoResponse
- func (*NodeInfoResponse) Descriptor() ([]byte, []int)deprecated
- func (x *NodeInfoResponse) GetAddress() string
- func (x *NodeInfoResponse) GetHealth() *HealthResponse
- func (x *NodeInfoResponse) GetId() string
- func (x *NodeInfoResponse) GetName() string
- func (x *NodeInfoResponse) GetType() string
- func (*NodeInfoResponse) ProtoMessage()
- func (x *NodeInfoResponse) ProtoReflect() protoreflect.Message
- func (x *NodeInfoResponse) Reset()
- func (x *NodeInfoResponse) String() string
- type NodeType
- type Peer
- type PeerInfo
- type PeerManager
- func (pm *PeerManager) AddPeer(info PeerInfo) error
- func (pm *PeerManager) Close() error
- func (pm *PeerManager) Count() int
- func (pm *PeerManager) GetAllPeers() []*Peer
- func (pm *PeerManager) GetPeer(peerID string) (*Peer, bool)
- func (pm *PeerManager) GetPeerHealth(ctx context.Context, peerID string) (*HealthResponse, error)
- func (pm *PeerManager) GetPeerNodeInfo(ctx context.Context, peerID string) (*NodeInfoResponse, error)
- func (pm *PeerManager) GetPeersByType(nodeType NodeType) []*Peer
- func (pm *PeerManager) IsConnected(peerID string) bool
- func (pm *PeerManager) PingPeer(ctx context.Context, peerID string) (*PingResponse, error)
- func (pm *PeerManager) RemovePeer(peerID string) error
- func (pm *PeerManager) SetTLSConfig(tlsConfig *TLSConfig)
- func (pm *PeerManager) SyncTopology(ctx context.Context, peerID string, version int64) (*TopologySyncResponse, error)
- type PingHealthChecker
- type PingRequest
- func (*PingRequest) Descriptor() ([]byte, []int)deprecated
- func (x *PingRequest) GetSenderId() string
- func (x *PingRequest) GetTimestamp() int64
- func (*PingRequest) ProtoMessage()
- func (x *PingRequest) ProtoReflect() protoreflect.Message
- func (x *PingRequest) Reset()
- func (x *PingRequest) String() string
- type PingResponse
- func (*PingResponse) Descriptor() ([]byte, []int)deprecated
- func (x *PingResponse) GetReceiverId() string
- func (x *PingResponse) GetSuccess() bool
- func (x *PingResponse) GetTimestamp() int64
- func (*PingResponse) ProtoMessage()
- func (x *PingResponse) ProtoReflect() protoreflect.Message
- func (x *PingResponse) Reset()
- func (x *PingResponse) String() string
- type Service
- type ServiceClient
- type ServiceClientPool
- type ServiceInfo
- type ServiceRegistrar
- type TLSConfig
- type TLSOptions
- type Topology
- func (t *Topology) AddNode(info NodeInfo) error
- func (t *Topology) Clone() *Topology
- func (t *Topology) GetAllNodes() []NodeInfo
- func (t *Topology) GetNode(nodeID string) (NodeInfo, bool)
- func (t *Topology) GetNodesByService(name string) []NodeInfo
- func (t *Topology) GetServiceProviders(name, version string) []NodeInfo
- func (t *Topology) GetVersion() int64
- func (t *Topology) Merge(other *Topology) bool
- func (t *Topology) NodeCount() int
- func (t *Topology) RemoveNode(nodeID string) error
- func (t *Topology) UpdateNode(info NodeInfo) error
- type TopologyNode
- func (*TopologyNode) Descriptor() ([]byte, []int)deprecated
- func (x *TopologyNode) GetAddress() string
- func (x *TopologyNode) GetId() string
- func (x *TopologyNode) GetJoinedAt() int64
- func (x *TopologyNode) GetName() string
- func (x *TopologyNode) GetServices() []*Service
- func (x *TopologyNode) GetType() string
- func (x *TopologyNode) GetUpdatedAt() int64
- func (*TopologyNode) ProtoMessage()
- func (x *TopologyNode) ProtoReflect() protoreflect.Message
- func (x *TopologyNode) Reset()
- func (x *TopologyNode) String() string
- type TopologySyncRequest
- func (*TopologySyncRequest) Descriptor() ([]byte, []int)deprecated
- func (x *TopologySyncRequest) GetSenderId() string
- func (x *TopologySyncRequest) GetVersion() int64
- func (*TopologySyncRequest) ProtoMessage()
- func (x *TopologySyncRequest) ProtoReflect() protoreflect.Message
- func (x *TopologySyncRequest) Reset()
- func (x *TopologySyncRequest) String() string
- type TopologySyncResponse
- func (*TopologySyncResponse) Descriptor() ([]byte, []int)deprecated
- func (x *TopologySyncResponse) GetNodes() []*TopologyNode
- func (x *TopologySyncResponse) GetUpdatedAt() int64
- func (x *TopologySyncResponse) GetVersion() int64
- func (*TopologySyncResponse) ProtoMessage()
- func (x *TopologySyncResponse) ProtoReflect() protoreflect.Message
- func (x *TopologySyncResponse) Reset()
- func (x *TopologySyncResponse) String() string
- type UnimplementedMeshServiceServer
- func (UnimplementedMeshServiceServer) GetHealth(context.Context, *HealthRequest) (*HealthResponse, error)
- func (UnimplementedMeshServiceServer) GetNodeInfo(context.Context, *NodeInfoRequest) (*NodeInfoResponse, error)
- func (UnimplementedMeshServiceServer) GetTopology(context.Context, *GetTopologyRequest) (*GetTopologyResponse, error)
- func (UnimplementedMeshServiceServer) Ping(context.Context, *PingRequest) (*PingResponse, error)
- func (UnimplementedMeshServiceServer) SyncTopology(context.Context, *TopologySyncRequest) (*TopologySyncResponse, error)
- type UnsafeMeshServiceServer
Constants ¶
const ( MeshService_Ping_FullMethodName = "/aegis.MeshService/Ping" MeshService_GetHealth_FullMethodName = "/aegis.MeshService/GetHealth" MeshService_GetNodeInfo_FullMethodName = "/aegis.MeshService/GetNodeInfo" MeshService_SyncTopology_FullMethodName = "/aegis.MeshService/SyncTopology" MeshService_GetTopology_FullMethodName = "/aegis.MeshService/GetTopology" )
Variables ¶
var ( // ErrNoProviders is returned when no providers are found for a service. ErrNoProviders = errors.New("no providers available for service") // ErrNoTLSConfig is returned when the node has no TLS configuration. ErrNoTLSConfig = errors.New("node has no TLS configuration") )
var ( // ErrNoPeerInfo is returned when no peer info is found in context. ErrNoPeerInfo = errors.New("no peer info in context") // ErrNoTLSInfo is returned when the peer has no TLS info. ErrNoTLSInfo = errors.New("no TLS info in peer") // ErrNoCertificate is returned when no client certificate is present. ErrNoCertificate = errors.New("no client certificate") )
var File_mesh_proto protoreflect.FileDescriptor
var MeshService_ServiceDesc = grpc.ServiceDesc{ ServiceName: "aegis.MeshService", HandlerType: (*MeshServiceServer)(nil), Methods: []grpc.MethodDesc{ { MethodName: "Ping", Handler: _MeshService_Ping_Handler, }, { MethodName: "GetHealth", Handler: _MeshService_GetHealth_Handler, }, { MethodName: "GetNodeInfo", Handler: _MeshService_GetNodeInfo_Handler, }, { MethodName: "SyncTopology", Handler: _MeshService_SyncTopology_Handler, }, { MethodName: "GetTopology", Handler: _MeshService_GetTopology_Handler, }, }, Streams: []grpc.StreamDesc{}, Metadata: "mesh.proto", }
MeshService_ServiceDesc is the grpc.ServiceDesc for MeshService service. It's only intended for direct use with grpc.RegisterService, and not to be introspected or modified (even as a copy)
Functions ¶
func GenerateCertificateRequest ¶
GenerateCertificateRequest generates a CSR for external CA signing.
func LoadCABundle ¶
func LoadCABundle(source CertificateSource, fileOrEnvVar string) (*x509.CertPool, error)
LoadCABundle loads a CA bundle from file or environment
func ParseCertificateChain ¶
func ParseCertificateChain(pemData []byte) ([]*x509.Certificate, error)
ParseCertificateChain parses a PEM certificate chain
func RegisterMeshServiceServer ¶
func RegisterMeshServiceServer(s grpc.ServiceRegistrar, srv MeshServiceServer)
Types ¶
type Caller ¶
type Caller struct {
NodeID string
Certificate *x509.Certificate
}
Caller represents the identity of a calling node.
func CallerFromContext ¶
CallerFromContext extracts the caller's identity from the gRPC context. The caller's node ID is extracted from the client certificate's Common Name.
func MustCallerFromContext ¶
MustCallerFromContext extracts the caller's identity, panicking on error. Use only when mTLS is guaranteed (e.g., after middleware validation).
type CertificateSource ¶
type CertificateSource string
CertificateSource defines how certificates are loaded
const ( // CertSourceFile loads certificates from files CertSourceFile CertificateSource = "file" // CertSourceEnv loads certificates from environment variables CertSourceEnv CertificateSource = "env" // CertSourceVault loads certificates from HashiCorp Vault (future) CertSourceVault CertificateSource = "vault" )
type FunctionHealthChecker ¶
type FunctionHealthChecker struct {
// contains filtered or unexported fields
}
FunctionHealthChecker performs health checks using a custom function.
func NewFunctionHealthChecker ¶
func NewFunctionHealthChecker(name string, checkFn func(ctx context.Context) error) *FunctionHealthChecker
NewFunctionHealthChecker creates a new function-based health checker.
func (*FunctionHealthChecker) Check ¶
func (f *FunctionHealthChecker) Check(ctx context.Context) error
func (*FunctionHealthChecker) Name ¶
func (f *FunctionHealthChecker) Name() string
type GetTopologyRequest ¶
type GetTopologyRequest struct {
SenderId string `protobuf:"bytes,1,opt,name=sender_id,json=senderId,proto3" json:"sender_id,omitempty"`
// contains filtered or unexported fields
}
func (*GetTopologyRequest) Descriptor
deprecated
func (*GetTopologyRequest) Descriptor() ([]byte, []int)
Deprecated: Use GetTopologyRequest.ProtoReflect.Descriptor instead.
func (*GetTopologyRequest) GetSenderId ¶
func (x *GetTopologyRequest) GetSenderId() string
func (*GetTopologyRequest) ProtoMessage ¶
func (*GetTopologyRequest) ProtoMessage()
func (*GetTopologyRequest) ProtoReflect ¶
func (x *GetTopologyRequest) ProtoReflect() protoreflect.Message
func (*GetTopologyRequest) Reset ¶
func (x *GetTopologyRequest) Reset()
func (*GetTopologyRequest) String ¶
func (x *GetTopologyRequest) String() string
type GetTopologyResponse ¶
type GetTopologyResponse struct {
Version int64 `protobuf:"varint,1,opt,name=version,proto3" json:"version,omitempty"`
Nodes []*TopologyNode `protobuf:"bytes,2,rep,name=nodes,proto3" json:"nodes,omitempty"`
// contains filtered or unexported fields
}
func (*GetTopologyResponse) Descriptor
deprecated
func (*GetTopologyResponse) Descriptor() ([]byte, []int)
Deprecated: Use GetTopologyResponse.ProtoReflect.Descriptor instead.
func (*GetTopologyResponse) GetNodes ¶
func (x *GetTopologyResponse) GetNodes() []*TopologyNode
func (*GetTopologyResponse) GetVersion ¶
func (x *GetTopologyResponse) GetVersion() int64
func (*GetTopologyResponse) ProtoMessage ¶
func (*GetTopologyResponse) ProtoMessage()
func (*GetTopologyResponse) ProtoReflect ¶
func (x *GetTopologyResponse) ProtoReflect() protoreflect.Message
func (*GetTopologyResponse) Reset ¶
func (x *GetTopologyResponse) Reset()
func (*GetTopologyResponse) String ¶
func (x *GetTopologyResponse) String() string
type HealthChecker ¶
HealthChecker defines the interface for health check implementations.
type HealthInfo ¶
type HealthInfo struct {
Status HealthStatus `json:"status"`
LastChecked time.Time `json:"last_checked"`
Message string `json:"message,omitempty"`
Error string `json:"error,omitempty"`
// contains filtered or unexported fields
}
HealthInfo contains health status information for a node.
func NewHealthInfo ¶
func NewHealthInfo() *HealthInfo
NewHealthInfo creates a new health info with unknown status.
func (*HealthInfo) Get ¶
func (h *HealthInfo) Get() (HealthStatus, time.Time, string, string)
func (*HealthInfo) IsHealthy ¶
func (h *HealthInfo) IsHealthy() bool
func (*HealthInfo) String ¶
func (h *HealthInfo) String() string
func (*HealthInfo) Update ¶
func (h *HealthInfo) Update(status HealthStatus, message string, err error)
type HealthRequest ¶
type HealthRequest struct {
SenderId string `protobuf:"bytes,1,opt,name=sender_id,json=senderId,proto3" json:"sender_id,omitempty"`
// contains filtered or unexported fields
}
func (*HealthRequest) Descriptor
deprecated
func (*HealthRequest) Descriptor() ([]byte, []int)
Deprecated: Use HealthRequest.ProtoReflect.Descriptor instead.
func (*HealthRequest) GetSenderId ¶
func (x *HealthRequest) GetSenderId() string
func (*HealthRequest) ProtoMessage ¶
func (*HealthRequest) ProtoMessage()
func (*HealthRequest) ProtoReflect ¶
func (x *HealthRequest) ProtoReflect() protoreflect.Message
func (*HealthRequest) Reset ¶
func (x *HealthRequest) Reset()
func (*HealthRequest) String ¶
func (x *HealthRequest) String() string
type HealthResponse ¶
type HealthResponse struct {
NodeId string `protobuf:"bytes,1,opt,name=node_id,json=nodeId,proto3" json:"node_id,omitempty"`
Status string `protobuf:"bytes,2,opt,name=status,proto3" json:"status,omitempty"`
LastChecked int64 `protobuf:"varint,3,opt,name=last_checked,json=lastChecked,proto3" json:"last_checked,omitempty"`
Message string `protobuf:"bytes,4,opt,name=message,proto3" json:"message,omitempty"`
Error string `protobuf:"bytes,5,opt,name=error,proto3" json:"error,omitempty"`
// contains filtered or unexported fields
}
func (*HealthResponse) Descriptor
deprecated
func (*HealthResponse) Descriptor() ([]byte, []int)
Deprecated: Use HealthResponse.ProtoReflect.Descriptor instead.
func (*HealthResponse) GetError ¶
func (x *HealthResponse) GetError() string
func (*HealthResponse) GetLastChecked ¶
func (x *HealthResponse) GetLastChecked() int64
func (*HealthResponse) GetMessage ¶
func (x *HealthResponse) GetMessage() string
func (*HealthResponse) GetNodeId ¶
func (x *HealthResponse) GetNodeId() string
func (*HealthResponse) GetStatus ¶
func (x *HealthResponse) GetStatus() string
func (*HealthResponse) ProtoMessage ¶
func (*HealthResponse) ProtoMessage()
func (*HealthResponse) ProtoReflect ¶
func (x *HealthResponse) ProtoReflect() protoreflect.Message
func (*HealthResponse) Reset ¶
func (x *HealthResponse) Reset()
func (*HealthResponse) String ¶
func (x *HealthResponse) String() string
type HealthStatus ¶
type HealthStatus string
HealthStatus represents the health state of a node.
const ( HealthStatusHealthy HealthStatus = "healthy" HealthStatusUnhealthy HealthStatus = "unhealthy" HealthStatusUnknown HealthStatus = "unknown" )
type MeshServer ¶
type MeshServer struct {
UnimplementedMeshServiceServer
// contains filtered or unexported fields
}
MeshServer handles gRPC mesh service requests.
func NewMeshServer ¶
func NewMeshServer(node *Node) *MeshServer
NewMeshServer creates a new mesh server for the node.
func (*MeshServer) GetHealth ¶
func (ms *MeshServer) GetHealth(ctx context.Context, req *HealthRequest) (*HealthResponse, error)
GetHealth returns the health status of this node.
func (*MeshServer) GetNodeInfo ¶
func (ms *MeshServer) GetNodeInfo(ctx context.Context, req *NodeInfoRequest) (*NodeInfoResponse, error)
GetNodeInfo returns information about this node.
func (*MeshServer) GetTopology ¶
func (ms *MeshServer) GetTopology(ctx context.Context, req *GetTopologyRequest) (*GetTopologyResponse, error)
GetTopology returns the current topology.
func (*MeshServer) Ping ¶
func (ms *MeshServer) Ping(ctx context.Context, req *PingRequest) (*PingResponse, error)
Ping responds to ping requests.
func (*MeshServer) RegisterService ¶
func (ms *MeshServer) RegisterService(r ServiceRegistrar)
RegisterService adds a service registrar to be called when the server starts.
func (*MeshServer) SetTLSConfig ¶
func (ms *MeshServer) SetTLSConfig(tlsConfig *TLSConfig)
SetTLSConfig sets the TLS configuration for the server.
func (*MeshServer) SyncTopology ¶
func (ms *MeshServer) SyncTopology(ctx context.Context, req *TopologySyncRequest) (*TopologySyncResponse, error)
SyncTopology handles topology synchronization requests.
type MeshServiceClient ¶
type MeshServiceClient interface {
// Core mesh primitives
Ping(ctx context.Context, in *PingRequest, opts ...grpc.CallOption) (*PingResponse, error)
GetHealth(ctx context.Context, in *HealthRequest, opts ...grpc.CallOption) (*HealthResponse, error)
GetNodeInfo(ctx context.Context, in *NodeInfoRequest, opts ...grpc.CallOption) (*NodeInfoResponse, error)
// Topology operations
SyncTopology(ctx context.Context, in *TopologySyncRequest, opts ...grpc.CallOption) (*TopologySyncResponse, error)
GetTopology(ctx context.Context, in *GetTopologyRequest, opts ...grpc.CallOption) (*GetTopologyResponse, error)
}
MeshServiceClient is the client API for MeshService 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.
func NewMeshServiceClient ¶
func NewMeshServiceClient(cc grpc.ClientConnInterface) MeshServiceClient
type MeshServiceServer ¶
type MeshServiceServer interface {
// Core mesh primitives
Ping(context.Context, *PingRequest) (*PingResponse, error)
GetHealth(context.Context, *HealthRequest) (*HealthResponse, error)
GetNodeInfo(context.Context, *NodeInfoRequest) (*NodeInfoResponse, error)
// Topology operations
SyncTopology(context.Context, *TopologySyncRequest) (*TopologySyncResponse, error)
GetTopology(context.Context, *GetTopologyRequest) (*GetTopologyResponse, error)
// contains filtered or unexported methods
}
MeshServiceServer is the server API for MeshService service. All implementations must embed UnimplementedMeshServiceServer for forward compatibility.
type Node ¶
type Node struct {
ID string `json:"id"`
Name string `json:"name"`
Type NodeType `json:"type"`
Address string `json:"address"`
Services []ServiceInfo `json:"services,omitempty"`
Health *HealthInfo `json:"health"`
PeerManager *PeerManager `json:"-"`
MeshServer *MeshServer `json:"-"`
Topology *Topology `json:"-"`
TLSConfig *TLSConfig `json:"-"`
}
Node represents a node in the mesh network.
func NewSecureNode ¶
NewSecureNode is a convenience function that creates a node with TLS enabled.
func (*Node) CheckHealth ¶
func (n *Node) CheckHealth(ctx context.Context, checker HealthChecker) error
CheckHealth runs a health check using the provided checker.
func (*Node) EnableTLS ¶
EnableTLS enables TLS for the node using the specified certificate directory.
func (*Node) GetAllPeers ¶
GetAllPeers returns all connected peers.
func (*Node) GetHealth ¶
func (n *Node) GetHealth() (HealthStatus, string)
GetHealth returns the node's health status and message.
func (*Node) GetMeshNodes ¶
GetMeshNodes returns all nodes in the topology.
func (*Node) GetPeerHealth ¶
GetPeerHealth retrieves the health status of a peer.
func (*Node) GetPeerNodeInfo ¶
GetPeerNodeInfo retrieves node information from a peer.
func (*Node) GetTopologyVersion ¶
GetTopologyVersion returns the current topology version.
func (*Node) MarshalJSON ¶
MarshalJSON implements json.Marshaler.
func (*Node) RemovePeer ¶
RemovePeer removes a peer connection.
func (*Node) SetHealth ¶
func (n *Node) SetHealth(status HealthStatus, message string, err error)
SetHealth updates the node's health status.
func (*Node) StartServer ¶
StartServer starts the gRPC mesh server.
func (*Node) SyncTopology ¶
SyncTopology synchronizes topology with a specific peer.
func (*Node) SyncTopologyWithAllPeers ¶
SyncTopologyWithAllPeers synchronizes topology with all connected peers.
func (*Node) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler.
type NodeBuilder ¶
type NodeBuilder struct {
// contains filtered or unexported fields
}
NodeBuilder provides a fluent interface for creating nodes with required TLS.
func (*NodeBuilder) Build ¶
func (nb *NodeBuilder) Build() (*Node, error)
Build creates the node with TLS enabled.
func (*NodeBuilder) WithAddress ¶
func (nb *NodeBuilder) WithAddress(address string) *NodeBuilder
WithAddress sets the node address.
func (*NodeBuilder) WithCertDir ¶
func (nb *NodeBuilder) WithCertDir(certDir string) *NodeBuilder
WithCertDir sets the certificate directory.
func (*NodeBuilder) WithID ¶
func (nb *NodeBuilder) WithID(id string) *NodeBuilder
WithID sets the node ID.
func (*NodeBuilder) WithName ¶
func (nb *NodeBuilder) WithName(name string) *NodeBuilder
WithName sets the node name.
func (*NodeBuilder) WithServiceRegistration ¶
func (nb *NodeBuilder) WithServiceRegistration(r ServiceRegistrar) *NodeBuilder
WithServiceRegistration adds a callback to register gRPC services on the server.
func (*NodeBuilder) WithServices ¶
func (nb *NodeBuilder) WithServices(services ...ServiceInfo) *NodeBuilder
WithServices sets the services this node provides.
func (*NodeBuilder) WithTLSOptions ¶
func (nb *NodeBuilder) WithTLSOptions(opts *TLSOptions) *NodeBuilder
WithTLSOptions sets custom TLS options.
func (*NodeBuilder) WithType ¶
func (nb *NodeBuilder) WithType(nodeType NodeType) *NodeBuilder
WithType sets the node type.
type NodeInfo ¶
type NodeInfo struct {
ID string `json:"id"`
Name string `json:"name"`
Type NodeType `json:"type"`
Address string `json:"address"`
Services []ServiceInfo `json:"services,omitempty"`
JoinedAt time.Time `json:"joined_at"`
UpdatedAt time.Time `json:"updated_at"`
}
NodeInfo contains information about a node in the mesh topology.
type NodeInfoRequest ¶
type NodeInfoRequest struct {
SenderId string `protobuf:"bytes,1,opt,name=sender_id,json=senderId,proto3" json:"sender_id,omitempty"`
// contains filtered or unexported fields
}
func (*NodeInfoRequest) Descriptor
deprecated
func (*NodeInfoRequest) Descriptor() ([]byte, []int)
Deprecated: Use NodeInfoRequest.ProtoReflect.Descriptor instead.
func (*NodeInfoRequest) GetSenderId ¶
func (x *NodeInfoRequest) GetSenderId() string
func (*NodeInfoRequest) ProtoMessage ¶
func (*NodeInfoRequest) ProtoMessage()
func (*NodeInfoRequest) ProtoReflect ¶
func (x *NodeInfoRequest) ProtoReflect() protoreflect.Message
func (*NodeInfoRequest) Reset ¶
func (x *NodeInfoRequest) Reset()
func (*NodeInfoRequest) String ¶
func (x *NodeInfoRequest) String() string
type NodeInfoResponse ¶
type NodeInfoResponse struct {
Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"`
Type string `protobuf:"bytes,3,opt,name=type,proto3" json:"type,omitempty"`
Address string `protobuf:"bytes,4,opt,name=address,proto3" json:"address,omitempty"`
Health *HealthResponse `protobuf:"bytes,5,opt,name=health,proto3" json:"health,omitempty"`
// contains filtered or unexported fields
}
func (*NodeInfoResponse) Descriptor
deprecated
func (*NodeInfoResponse) Descriptor() ([]byte, []int)
Deprecated: Use NodeInfoResponse.ProtoReflect.Descriptor instead.
func (*NodeInfoResponse) GetAddress ¶
func (x *NodeInfoResponse) GetAddress() string
func (*NodeInfoResponse) GetHealth ¶
func (x *NodeInfoResponse) GetHealth() *HealthResponse
func (*NodeInfoResponse) GetId ¶
func (x *NodeInfoResponse) GetId() string
func (*NodeInfoResponse) GetName ¶
func (x *NodeInfoResponse) GetName() string
func (*NodeInfoResponse) GetType ¶
func (x *NodeInfoResponse) GetType() string
func (*NodeInfoResponse) ProtoMessage ¶
func (*NodeInfoResponse) ProtoMessage()
func (*NodeInfoResponse) ProtoReflect ¶
func (x *NodeInfoResponse) ProtoReflect() protoreflect.Message
func (*NodeInfoResponse) Reset ¶
func (x *NodeInfoResponse) Reset()
func (*NodeInfoResponse) String ¶
func (x *NodeInfoResponse) String() string
type NodeType ¶
type NodeType string
NodeType represents the type of node in the mesh.
const ( // NodeTypeGeneric is the default node type. NodeTypeGeneric NodeType = "generic" )
type Peer ¶
type Peer struct {
Info PeerInfo
Client MeshServiceClient
Conn *grpc.ClientConn
}
Peer represents a connected peer node.
type PeerInfo ¶
type PeerInfo struct {
ID string `json:"id"`
Address string `json:"address"`
Type NodeType `json:"type"`
}
PeerInfo contains information about a peer node.
type PeerManager ¶
type PeerManager struct {
// contains filtered or unexported fields
}
PeerManager manages connections to peer nodes.
func NewPeerManager ¶
func NewPeerManager(nodeID string) *PeerManager
NewPeerManager creates a new peer manager.
func (*PeerManager) AddPeer ¶
func (pm *PeerManager) AddPeer(info PeerInfo) error
AddPeer adds a new peer connection.
func (*PeerManager) Count ¶
func (pm *PeerManager) Count() int
Count returns the number of connected peers.
func (*PeerManager) GetAllPeers ¶
func (pm *PeerManager) GetAllPeers() []*Peer
GetAllPeers returns all connected peers.
func (*PeerManager) GetPeer ¶
func (pm *PeerManager) GetPeer(peerID string) (*Peer, bool)
GetPeer returns a peer by ID.
func (*PeerManager) GetPeerHealth ¶
func (pm *PeerManager) GetPeerHealth(ctx context.Context, peerID string) (*HealthResponse, error)
GetPeerHealth retrieves the health status of a peer.
func (*PeerManager) GetPeerNodeInfo ¶
func (pm *PeerManager) GetPeerNodeInfo(ctx context.Context, peerID string) (*NodeInfoResponse, error)
GetPeerNodeInfo retrieves node information from a peer.
func (*PeerManager) GetPeersByType ¶
func (pm *PeerManager) GetPeersByType(nodeType NodeType) []*Peer
GetPeersByType returns peers of a specific type.
func (*PeerManager) IsConnected ¶
func (pm *PeerManager) IsConnected(peerID string) bool
IsConnected checks if a peer connection is in READY state.
func (*PeerManager) PingPeer ¶
func (pm *PeerManager) PingPeer(ctx context.Context, peerID string) (*PingResponse, error)
PingPeer sends a ping request to a peer.
func (*PeerManager) RemovePeer ¶
func (pm *PeerManager) RemovePeer(peerID string) error
RemovePeer removes a peer connection.
func (*PeerManager) SetTLSConfig ¶
func (pm *PeerManager) SetTLSConfig(tlsConfig *TLSConfig)
SetTLSConfig sets the TLS configuration for peer connections.
func (*PeerManager) SyncTopology ¶
func (pm *PeerManager) SyncTopology(ctx context.Context, peerID string, version int64) (*TopologySyncResponse, error)
SyncTopology requests topology synchronization from a peer.
type PingHealthChecker ¶
type PingHealthChecker struct {
// contains filtered or unexported fields
}
PingHealthChecker performs simple ping-based health checks.
func NewPingHealthChecker ¶
func NewPingHealthChecker(name string) *PingHealthChecker
NewPingHealthChecker creates a new ping-based health checker.
func (*PingHealthChecker) Name ¶
func (p *PingHealthChecker) Name() string
type PingRequest ¶
type PingRequest struct {
SenderId string `protobuf:"bytes,1,opt,name=sender_id,json=senderId,proto3" json:"sender_id,omitempty"`
Timestamp int64 `protobuf:"varint,2,opt,name=timestamp,proto3" json:"timestamp,omitempty"`
// contains filtered or unexported fields
}
func (*PingRequest) Descriptor
deprecated
func (*PingRequest) Descriptor() ([]byte, []int)
Deprecated: Use PingRequest.ProtoReflect.Descriptor instead.
func (*PingRequest) GetSenderId ¶
func (x *PingRequest) GetSenderId() string
func (*PingRequest) GetTimestamp ¶
func (x *PingRequest) GetTimestamp() int64
func (*PingRequest) ProtoMessage ¶
func (*PingRequest) ProtoMessage()
func (*PingRequest) ProtoReflect ¶
func (x *PingRequest) ProtoReflect() protoreflect.Message
func (*PingRequest) Reset ¶
func (x *PingRequest) Reset()
func (*PingRequest) String ¶
func (x *PingRequest) String() string
type PingResponse ¶
type PingResponse struct {
ReceiverId string `protobuf:"bytes,1,opt,name=receiver_id,json=receiverId,proto3" json:"receiver_id,omitempty"`
Timestamp int64 `protobuf:"varint,2,opt,name=timestamp,proto3" json:"timestamp,omitempty"`
Success bool `protobuf:"varint,3,opt,name=success,proto3" json:"success,omitempty"`
// contains filtered or unexported fields
}
func (*PingResponse) Descriptor
deprecated
func (*PingResponse) Descriptor() ([]byte, []int)
Deprecated: Use PingResponse.ProtoReflect.Descriptor instead.
func (*PingResponse) GetReceiverId ¶
func (x *PingResponse) GetReceiverId() string
func (*PingResponse) GetSuccess ¶
func (x *PingResponse) GetSuccess() bool
func (*PingResponse) GetTimestamp ¶
func (x *PingResponse) GetTimestamp() int64
func (*PingResponse) ProtoMessage ¶
func (*PingResponse) ProtoMessage()
func (*PingResponse) ProtoReflect ¶
func (x *PingResponse) ProtoReflect() protoreflect.Message
func (*PingResponse) Reset ¶
func (x *PingResponse) Reset()
func (*PingResponse) String ¶
func (x *PingResponse) String() string
type Service ¶
type Service struct {
Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
Version string `protobuf:"bytes,2,opt,name=version,proto3" json:"version,omitempty"`
// contains filtered or unexported fields
}
func (*Service) Descriptor
deprecated
func (*Service) GetVersion ¶
func (*Service) ProtoMessage ¶
func (*Service) ProtoMessage()
func (*Service) ProtoReflect ¶
func (x *Service) ProtoReflect() protoreflect.Message
type ServiceClient ¶
type ServiceClient[T any] struct { // contains filtered or unexported fields }
ServiceClient provides a typed client for a specific service.
func NewServiceClient ¶
func NewServiceClient[T any](pool *ServiceClientPool, name, version string, newClient func(grpc.ClientConnInterface) T) *ServiceClient[T]
NewServiceClient creates a typed service client.
type ServiceClientPool ¶
type ServiceClientPool struct {
// contains filtered or unexported fields
}
ServiceClientPool manages gRPC connections to service providers.
func NewServiceClientPool ¶
func NewServiceClientPool(node *Node) *ServiceClientPool
NewServiceClientPool creates a connection pool for service clients.
func (*ServiceClientPool) Close ¶
func (p *ServiceClientPool) Close() error
Close closes all connections in the pool.
func (*ServiceClientPool) GetConn ¶
func (p *ServiceClientPool) GetConn(ctx context.Context, name, version string) (*grpc.ClientConn, error)
GetConn returns a connection to a provider of the specified service. Uses round-robin to distribute calls across providers.
type ServiceInfo ¶
ServiceInfo represents a service that a node provides. This is the internal representation; Service from mesh.pb.go is used for wire format.
type ServiceRegistrar ¶
ServiceRegistrar is called to register additional gRPC services.
type TLSConfig ¶
type TLSConfig struct {
Certificate tls.Certificate
CertPool *x509.CertPool
ServerName string
}
TLSConfig holds the TLS configuration for a node
func LoadOrGenerateTLS ¶
LoadOrGenerateTLS loads existing certificates or generates new ones
func LoadTLSConfig ¶
func LoadTLSConfig(opts *TLSOptions) (*TLSConfig, error)
LoadTLSConfig loads TLS configuration based on options
func (*TLSConfig) GetClientTLSConfig ¶
GetClientTLSConfig returns TLS configuration for the client
func (*TLSConfig) GetServerTLSConfig ¶
GetServerTLSConfig returns TLS configuration for the server
type TLSOptions ¶
type TLSOptions struct {
// Source determines where certificates come from
Source CertificateSource
// For file-based certificates
CertFile string
KeyFile string
CAFile string
// For environment-based certificates
CertEnvVar string
KeyEnvVar string
CAEnvVar string
// For Vault-based certificates (future)
VaultPath string
VaultRole string
// Validation options
VerifyChain bool
AllowExpired bool
RequiredSANs []string
}
TLSOptions configures how TLS certificates are loaded
func DefaultTLSOptions ¶
func DefaultTLSOptions(nodeID string, certDir string) *TLSOptions
DefaultTLSOptions returns secure default options
type Topology ¶
type Topology struct {
Nodes map[string]NodeInfo `json:"nodes"`
Version int64 `json:"version"`
UpdatedAt time.Time `json:"updated_at"`
// contains filtered or unexported fields
}
Topology maintains the mesh network topology.
func (*Topology) GetAllNodes ¶
GetAllNodes returns all nodes in the topology.
func (*Topology) GetNodesByService ¶
GetNodesByService returns all nodes that provide any version of the specified service.
func (*Topology) GetServiceProviders ¶
GetServiceProviders returns all nodes that provide the specified service.
func (*Topology) GetVersion ¶
GetVersion returns the topology version.
func (*Topology) RemoveNode ¶
RemoveNode removes a node from the topology.
func (*Topology) UpdateNode ¶
UpdateNode updates a node in the topology.
type TopologyNode ¶
type TopologyNode struct {
Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"`
Type string `protobuf:"bytes,3,opt,name=type,proto3" json:"type,omitempty"`
Address string `protobuf:"bytes,4,opt,name=address,proto3" json:"address,omitempty"`
JoinedAt int64 `protobuf:"varint,5,opt,name=joined_at,json=joinedAt,proto3" json:"joined_at,omitempty"`
UpdatedAt int64 `protobuf:"varint,6,opt,name=updated_at,json=updatedAt,proto3" json:"updated_at,omitempty"`
Services []*Service `protobuf:"bytes,7,rep,name=services,proto3" json:"services,omitempty"`
// contains filtered or unexported fields
}
func (*TopologyNode) Descriptor
deprecated
func (*TopologyNode) Descriptor() ([]byte, []int)
Deprecated: Use TopologyNode.ProtoReflect.Descriptor instead.
func (*TopologyNode) GetAddress ¶
func (x *TopologyNode) GetAddress() string
func (*TopologyNode) GetId ¶
func (x *TopologyNode) GetId() string
func (*TopologyNode) GetJoinedAt ¶
func (x *TopologyNode) GetJoinedAt() int64
func (*TopologyNode) GetName ¶
func (x *TopologyNode) GetName() string
func (*TopologyNode) GetServices ¶
func (x *TopologyNode) GetServices() []*Service
func (*TopologyNode) GetType ¶
func (x *TopologyNode) GetType() string
func (*TopologyNode) GetUpdatedAt ¶
func (x *TopologyNode) GetUpdatedAt() int64
func (*TopologyNode) ProtoMessage ¶
func (*TopologyNode) ProtoMessage()
func (*TopologyNode) ProtoReflect ¶
func (x *TopologyNode) ProtoReflect() protoreflect.Message
func (*TopologyNode) Reset ¶
func (x *TopologyNode) Reset()
func (*TopologyNode) String ¶
func (x *TopologyNode) String() string
type TopologySyncRequest ¶
type TopologySyncRequest struct {
SenderId string `protobuf:"bytes,1,opt,name=sender_id,json=senderId,proto3" json:"sender_id,omitempty"`
Version int64 `protobuf:"varint,2,opt,name=version,proto3" json:"version,omitempty"`
// contains filtered or unexported fields
}
Topology messages
func (*TopologySyncRequest) Descriptor
deprecated
func (*TopologySyncRequest) Descriptor() ([]byte, []int)
Deprecated: Use TopologySyncRequest.ProtoReflect.Descriptor instead.
func (*TopologySyncRequest) GetSenderId ¶
func (x *TopologySyncRequest) GetSenderId() string
func (*TopologySyncRequest) GetVersion ¶
func (x *TopologySyncRequest) GetVersion() int64
func (*TopologySyncRequest) ProtoMessage ¶
func (*TopologySyncRequest) ProtoMessage()
func (*TopologySyncRequest) ProtoReflect ¶
func (x *TopologySyncRequest) ProtoReflect() protoreflect.Message
func (*TopologySyncRequest) Reset ¶
func (x *TopologySyncRequest) Reset()
func (*TopologySyncRequest) String ¶
func (x *TopologySyncRequest) String() string
type TopologySyncResponse ¶
type TopologySyncResponse struct {
Version int64 `protobuf:"varint,1,opt,name=version,proto3" json:"version,omitempty"`
Nodes []*TopologyNode `protobuf:"bytes,2,rep,name=nodes,proto3" json:"nodes,omitempty"`
UpdatedAt int64 `protobuf:"varint,3,opt,name=updated_at,json=updatedAt,proto3" json:"updated_at,omitempty"`
// contains filtered or unexported fields
}
func (*TopologySyncResponse) Descriptor
deprecated
func (*TopologySyncResponse) Descriptor() ([]byte, []int)
Deprecated: Use TopologySyncResponse.ProtoReflect.Descriptor instead.
func (*TopologySyncResponse) GetNodes ¶
func (x *TopologySyncResponse) GetNodes() []*TopologyNode
func (*TopologySyncResponse) GetUpdatedAt ¶
func (x *TopologySyncResponse) GetUpdatedAt() int64
func (*TopologySyncResponse) GetVersion ¶
func (x *TopologySyncResponse) GetVersion() int64
func (*TopologySyncResponse) ProtoMessage ¶
func (*TopologySyncResponse) ProtoMessage()
func (*TopologySyncResponse) ProtoReflect ¶
func (x *TopologySyncResponse) ProtoReflect() protoreflect.Message
func (*TopologySyncResponse) Reset ¶
func (x *TopologySyncResponse) Reset()
func (*TopologySyncResponse) String ¶
func (x *TopologySyncResponse) String() string
type UnimplementedMeshServiceServer ¶
type UnimplementedMeshServiceServer struct{}
UnimplementedMeshServiceServer 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 (UnimplementedMeshServiceServer) GetHealth ¶
func (UnimplementedMeshServiceServer) GetHealth(context.Context, *HealthRequest) (*HealthResponse, error)
func (UnimplementedMeshServiceServer) GetNodeInfo ¶
func (UnimplementedMeshServiceServer) GetNodeInfo(context.Context, *NodeInfoRequest) (*NodeInfoResponse, error)
func (UnimplementedMeshServiceServer) GetTopology ¶
func (UnimplementedMeshServiceServer) GetTopology(context.Context, *GetTopologyRequest) (*GetTopologyResponse, error)
func (UnimplementedMeshServiceServer) Ping ¶
func (UnimplementedMeshServiceServer) Ping(context.Context, *PingRequest) (*PingResponse, error)
func (UnimplementedMeshServiceServer) SyncTopology ¶
func (UnimplementedMeshServiceServer) SyncTopology(context.Context, *TopologySyncRequest) (*TopologySyncResponse, error)
type UnsafeMeshServiceServer ¶
type UnsafeMeshServiceServer interface {
// contains filtered or unexported methods
}
UnsafeMeshServiceServer may be embedded to opt out of forward compatibility for this service. Use of this interface is not recommended, as added methods to MeshServiceServer will result in compilation errors.