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 AgentEnabled(runner *core.Record) bool
- func AgentNamespace(runnerRecordID string) string
- func AgentNamespaceReady(runner *core.Record) bool
- func AgentNamespaceServed(runnerID string) bool
- func Credential(runner *core.Record) (string, error)
- func HTTPClient(runner *core.Record) *http.Client
- func IsQuickTunnelURL(runnerURL string) bool
- func MarkAgentNamespaceReady(app core.App, runnerID string) error
- 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 SetAgentNamespaceServed(runnerID string, served bool)
- 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 AgentNamespaceReadyField = "agent_namespace_ready"
AgentNamespaceReadyField is the hidden mobile_runners field where Credimi records that it prepared the runner's agent namespace, so a restarted Credimi keeps answering heartbeats with the namespace.
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 AgentEnabled ¶ added in v1.330.0
AgentEnabled reports whether runner serves action author sessions: its agent is enabled and the runner is not disabled.
func AgentNamespace ¶ added in v1.330.0
AgentNamespace is the Temporal namespace where the action author sessions of the runner with record ID runnerRecordID run.
func AgentNamespaceReady ¶ added in v1.330.0
AgentNamespaceReady reports whether runner's agent may serve its namespace: the agent is enabled and Credimi prepared the namespace, in this process or in an earlier one (AgentNamespaceReadyField).
func AgentNamespaceServed ¶ added in v1.330.0
AgentNamespaceServed reports whether this process runs the workers of the agent namespace of the runner with record ID runnerID.
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. Requests carry the caller's trace context, so the runner's spans join the Credimi trace.
func IsQuickTunnelURL ¶
func MarkAgentNamespaceReady ¶ added in v1.330.0
MarkAgentNamespaceReady sets AgentNamespaceReadyField on the runner with record ID runnerID while its agent is enabled and it is not disabled. It writes the column alone, so record hooks don't run again.
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 SetAgentNamespaceServed ¶ added in v1.330.0
SetAgentNamespaceServed records whether this process runs the workers of the agent namespace of the runner with record ID runnerID.
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.