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

runtimecontext

package
v1.0.67-beta.1 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2026 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Overview

Package runtimecontext supplies an optional, process-scoped request context.

Index

Constants

View Source
const (
	HeaderName     = requestmeta.DingTalkExtHeader
	PayloadVersion = runtimepayload.PayloadVersion
	Environment    = "online"
)
View Source
const MaxAgentJSONBytes = 256 * 1024

Variables

This section is empty.

Functions

This section is empty.

Types

type AgentSnapshot

type AgentSnapshot struct {
	State         State  `json:"state"`
	ErrorCode     int32  `json:"error_code"`
	ErrorCategory string `json:"error_category,omitempty"`
	AgentID       int64  `json:"agent_id"`
	OS            string `json:"os,omitempty"`
	ExecutionMode string `json:"execution_mode,omitempty"`
	// contains filtered or unexported fields
}

AgentSnapshot is a process-scoped value, separate from the existing agentcode. The SDK object stays private; JSON returns a defensive copy for telemetry only.

func AgentSnapshotForTest

func AgentSnapshotForTest(raw []byte, code int32) AgentSnapshot

AgentSnapshotForTest supplies a parsed SDK object to cross-package tests.

func ResolveAgent

func ResolveAgent() AgentSnapshot

ResolveAgent collects full_info=0 in the original CLI process once. Timeout publishes a final snapshot; a late native result is released and discarded.

func (AgentSnapshot) GoString

func (a AgentSnapshot) GoString() string

func (AgentSnapshot) JSON

func (a AgentSnapshot) JSON() json.RawMessage

func (AgentSnapshot) String

func (a AgentSnapshot) String() string

type Result

type Result struct {
	State          State         `json:"state"`
	PayloadVersion string        `json:"payload_version"`
	Environment    string        `json:"environment"`
	Elapsed        time.Duration `json:"-"`
	ErrorCategory  string        `json:"error_category,omitempty"`
	// contains filtered or unexported fields
}

Result is the immutable process result. Sensitive values stay private and cannot be serialized or formatted accidentally.

func ReadyResultForTest

func ReadyResultForTest(value string) Result

ReadyResultForTest constructs a ready result for cross-package tests. Production code must obtain Result values from Resolve.

func Resolve

func Resolve() Result

Resolve initializes and returns the process-scoped context. It never retries: every caller observes the same immutable outcome.

func ResultWithAgentForTest

func ResultWithAgentForTest(token string, raw []byte, code int32) Result

ResultWithAgentForTest exercises request assembly without loading the SDK.

func (Result) AttachToURL

func (r Result) AttachToURL(rawURL string) (string, bool)

AttachToURL attaches the private runtime value to a login authorization URL. The URL may be opened in a browser or shown as a manual login link. Callers must never send it to diagnostic logs or persist it as application state.

func (Result) DiagnosticDetail

func (r Result) DiagnosticDetail() map[string]any

DiagnosticDetail returns redacted, stable diagnostic fields.

func (Result) GoString

func (r Result) GoString() string

func (Result) HeaderValue

func (r Result) HeaderValue() (string, bool)

HeaderValue composes independent UMID and Agent results into a bounded header. Missing or failed Agent collection is represented by the integer agent_id=0.

func (Result) String

func (r Result) String() string

type State

type State string
const (
	AgentUnknown   State = "unknown"
	AgentDegraded  State = "config_degraded"
	AgentInvalid   State = "parse_error"
	AgentOversized State = "oversized"
)
const (
	StateReady       State = "ready"
	StateUnavailable State = "unavailable"
	StateTimeout     State = "timeout"
	StateError       State = "error"
)

Jump to

Keyboard shortcuts

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