Documentation
¶
Overview ¶
Package mobilerunner holds the rules shared by every surface that decides whether a mobile runner can be used and how it is reached over HTTP.
Index ¶
- Constants
- Variables
- func Credential(runner *core.Record) (string, error)
- func HTTPClient(runner *core.Record) *http.Client
- func IsQuickTunnelURL(runnerURL string) bool
- func NormalizeDeviceIDs(values []string) []string
- func OrganizationPublishedLoader(app core.App, orgID string) func() (bool, error)
- func RecentlyAlive(record *core.Record, now time.Time) bool
- func ResolveDevice(app core.App, id string) (device, runner *core.Record, err error)
- func ResolveRunner(app core.App, id string) (*core.Record, error)
- func RunnerIdentifier(app core.App, runner *core.Record) (string, error)
- func RunnerURL(runner *core.Record) string
- func SelectorHeartbeatTTL() time.Duration
- func SharedWith(runner *core.Record, orgPublished bool) bool
- func Transport(runner *core.Record) http.RoundTripper
- func URLUsable(runnerURL string) bool
- func ValidateDeviceAccess(app core.App, ownerID string, deviceIDs []string) error
Constants ¶
const CredentialSecretEnvVar = "CREDIMI_RUNNER_CREDENTIAL_SECRET"
CredentialSecretEnvVar names the secret every runner credential is derived from. Rotating it invalidates every runner credential until each runner's next registration or heartbeat delivers the new one.
const DefaultSelectorHeartbeatTTL = 60 * time.Second
DefaultSelectorHeartbeatTTL tolerates two missed heartbeats. The runner heartbeats every 30s, so a runner that has not reported for a minute is treated as unavailable by catalog surfaces. The lifecycle heartbeat timeout stays an hour because it drives the durable `online` flag, which must not flap.
const SelectorHeartbeatTTLEnv = "MOBILE_RUNNER_SELECTOR_HEARTBEAT_TTL"
Variables ¶
var ( ErrDeviceNotFound = errors.New("mobile device not found") ErrDeviceRunnerNotFound = errors.New("mobile device runner not found") ErrDeviceNotAccessible = errors.New("mobile device is not accessible") ErrRunnerNotFound = errors.New("mobile runner not found") )
var ErrCredentialSecretMissing = errors.New(CredentialSecretEnvVar + " is not set")
ErrCredentialSecretMissing reports that CredentialSecretEnvVar is not set.
Functions ¶
func Credential ¶
Credential returns the key Credimi presents to runner as Credimi-Api-Key: the lowercase hex HMAC-SHA256, keyed by CredentialSecretEnvVar, of "<record id>:<credential_generation>". Each runner gets its own value, and bumping credential_generation rotates it. Credimi never sends its internal admin key to a runner.
func HTTPClient ¶
HTTPClient returns the client every Credimi call to runner must use; see Transport.
func IsQuickTunnelURL ¶
func NormalizeDeviceIDs ¶
NormalizeDeviceIDs splits comma lists, normalizes, deduplicates and sorts device IDs.
func OrganizationPublishedLoader ¶
OrganizationPublishedLoader returns a function that reads the organization's published flag on first use and reuses it afterwards.
func RecentlyAlive ¶
RecentlyAlive reports whether a runner reported a heartbeat recently enough to be offered in a device selector. It answers "the runner was reaching Credimi a moment ago", which is what a catalog needs; whether the runner is reachable at execution time is decided by a live health check on the run path, not here.
func ResolveDevice ¶
ResolveDevice returns the mobile device at the canonified path id and its runner. It returns an error wrapping ErrDeviceNotFound when id is not a mobile device and ErrDeviceRunnerNotFound when its runner record is missing; any other error is a lookup failure.
func ResolveRunner ¶
ResolveRunner returns the mobile runner at the canonified path id. It returns an error wrapping ErrRunnerNotFound when id is not a mobile runner; any other error is a lookup failure.
func RunnerIdentifier ¶
RunnerIdentifier returns the normalized canonified path of a runner.
func SelectorHeartbeatTTL ¶
func SharedWith ¶
SharedWith reports whether another organization's runner may be used by an organization: only published runners are shared, and unpublished organizations only get admin-managed ones.
func Transport ¶
func Transport(runner *core.Record) http.RoundTripper
Transport returns the round tripper every Credimi call to runner must go through, or nil when the default transport is correct. Callers that own their own client (an activity setting its own timeout) use this instead of HTTPClient.
Admin-managed runners are operator infrastructure: they get the default transport, or the Cloudflare-resolving one for quick tunnels. A tenant chooses its runner's address, so tenant runners are reached only over https, without a proxy, and only at public addresses checked on every dial, which also covers redirects and rebinding hostnames. A rejected destination fails with an error wrapping safehttp.ErrBlockedDestination.
Types ¶
This section is empty.