scope

package
v0.20.0 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package scope provides the `@scope :mods { ... }` directive. The header's modifiers become the effective policy for every atom declared inside the braces. Nested scopes override outer scopes on a per-modifier-name basis; an atom's own modifier always wins.

Typical use:

@scope :timeout=5s :retry=3 {
  http.request
  json.parse
}

The directive stores its line spans under the private meta key "scope.spans". core.Parser never sees these records; it consults a generic line-indexed modifier lookup that Bundle.OnPreprocess installs via core.WithLineModifiers.

Index

Constants

View Source
const ID = "scope"

Variables

View Source
var Directive = core.Directive{
	Name:    "scope",
	Example: "@scope :timeout=5s :retry=3 {\n  http.request\n}",
	Handler: handleDirective,
}

Directive parses `@scope :mods { ... }`.

View Source
var ProfileDirective = core.Directive{
	Name:    "profile",
	Example: "@profile reliable :timeout=2s :retry=4",
	Handler: handleProfile,
}

ProfileDirective declares a named, reusable set of modifiers:

@profile reliable :timeout=2s :retry=4
@profile fast     :parent=reliable :timeout=500ms

A profile must be declared before the @pipeline or @scope that references it. The parent may be declared either before or after the child; only the use site requires the parent to exist by then.

Functions

func Bundle

func Bundle(_ map[string]string) core.Bundle

func ExpandProfile

func ExpandProfile(meta map[string]any, name string) ([]string, error)

ExpandProfile returns the effective modifier list for a named profile: parent modifiers first, then the profile's own modifiers overriding on name. Cycles and unknown names are compile errors.

A nil meta, an unknown name, or an unresolved parent returns an error naming the missing profile. The full parent chain is included in cycle diagnostics.

Types

This section is empty.

Jump to

Keyboard shortcuts

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