Documentation
¶
Overview ¶
Package turnruntime owns TURN settings, shared account budgets and demand-driven discovery.
Index ¶
- Constants
- Variables
- type AccountSettings
- type Cache
- type Capability
- type CloudflareAnalytics
- type CloudflareCredentials
- type CoturnCredentials
- type Dependencies
- type Event
- type HTTPClient
- type ManagedPolicy
- type ManagedSettings
- type ManualSettings
- type ProfileSettings
- type Runtime
- func (runtime *Runtime) Close() error
- func (runtime *Runtime) Configure(settings Settings) error
- func (runtime *Runtime) ForShare(ctx context.Context, relays []relayprofile.Candidate) (*Selection, func())
- func (runtime *Runtime) QueryUsage(ctx context.Context, account string, first, last time.Time) (Usage, error)
- func (runtime *Runtime) Status() []Status
- type Selection
- type ServiceIdentity
- type SessionSubject
- type Settings
- type StaticCredentials
- type Status
- type TrafficUsage
- type Usage
Constants ¶
const ( MaximumProfiles = 8 MaximumAccounts = 8 MaximumOutstandingLeases = 32 IssuanceTimeout = 15 * time.Second )
const ( StaticIssuer = "static" CloudflareIssuer = "cloudflare" CoturnIssuer = "coturn" )
const DelegationNotice = "" /* 214-byte string literal not displayed */
const (
MaximumManagedServices = 64
)
Variables ¶
Functions ¶
This section is empty.
Types ¶
type AccountSettings ¶
type AccountSettings struct {
ID string `json:"id"`
Provider string `json:"provider"`
Issuer string `json:"issuer"`
LocalBudgetBytes uint64 `json:"local_budget_bytes"`
Credentials json.RawMessage `json:"credentials"`
Analytics *CloudflareAnalytics `json:"analytics,omitempty"`
}
type Cache ¶
type Cache interface {
Load(relayprofile.Candidate) (*Capability, error)
Save(context.Context, relayprofile.Candidate, Capability, time.Time) error
}
Cache is optional. Runtime authority changes do not depend on durable writes.
type Capability ¶
Capability is a deployment observation, never a credential or a user policy.
func (Capability) Validate ¶
func (capability Capability) Validate() error
type CloudflareAnalytics ¶
type CloudflareCredentials ¶
type CoturnCredentials ¶
type CoturnCredentials struct {
LifetimeSeconds uint32 `json:"lifetime_seconds,omitempty"`
}
type Dependencies ¶
type Dependencies struct {
Client HTTPClient
Now func() time.Time
Observe func(Event)
Cache Cache
}
type Event ¶
type Event struct {
At time.Time
Identity ServiceIdentity
Subject SessionSubject
Revision uint64
ProfileRevision uint64
Milestone string
ResourceID string
Attempt int
Reason string
Usage TrafficUsage
ProviderRevocationConfirmed bool
}
type ManagedPolicy ¶
type ManagedPolicy struct {
RelayURL string `json:"relay_url"`
LocalBudgetBytes uint64 `json:"local_budget_bytes"`
}
func (ManagedPolicy) Validate ¶
func (policy ManagedPolicy) Validate() error
type ManagedSettings ¶
type ManagedSettings struct {
Relays []relayprofile.Candidate
Policies []ManagedPolicy
}
ManagedSettings projects deployment authority from the application's relay profiles. TURN does not own relay selection, frontend settings or enrollment.
func (ManagedSettings) Validate ¶
func (settings ManagedSettings) Validate() error
type ManualSettings ¶
type ManualSettings struct {
Accounts []AccountSettings `json:"accounts"`
Profiles []ProfileSettings `json:"profiles"`
}
ManualSettings is the persisted, device-owned part of TURN settings.
func (ManualSettings) Clone ¶
func (settings ManualSettings) Clone() ManualSettings
func (ManualSettings) Validate ¶
func (settings ManualSettings) Validate() error
type ProfileSettings ¶
type Runtime ¶
type Runtime struct {
// contains filtered or unexported fields
}
Runtime owns account ledgers and discovery for one Engine lifetime. Settings replacement never replaces this owner or resets its accumulated usage.
func (*Runtime) Configure ¶
Configure validates both manual and managed settings before publishing either. It does not contact issuers; existing leases retain their issuing source.
func (*Runtime) ForShare ¶
func (runtime *Runtime) ForShare(ctx context.Context, relays []relayprofile.Candidate) (*Selection, func())
ForShare binds the selected deployments and registers discovery demand without waiting for remote discovery. Releasing one share cannot stop another's worker.
func (*Runtime) QueryUsage ¶
type Selection ¶
type Selection struct {
// contains filtered or unexported fields
}
type ServiceIdentity ¶
type ServiceIdentity struct{ Provider, Account, Profile string }
ServiceIdentity and SessionSubject retain attribution without exposing provider configuration.
type SessionSubject ¶
type SessionSubject struct{ SessionID, PathID [16]byte }
type Settings ¶
type Settings struct {
Manual ManualSettings
Managed ManagedSettings
}
Settings is one desired configuration. Discovered capabilities are observations, not user settings, so a refresh cannot overwrite a budget or restore authority.
type StaticCredentials ¶
type TrafficUsage ¶
type TrafficUsage struct{ Payload, Useful, TransportSent, TransportReceived uint64 }
TrafficUsage separates accepted application traffic from useful file content and socket accounting.