Documentation
¶
Index ¶
- func HashToken(token string) string
- type Config
- type CreatePeerInput
- type FederatedRelay
- type HealthDTO
- type Peer
- type PeerStatus
- type PublicRelayDTO
- type RelaySource
- type Service
- func (s *Service) PublicHealth(ctx context.Context) HealthDTO
- func (s *Service) PublicRelays(ctx context.Context) ([]PublicRelayDTO, error)
- func (s *Service) RegisterPeerToken(peerID int64, token string)
- func (s *Service) Start(ctx context.Context)
- func (s *Service) Store() *Store
- func (s *Service) SyncAll(ctx context.Context)
- func (s *Service) SyncPeer(ctx context.Context, id int64) error
- type Store
- func (s *Store) Create(ctx context.Context, in CreatePeerInput) (Peer, error)
- func (s *Store) Delete(ctx context.Context, id int64) error
- func (s *Store) Get(ctx context.Context, id int64) (Peer, error)
- func (s *Store) List(ctx context.Context) ([]Peer, error)
- func (s *Store) ListFederatedRelays(ctx context.Context) ([]FederatedRelay, error)
- func (s *Store) ReplaceFederatedRelays(ctx context.Context, peerID int64, relays []FederatedRelay) error
- func (s *Store) UpdateStatus(ctx context.Context, id int64, status PeerStatus, errMsg *string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Config ¶
type Config struct {
Store *Store
Relays RelaySource
Version string
SyncInterval time.Duration
Log *slog.Logger
HTTPClient *http.Client
}
Config configures the federation service.
type CreatePeerInput ¶
CreatePeerInput is input for registering a new peer panel.
type FederatedRelay ¶
type FederatedRelay struct {
ID int64 `json:"id"`
PeerID int64 `json:"peer_id"`
PeerName string `json:"peer_name,omitempty"`
RemoteName string `json:"remote_name"`
PublicHost string `json:"public_host"`
Region string `json:"region,omitempty"`
Health string `json:"health"`
LastSyncAt time.Time `json:"last_sync_at"`
}
FederatedRelay represents a relay announced by a peered RD Panel.
type HealthDTO ¶
type HealthDTO struct {
Status string `json:"status"`
Version string `json:"version"`
ActiveRelays int `json:"active_relays"`
TimestampNano int64 `json:"timestamp_nano"`
}
HealthDTO is the response to /api/v1/federation/health.
type Peer ¶
type Peer struct {
ID int64 `json:"id"`
Name string `json:"name"`
APIURL string `json:"api_url"`
TokenHash string `json:"-"`
SyncRelays bool `json:"sync_relays"`
Status PeerStatus `json:"status"`
LastSyncAt *time.Time `json:"last_sync_at,omitempty"`
LastError *string `json:"last_error,omitempty"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
Peer represents an external peered RD Panel instance.
type PeerStatus ¶
type PeerStatus string
PeerStatus is the connection status of a peered RD Panel.
const ( StatusUnknown PeerStatus = "unknown" StatusActive PeerStatus = "active" StatusUnreachable PeerStatus = "unreachable" )
type PublicRelayDTO ¶
type PublicRelayDTO struct {
Name string `json:"name"`
PublicHost string `json:"public_host"`
Region string `json:"region,omitempty"`
Health string `json:"health"`
}
PublicRelayDTO is what a panel announces to peers.
type RelaySource ¶
RelaySource provides active local relays to announce.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service manages federation peering, relay synchronization and public federation endpoints.
func (*Service) PublicHealth ¶
PublicHealth returns local health for peering verification.
func (*Service) PublicRelays ¶
func (s *Service) PublicRelays(ctx context.Context) ([]PublicRelayDTO, error)
PublicRelays returns local active relays for peering peers.
func (*Service) RegisterPeerToken ¶
RegisterPeerToken caches the plaintext token in-memory for outgoing sync requests.
type Store ¶
Store persists federation peers and announced relays.
func (*Store) ListFederatedRelays ¶
func (s *Store) ListFederatedRelays(ctx context.Context) ([]FederatedRelay, error)
ListFederatedRelays returns all federated relays from all active peers.
func (*Store) ReplaceFederatedRelays ¶
func (s *Store) ReplaceFederatedRelays(ctx context.Context, peerID int64, relays []FederatedRelay) error
ReplaceFederatedRelays atomically replaces the relays associated with a peer.
func (*Store) UpdateStatus ¶
func (s *Store) UpdateStatus(ctx context.Context, id int64, status PeerStatus, errMsg *string) error
UpdateStatus records a peer's sync attempt and current connectivity status.