Documentation
¶
Overview ¶
Package service contains all the services used by XrayR To implement a service, one needs to implement the interface below.
Index ¶
- Constants
- func CleanupContext(ctx context.Context) (context.Context, context.CancelFunc)
- func CloseContext(ctx context.Context, runtime Service) error
- func JoinContext(ctx context.Context, owner any) error
- func RecordSnapshotSyncApplied(target any, scope SnapshotSyncScope)
- func SortRuntimeSnapshots(snapshots []RuntimeSnapshot)
- func StartContext(ctx context.Context, runtime Service) error
- func WithDefaultTimeout(ctx context.Context, timeout time.Duration) (context.Context, context.CancelFunc)
- type ContextCloser
- type ContextJoiner
- type ContextStarter
- type FailureStage
- type Readiness
- type ReadinessReason
- type ReloadPhase
- type ReloadSnapshot
- type Restart
- type RuntimeHealthSnapshot
- type RuntimeHealthState
- func (s *RuntimeHealthState) RecordFailure(stage FailureStage, at time.Time)
- func (s *RuntimeHealthState) RecordSuccessfulSync(at time.Time)
- func (s *RuntimeHealthState) SetCertificateExpiry(expiry time.Time)
- func (s *RuntimeHealthState) SetTrafficBacklog(backlog int)
- func (s *RuntimeHealthState) Snapshot() RuntimeHealthSnapshot
- type RuntimeKind
- type RuntimeLifecycle
- type RuntimeMode
- type RuntimeSnapshot
- type RuntimeSnapshotProvider
- type Service
- type SnapshotSyncAppliedRecorder
- type SnapshotSyncScope
- type SnapshotSyncSource
- type SnapshotSyncSubmitter
- type SnapshotSyncTrigger
- type WebSocketSnapshot
- type WebSocketSnapshotProvider
- type WebSocketState
Constants ¶
View Source
const ( DefaultStartTimeout = 2 * time.Minute DefaultCloseTimeout = 30 * time.Second DefaultJoinTimeout = 30 * time.Second DefaultSyncTimeout = 30 * time.Second )
View Source
const DefaultReadinessStaleAfter = 3 * time.Minute
Variables ¶
This section is empty.
Functions ¶
func CleanupContext ¶
func RecordSnapshotSyncApplied ¶
func RecordSnapshotSyncApplied(target any, scope SnapshotSyncScope)
func SortRuntimeSnapshots ¶
func SortRuntimeSnapshots(snapshots []RuntimeSnapshot)
func WithDefaultTimeout ¶
Types ¶
type ContextCloser ¶
type ContextJoiner ¶
type ContextStarter ¶
type FailureStage ¶
type FailureStage string
const ( FailureStageNone FailureStage = "none" FailureStageStart FailureStage = "start" FailureStageSync FailureStage = "sync" FailureStageWebSocket FailureStage = "websocket" FailureStageReconcile FailureStage = "reconcile" FailureStageReport FailureStage = "report" FailureStageCertificate FailureStage = "certificate" FailureStageRuntime FailureStage = "runtime" FailureStageClose FailureStage = "close" FailureStageCleanup FailureStage = "cleanup" )
type Readiness ¶
type Readiness struct {
Ready bool
Degraded bool
Reasons []ReadinessReason
}
func EvaluateReadiness ¶
type ReadinessReason ¶
type ReadinessReason string
const ( ReadinessReasonShutdown ReadinessReason = "shutdown" ReadinessReasonLifecycle ReadinessReason = "lifecycle" ReadinessReasonCleanupPending ReadinessReason = "cleanup_pending" ReadinessReasonSyncStale ReadinessReason = "sync_stale" ReadinessReasonCertificateExpired ReadinessReason = "certificate_expired" )
type ReloadPhase ¶
type ReloadPhase string
const ( ReloadPhaseNone ReloadPhase = "none" ReloadPhaseCandidate ReloadPhase = "candidate" ReloadPhaseStop ReloadPhase = "stop" ReloadPhaseStart ReloadPhase = "start" ReloadPhaseCommit ReloadPhase = "commit" ReloadPhaseRollback ReloadPhase = "rollback" )
type ReloadSnapshot ¶
type ReloadSnapshot struct {
Phase ReloadPhase
Attempts uint64
Successes uint64
Failures uint64
LastCandidateDuration time.Duration
LastStopDuration time.Duration
LastStartDuration time.Duration
LastCommitDuration time.Duration
LastRollbackDuration time.Duration
LastInterruptionDuration time.Duration
}
type RuntimeHealthSnapshot ¶
type RuntimeHealthState ¶
type RuntimeHealthState struct {
// contains filtered or unexported fields
}
func (*RuntimeHealthState) RecordFailure ¶
func (s *RuntimeHealthState) RecordFailure(stage FailureStage, at time.Time)
func (*RuntimeHealthState) RecordSuccessfulSync ¶
func (s *RuntimeHealthState) RecordSuccessfulSync(at time.Time)
func (*RuntimeHealthState) SetCertificateExpiry ¶
func (s *RuntimeHealthState) SetCertificateExpiry(expiry time.Time)
func (*RuntimeHealthState) SetTrafficBacklog ¶
func (s *RuntimeHealthState) SetTrafficBacklog(backlog int)
func (*RuntimeHealthState) Snapshot ¶
func (s *RuntimeHealthState) Snapshot() RuntimeHealthSnapshot
type RuntimeKind ¶
type RuntimeKind string
const ( RuntimeKindPanel RuntimeKind = "panel" RuntimeKindMachine RuntimeKind = "machine" RuntimeKindController RuntimeKind = "controller" RuntimeKindAnyTLS RuntimeKind = "anytls" RuntimeKindTUIC RuntimeKind = "tuic" RuntimeKindHysteria2 RuntimeKind = "hysteria2" )
type RuntimeLifecycle ¶
type RuntimeLifecycle string
const ( RuntimeLifecycleStopped RuntimeLifecycle = "stopped" RuntimeLifecycleStarting RuntimeLifecycle = "starting" RuntimeLifecycleRunning RuntimeLifecycle = "running" RuntimeLifecycleReloading RuntimeLifecycle = "reloading" RuntimeLifecycleStopping RuntimeLifecycle = "stopping" RuntimeLifecycleFailed RuntimeLifecycle = "failed" RuntimeLifecycleFailedOwned RuntimeLifecycle = "failed-owned" RuntimeLifecycleRetiring RuntimeLifecycle = "retiring" RuntimeLifecycleClosed RuntimeLifecycle = "closed" )
type RuntimeMode ¶
type RuntimeMode string
const ( RuntimeModeStatic RuntimeMode = "static" RuntimeModeMachine RuntimeMode = "machine" )
type RuntimeSnapshot ¶
type RuntimeSnapshot struct {
Kind RuntimeKind
Mode RuntimeMode
NodeID int
Lifecycle RuntimeLifecycle
TopologyGeneration uint64
LastSuccessfulSync time.Time
WebSocket WebSocketState
LastFailureStage FailureStage
LastFailureAt time.Time
CleanupPending bool
TrafficReportBacklog int
CertificateExpiresAt time.Time
Reload ReloadSnapshot
Children []RuntimeSnapshot
}
func (RuntimeSnapshot) Clone ¶
func (s RuntimeSnapshot) Clone() RuntimeSnapshot
type RuntimeSnapshotProvider ¶
type RuntimeSnapshotProvider interface {
ObservabilitySnapshot() RuntimeSnapshot
}
type SnapshotSyncAppliedRecorder ¶
type SnapshotSyncAppliedRecorder interface {
RecordSnapshotSyncApplied(SnapshotSyncScope)
}
SnapshotSyncAppliedRecorder commits fetched candidates only after the runtime has successfully applied the corresponding authoritative snapshot.
type SnapshotSyncScope ¶
type SnapshotSyncScope uint8
SnapshotSyncScope identifies authoritative panel snapshots that need refresh. Values are flags so burst triggers can be merged without an unbounded queue.
const ( SnapshotSyncNode SnapshotSyncScope = 1 << iota SnapshotSyncUsers SnapshotSyncRules SnapshotSyncAll = SnapshotSyncNode | SnapshotSyncUsers | SnapshotSyncRules )
func (SnapshotSyncScope) Includes ¶
func (scope SnapshotSyncScope) Includes(required SnapshotSyncScope) bool
func (SnapshotSyncScope) Valid ¶
func (scope SnapshotSyncScope) Valid() bool
type SnapshotSyncSource ¶
type SnapshotSyncSource string
const ( SnapshotSyncSourceWebSocket SnapshotSyncSource = "websocket" SnapshotSyncSourceReconnect SnapshotSyncSource = "reconnect" SnapshotSyncSourceParseError SnapshotSyncSource = "parse_error" SnapshotSyncSourcePolling SnapshotSyncSource = "polling" )
type SnapshotSyncSubmitter ¶
type SnapshotSyncSubmitter interface {
SubmitSnapshotSync(SnapshotSyncTrigger)
}
SnapshotSyncSubmitter accepts non-blocking authoritative snapshot triggers. Implementations must bound and coalesce pending work.
type SnapshotSyncTrigger ¶
type SnapshotSyncTrigger struct {
Scope SnapshotSyncScope
Source SnapshotSyncSource
OccurredAt time.Time
}
type WebSocketSnapshot ¶
type WebSocketSnapshot struct {
State WebSocketState
LastFailureAt time.Time
}
type WebSocketSnapshotProvider ¶
type WebSocketSnapshotProvider interface {
WebSocketObservabilitySnapshot() WebSocketSnapshot
}
type WebSocketState ¶
type WebSocketState string
const ( WebSocketDisabled WebSocketState = "disabled" WebSocketDisconnected WebSocketState = "disconnected" WebSocketConnected WebSocketState = "connected" WebSocketDegraded WebSocketState = "degraded" )
Directories
¶
| Path | Synopsis |
|---|---|
|
Package controller Package generate the InboundConfig used by add inbound
|
Package controller Package generate the InboundConfig used by add inbound |
|
internal
|
|
Click to show internal directories.
Click to hide internal directories.