Documentation
¶
Overview ¶
Package appnet provides network actions for the operation graph.
Index ¶
Constants ¶
const (
Download op.ActionName = "appnet.download"
)
Action-name constants for the appnet provider's plan-mode actions.
Each constant is the short dotted action label its method dispatches under. Pass these to plan.Plan, op.ReceiverRegistry().BuildAction, RuntimeEnvironment.ActionByName, or WithActionNamed in place of a string literal so a typo is a compile error and rename / find-references work through the constant.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Provider ¶
type Provider struct {
op.ProviderBase
}
Provider provides network actions.
func NewProvider ¶
func NewProvider(runtimeEnvironment *op.RuntimeEnvironment) *Provider
NewProvider creates a network-actions provider bound to the given context.
func (*Provider) Download ¶
Download fetches the content at the given URL and returns the response body.
Parameters:
- `url`: network resource identifying the URL to fetch.
Returns:
- `[]byte`: the response body read from the URL.
- `error`: non-nil if the request fails, the response status is not 200 OK, or the body cannot be read.
type Resource ¶
type Resource interface {
op.Resource
// SourceURL returns the endpoint's URL. Identity-bearing — the canonical URI derives from it.
SourceURL() *url.URL
// contains filtered or unexported methods
}
Resource represents a network resource identified by a URL.
The URI IS the canonical full URL — scheme, host, path, and query. The scheme is preserved because it's reachability-critical (http vs. https vs. ftp are distinct endpoints). Canonicalization normalizes host casing, strips default ports, normalizes percent-encoding, strips trailing slashes, collapses repeated slashes, and sorts query parameters — all semantics-preserving transforms over the given URL.
Two URLs that differ only in the transport scheme (e.g., "http://x" vs. "https://x") produce distinct resources. This is a deliberate consequence of "identity ensures reachability." Consumers that want transport-independent addressing should factor that into their own logic; appnet.Resource does not.
SourceURL is a non-persisted *url.URL view of the URI, populated at construction (and reparsed on unmarshal) for callers that want structured URL access. It always equals url.Parse(URI). Resource is this provider's resource type — the sealed interface over an application-network endpoint.
Sealed by an unexported marker, so the closed set of implementations is the one this package declares. A value reaching an appnet method therefore came from a constructor and carries catalog-issued identity.
func DiscoverResource ¶
func DiscoverResource(runtimeEnvironment *op.RuntimeEnvironment, value any) (Resource, error)
DiscoverResource registers an appnet.Resource via op.ResourceCatalog.Discover without claiming production.
Used by the framework's resource registry adapter for slot coercion (when starlark supplies a string and the slot expects a *appnet.Resource), and by callers that hold a reference handle without claiming to have produced the underlying URL endpoint (UnmarshalJSON/Text/YAML rehydration is the canonical example).
Discover does not stamp a producer, so unlike NewResource it takes only `runtimeEnvironment` — no unit reference is needed.
Nil-Catalog tolerance mirrors the receipt-rehydration paths.
Parameters:
- `runtimeEnvironment`: the session runtime environment.
- `value`: a string URL with a transport scheme.
Returns:
- `*Resource`: the canonical catalog entry (or the unlinked candidate when no catalog is present).
- `error`: if `value` is not a string, does not parse as a URL, or has no scheme.
func NewResource ¶
func NewResource(runtimeEnvironment *op.RuntimeEnvironment, producerID string, value any) (Resource, error)
NewResource constructs an appnet.Resource and claims production via op.ResourceCatalog.GetOrCreate.
Use NewResource from a producer dispatch context — typically a provider method that has received an op.ActivationRecord from the framework. The returned Resource is the canonical catalog entry, stamped with `producerID = activationRecord.CallerID.ID()` (or empty when `Unit` is nil for non-graph dispatch). Use DiscoverResource instead when the caller is not claiming production (rehydration, reference handles, scanner-style discovery, the framework's slot-coercion adapter).
Today no appnet provider method actually claims production — Download returns []byte, not *Resource; future fetchers (e.g., 13.0(k.10)'s Download → *stream.Resource) would produce a stream.Resource, not an appnet.Resource. NewResource exists for symmetry with the m.4 two-constructor pattern and as a stable surface for any future appnet producer.
The URL is canonicalized (lowercase host, strip default port, normalize percent-encoding, strip trailing slash, collapse double slashes, sort query parameters) while preserving the transport scheme. The canonicalized URL becomes the Resource's URI; SourceURL is populated by reparsing it.
Nil-Catalog tolerance mirrors DiscoverResource: when `runtimeEnvironment.Catalog` is nil (test fixtures, library callers without a runtime), the candidate is returned unlinked.
Parameters:
- `runtimeEnvironment`: the session runtime environment.
- `producerID`: the producing caller's id (`activationRecord.CallerID`), or "" for caller-less dispatch. for non-graph dispatch.
- `value`: a string URL with a transport scheme.
Returns:
- `*Resource`: the canonical catalog entry (or the unlinked candidate when no catalog is present).
- `error`: if `value` is not a string, does not parse as a URL, or has no scheme.