Help us shape the future of Go! Take the 2026 Go Developer Survey

mobilerunner

package
v1.321.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 27, 2026 License: AGPL-3.0 Imports: 22 Imported by: 0

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

View Source
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.

View Source
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.

View Source
const SelectorHeartbeatTTLEnv = "MOBILE_RUNNER_SELECTOR_HEARTBEAT_TTL"

Variables

View Source
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")
)
View Source
var ErrCredentialSecretMissing = errors.New(CredentialSecretEnvVar + " is not set")

ErrCredentialSecretMissing reports that CredentialSecretEnvVar is not set.

Functions

func Credential

func Credential(runner *core.Record) (string, error)

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

func HTTPClient(runner *core.Record) *http.Client

HTTPClient returns the client every Credimi call to runner must use; see Transport.

func IsQuickTunnelURL

func IsQuickTunnelURL(runnerURL string) bool

func NormalizeDeviceIDs

func NormalizeDeviceIDs(values []string) []string

NormalizeDeviceIDs splits comma lists, normalizes, deduplicates and sorts device IDs.

func OrganizationPublishedLoader

func OrganizationPublishedLoader(app core.App, orgID string) func() (bool, error)

OrganizationPublishedLoader returns a function that reads the organization's published flag on first use and reuses it afterwards.

func RecentlyAlive

func RecentlyAlive(record *core.Record, now time.Time) bool

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

func ResolveDevice(app core.App, id string) (device, runner *core.Record, err error)

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

func ResolveRunner(app core.App, id string) (*core.Record, error)

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

func RunnerIdentifier(app core.App, runner *core.Record) (string, error)

RunnerIdentifier returns the normalized canonified path of a runner.

func RunnerURL

func RunnerURL(runner *core.Record) string

RunnerURL returns the runner base URL built from its ip and optional port.

func SelectorHeartbeatTTL

func SelectorHeartbeatTTL() time.Duration

func SharedWith

func SharedWith(runner *core.Record, orgPublished bool) bool

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.

func URLUsable

func URLUsable(runnerURL string) bool

URLUsable reports whether a runner URL can be called at all. A catalog surface that trusts heartbeats still has to exclude a runner whose stored URL is malformed: it reports healthy while being uncallable.

func ValidateDeviceAccess

func ValidateDeviceAccess(app core.App, ownerID string, deviceIDs []string) error

ValidateDeviceAccess checks that every device exists, has a runner and is either owned by ownerID or shared with that organization.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL