zoobzio February 17, 2025 Edit this page

Types Reference

This document describes the core types in aegis.

Node

type Node struct {
    ID          string
    Name        string
    Type        NodeType
    Address     string
    Services    []ServiceInfo
    Health      *HealthInfo
    PeerManager *PeerManager
    MeshServer  *MeshServer
    Topology    *Topology
    TLSConfig   *TLSConfig
}
FieldTypeDescription
IDstringUnique identifier, used in certificates
NamestringHuman-readable label
TypeNodeTypeClassification (e.g., gateway, worker)
AddressstringHost:port for connections
Services[]ServiceInfoServices this node provides
Health*HealthInfoCurrent health status
PeerManager*PeerManagerManages outgoing connections
MeshServer*MeshServergRPC server for incoming connections
Topology*TopologyView of mesh membership
TLSConfig*TLSConfigCertificates and TLS settings

NodeType

type NodeType string

const (
    NodeTypeGeneric NodeType = "generic"
)

Node classification. Applications can define custom types.


NodeInfo

type NodeInfo struct {
    ID        string
    Name      string
    Type      NodeType
    Address   string
    Services  []ServiceInfo
    JoinedAt  time.Time
    UpdatedAt time.Time
}
FieldTypeDescription
IDstringNode identifier
NamestringNode name
TypeNodeTypeNode type
AddressstringNode address
Services[]ServiceInfoServices the node provides
JoinedAttime.TimeWhen node joined topology
UpdatedAttime.TimeLast update timestamp

ServiceInfo

type ServiceInfo struct {
    Name    string
    Version string
}
FieldTypeDescription
NamestringService name (e.g., "identity")
VersionstringService version (e.g., "v1")

PeerInfo

type PeerInfo struct {
    ID      string
    Type    NodeType
    Address string
}
FieldTypeDescription
IDstringPeer node ID
TypeNodeTypePeer node type
AddressstringPeer address for connection

Peer

type Peer struct {
    Info   PeerInfo
    Client MeshServiceClient
    Conn   *grpc.ClientConn
}
FieldTypeDescription
InfoPeerInfoPeer metadata
ClientMeshServiceClientgRPC client for mesh operations
Conn*grpc.ClientConnUnderlying connection

Topology

type Topology struct {
    Nodes     map[string]NodeInfo
    Version   int64
    UpdatedAt time.Time
}
FieldTypeDescription
Nodesmap[string]NodeInfoNode ID to info mapping
Versionint64Monotonically increasing version
UpdatedAttime.TimeLast modification time

Caller

type Caller struct {
    NodeID      string
    Certificate *x509.Certificate
}
FieldTypeDescription
NodeIDstringCalling node's ID (from certificate CN)
Certificate*x509.CertificateFull client certificate

HealthInfo

type HealthInfo struct {
    Status      HealthStatus
    LastChecked time.Time
    Message     string
    Error       string
}
FieldTypeDescription
StatusHealthStatusCurrent status
LastCheckedtime.TimeWhen last checked
MessagestringHuman-readable message
ErrorstringError message if unhealthy

HealthStatus

type HealthStatus string

const (
    HealthStatusHealthy   HealthStatus = "healthy"
    HealthStatusUnhealthy HealthStatus = "unhealthy"
    HealthStatusUnknown   HealthStatus = "unknown"
)

HealthChecker

type HealthChecker interface {
    Check(ctx context.Context) error
    Name() string
}

Interface for health check implementations.


TLSOptions

type TLSOptions struct {
    Source       CertificateSource
    CertFile     string
    KeyFile      string
    CAFile       string
    CertEnvVar   string
    KeyEnvVar    string
    CAEnvVar     string
    VaultPath    string
    VaultRole    string
    VerifyChain  bool
    AllowExpired bool
    RequiredSANs []string
}
FieldTypeDescription
SourceCertificateSourceWhere to load certificates from
CertFilestringPath to certificate (file source)
KeyFilestringPath to private key (file source)
CAFilestringPath to CA certificate (file source)
CertEnvVarstringEnv var for certificate (env source)
KeyEnvVarstringEnv var for private key (env source)
CAEnvVarstringEnv var for CA certificate (env source)
VaultPathstringVault path (vault source, future)
VaultRolestringVault role (vault source, future)
VerifyChainboolVerify full certificate chain
AllowExpiredboolAccept expired certificates
RequiredSANs[]stringRequired Subject Alternative Names

CertificateSource

type CertificateSource string

const (
    CertSourceFile  CertificateSource = "file"
    CertSourceEnv   CertificateSource = "env"
    CertSourceVault CertificateSource = "vault"
)

TLSConfig

type TLSConfig struct {
    Certificate tls.Certificate
    CertPool    *x509.CertPool
    // internal fields
}
FieldTypeDescription
Certificatetls.CertificateNode's certificate and key
CertPool*x509.CertPoolTrusted CA certificates

Methods:

  • GetServerTLSConfig() *tls.Config — Returns server TLS config
  • GetClientTLSConfig(serverName string) *tls.Config — Returns client TLS config

ServiceRegistrar

type ServiceRegistrar func(*grpc.Server)

Callback to register gRPC services on the server.


Error Sentinels

var (
    ErrNoProviders   = errors.New("no providers available for service")
    ErrNoTLSConfig   = errors.New("node has no TLS configuration")
    ErrNoPeerInfo    = errors.New("no peer info in context")
    ErrNoTLSInfo     = errors.New("no TLS info in peer")
    ErrNoCertificate = errors.New("no client certificate")
)

Next Steps