Documentation
¶
Overview ¶
Package northtalk is the NorthTalk Go embedding, which runs the embedded Zig Core. Its public embedding interface follows spec/embedding/talk.go; the Spec and Conformance Corpus define its behavior. It provides immutable values and codecs, Script execution, Libraries, Capabilities, messaging, save/restore and canonical Trace records. Package session supplies the Session Host; package driver supplies the REPL, deterministic Session Transcript replay and a Pool that pumps many Groups.
Example ¶
Load a Script into a Group, Request one of its Handlers and Pump the Group until the Request settles.
package main
import (
"context"
"fmt"
"time"
talk "northtalk.org/go"
)
func main() {
group := talk.New().NewGroup(talk.GroupOptions{Name: "example"})
script, err := group.Load(talk.LoadOptions{Name: "math", Source: `
on sum a, b
return a + b
end sum
`})
if err != nil {
panic(err)
}
_, pending, err := script.Request(context.Background(), talk.Message{Name: "sum", Args: []talk.Value{talk.Int(2), talk.Int(3)}})
if err != nil {
panic(err)
}
if _, err := group.Pump(time.Now(), talk.PumpOptions{}); err != nil {
panic(err)
}
result, failure := pending.Result()
fmt.Println(result, failure == nil)
}
Output: 5 true
Index ¶
- Variables
- func Conforms(v Value, s Shape) bool
- func EncodeJSON(v Value) ([]byte, error)
- func EncodeValue(v Value) ([]byte, error)
- func SetCompilationCacheDir(dir string) error
- type BroadcastID
- type CalendarImpl
- type Call
- func (c *Call) Answer(v Value)
- func (c *Call) AnswerWithCost(v Value, fuel int64)
- func (c *Call) Automatic() bool
- func (c *Call) Binding() any
- func (c *Call) Charge(fuel int64) error
- func (c *Call) Context() context.Context
- func (c *Call) Delivery() string
- func (c *Call) Fail(e *ScriptError)
- func (c *Call) GrantName() string
- func (c *Call) Group() *Group
- func (c *Call) ID() CallID
- func (c *Call) Now() time.Time
- func (c *Call) RequestCharge(fuel int64) (*ChargeRequest, error)
- func (c *Call) RunID() RunID
- func (c *Call) ScopeName() string
- func (c *Call) ScriptName() string
- func (c *Call) SegmentID() string
- type CallFailed
- type CallID
- type CapabilityDef
- type CapabilityOption
- type CarryOver
- type CausalWork
- type ChargeRequest
- type ChargeRequestID
- type ChargeResult
- type CleanupFailure
- type ConsoleImpl
- type Core
- func (c *Core) CalendarCapability(impl CalendarImpl, costs Costs) (*CapabilityDef, error)
- func (c *Core) ClockCapability(costs Costs) (*CapabilityDef, error)
- func (c *Core) CompileLibrary(src LibrarySource, imports []*Library, declarations GrantDecls) (*Library, error)
- func (c *Core) ConsoleCapability(impl ConsoleImpl, costs Costs) (*CapabilityDef, error)
- func (c *Core) DefineCapability(name string, options ...CapabilityOption) (*CapabilityDef, error)
- func (c *Core) DefineCoordinatedCapability(name string, coordinator func(binding any) *SegmentLifecycle, ...) (*CapabilityDef, error)
- func (c *Core) DefineObjectKind(def ObjectKindDef) (*ObjectKind, error)
- func (c *Core) DefineSegmentCapability(name string, lifecycle SegmentLifecycle, options ...CapabilityOption) (*CapabilityDef, error)
- func (c *Core) HTTPCapability(impl HTTPImpl, costs Costs) (*CapabilityDef, error)
- func (c *Core) HTTPCapabilityWith(server HTTPImpl, client HTTPFetchImpl, costs Costs) (*CapabilityDef, error)
- func (c *Core) LocaleCapability(impl LocaleImpl, costs Costs) (*CapabilityDef, error)
- func (c *Core) MusicalClockCapability(impl MusicalClockImpl, costs Costs, options ...CapabilityOption) (*CapabilityDef, error)
- func (c *Core) NewGroup(o GroupOptions, options ...GroupOption) *Group
- func (c *Core) PeerCapability(impl PeerImpl, costs Costs) (*CapabilityDef, error)
- func (c *Core) PeerKind() *ObjectKind
- func (c *Core) Restore(save []byte, o RestoreOptions, options ...GroupOption) (_ *Group, result RestoreResult, err error)
- func (c *Core) SqliteCapability(impl SqliteImpl, costs Costs, perStep int64) (*CapabilityDef, error)
- func (c *Core) StoreCapability(impl StoreImpl, costs Costs) (*CapabilityDef, error)
- func (c *Core) TimerCapability(impl TimerImpl, costs Costs) (*CapabilityDef, error)
- func (c *Core) UserCapability(impl UserImpl, costs Costs) (*CapabilityDef, error)
- type Cost
- type Costs
- type Counters
- type DateFields
- type Decided
- type Deciding
- type Decimal
- type DeliveryID
- type Diagnostic
- type EffectFailure
- type EffectResult
- type EffectStatus
- type ErrorDecl
- type Field
- type Grant
- type GrantContext
- type GrantDecls
- type Group
- func (g *Group) AddLibrary(l *Library) error
- func (g *Group) Broadcast(m Message) (BroadcastID, error)
- func (g *Group) Call(ctx context.Context, fn Value, args []Value, limits *LimitOverride) (DeliveryID, *Pending, error)
- func (g *Group) CallPump(ctx context.Context, fn Value, args []Value, limits *LimitOverride, ...) (DeliveryID, *Pending, PumpResult, error)
- func (g *Group) Decide(ctx context.Context, to *Object, m Message) (DeliveryID, *Deciding, error)
- func (g *Group) DecideBroadcast(ctx context.Context, m Message) (BroadcastID, *Deciding, error)
- func (g *Group) Deliver(to *Object, m Message) (DeliveryID, error)
- func (g *Group) Dispose(o *Object) error
- func (g *Group) Fingerprint() [32]byte
- func (g *Group) Inspect() Inspection
- func (g *Group) Libraries() []*Library
- func (g *Group) Load(o LoadOptions) (*Script, error)
- func (g *Group) Name() string
- func (g *Group) Object(kind *ObjectKind, id string, native any, opts ...ObjectOption) (*Object, error)
- func (g *Group) ObjectByID(kind, id string) (*Object, bool)
- func (g *Group) Pump(now time.Time, o PumpOptions) (PumpResult, error)
- func (g *Group) ReplaceLibrary(l *Library, carry CarryOver, o ...ReloadOptions) ([]Report, error)
- func (g *Group) Request(ctx context.Context, to *Object, m Message) (DeliveryID, *Pending, error)
- func (g *Group) RequestPump(ctx context.Context, to *Object, m Message, now time.Time, o PumpOptions) (DeliveryID, *Pending, PumpResult, error)
- func (g *Group) Save() ([]byte, error)
- func (g *Group) Script(name string) *Script
- func (g *Group) ScriptNames() []string
- func (g *Group) SetParent(o, parent *Object) error
- func (g *Group) Settle(id CallID, s Settlement) (*Call, error)
- type GroupOption
- type GroupOptions
- type GroupState
- type HTTPFetchImpl
- type HTTPImpl
- type HostError
- type HostErrorCode
- type Inspection
- type Kind
- type Library
- type LibrarySource
- type LimitOverride
- type LimitOverrideFields
- type Limits
- type LoadError
- type LoadOptions
- type LocaleImpl
- type Location
- type Message
- type MessageView
- type MismatchPolicy
- type Mode
- type MusicalClockImpl
- type Object
- type ObjectElements
- type ObjectKind
- type ObjectKindDef
- type ObjectOption
- type ObjectRef
- type Operation
- type OperationCheck
- type OperationRef
- type Outcome
- type Pair
- type PathStep
- type PeerImpl
- type Pending
- type PendingCall
- type Prop
- type PumpOptions
- type PumpResult
- type ReleaseHook
- type ReleaseReason
- type ReloadOptions
- type Report
- type RestoreOptions
- type RestoreResult
- type RunAccounting
- type RunAncestry
- type RunDiscarded
- type RunEnd
- type RunID
- type RunStarted
- type RunStatus
- type RunView
- type ScopeDecl
- type Script
- func (s *Script) CancelRun(id RunID)
- func (s *Script) Counters() Counters
- func (s *Script) Decide(ctx context.Context, m Message) (DeliveryID, *Deciding, error)
- func (s *Script) Deliver(m Message) (DeliveryID, error)
- func (s *Script) Extend(source string) error
- func (s *Script) Grants() map[string][]string
- func (s *Script) Name() string
- func (s *Script) Reload(source string, carry CarryOver, o ...ReloadOptions) ([]Report, error)
- func (s *Script) Request(ctx context.Context, m Message) (DeliveryID, *Pending, error)
- func (s *Script) RequestPump(ctx context.Context, m Message, now time.Time, o PumpOptions) (DeliveryID, *Pending, PumpResult, error)
- func (s *Script) Revoke(grantName string)
- func (s *Script) RewindRun(id RunID)
- func (s *Script) Stop(reason string)
- type ScriptError
- type ScriptView
- type SegmentContext
- type SegmentGrant
- type SegmentLifecycle
- type Settlement
- type Shape
- type SqlParams
- type SqlRows
- type SqlValue
- type SqliteBinding
- type SqliteImpl
- type Stop
- type StoreImpl
- type TimerImpl
- type TraceSink
- type UndecidedBy
- type Unhandled
- type UserImpl
- type Value
- func Add(a, b Value) (Value, error)
- func Bool(b bool) Value
- func Bytes(b []byte) Value
- func CivilDate(f DateFields) (Value, error)
- func Dec(s string) (Value, error)
- func DecodeJSON(b []byte) (Value, error)
- func DecodeValue(b []byte, resolve func(kind, id string) (*Object, bool)) (Value, error)
- func Explain(v Value, s Shape) Value
- func FromFloat(f float64) (Value, error)
- func Instant(seconds int64, micros int32) (Value, error)
- func InstantFromTime(t time.Time) Value
- func Int(i int64) Value
- func List(vs ...Value) Value
- func Map(pairs ...Pair) (Value, error)
- func ParseCivilDate(s string) (Value, error)
- func Path(steps ...PathStep) (Value, error)
- func Quantity(n Decimal, unit string) (Value, error)
- func Range(from, to Value) (Value, error)
- func Text(s string) (Value, error)
- func Uint(u uint64) Value
- func ZoneRules(zone string, from, until time.Time) (Value, error)
- func (v Value) AsBool() (bool, bool)
- func (v Value) AsBytes() ([]byte, bool)
- func (v Value) AsCivilDate() (DateFields, bool)
- func (v Value) AsDec() (Decimal, bool)
- func (v Value) AsInstant() (seconds int64, micros int32, ok bool)
- func (v Value) AsObject() (*Object, bool)
- func (v Value) AsPath() ([]PathStep, bool)
- func (v Value) AsQuantity() (Decimal, string, bool)
- func (v Value) AsRange() (from, to Value, ok bool)
- func (v Value) AsText() (string, bool)
- func (v Value) Entries() []Pair
- func (v Value) Equal(w Value) bool
- func (v Value) Get(key string) Value
- func (v Value) HomeScript() (string, bool)
- func (v Value) Index(i int) Value
- func (v Value) Kind() Kind
- func (v Value) Len() int
- func (v Value) PatternSource() (string, bool)
- func (v Value) String() string
- type Verdict
- type Versions
- type Veto
Examples ¶
Constants ¶
This section is empty.
Variables ¶
var ErrLimit error = errors.New("the Run cannot cover this charge")
var ErrMailboxFull error = errors.New("mailbox full")
Functions ¶
func Conforms ¶ added in v0.2.0
Conforms reports whether v fits s, with a Capability argument's acceptance (ADR 0176).
func EncodeJSON ¶
func EncodeValue ¶
func SetCompilationCacheDir ¶ added in v0.2.0
SetCompilationCacheDir keeps the compiled Zig reactor in dir, so later processes load it instead of compiling it again. The reactor compiles once per process, for the first Core that needs it, so call this before then; afterwards it fails. An empty dir restores the default, the NORTHTALK_ZIG_CACHE_DIR environment variable's directory, or none.
Types ¶
type BroadcastID ¶
type BroadcastID string
type CalendarImpl ¶
type CalendarImpl interface {
Today(c *Call, zone string) (Value, error)
Now(c *Call, zone string) (Value, error)
ToCivil(c *Call, instant Value, zone string) (Value, error)
ToInstant(c *Call, civil Value, disambiguation string, zone string) (Value, error)
Offset(c *Call, instant Value, zone string) (Value, error)
Zone(c *Call, zone string) (Value, error)
}
CalendarImpl supplies zone data and applies gap/overlap rules. An absent zone is passed as ""; the Host reads its default from the Call's Grant binding.
type Call ¶
type Call struct {
// contains filtered or unexported fields
}
func (*Call) Answer ¶
Answer queues a suspending call's settlement for the next Pump. A foreign Group's Value panics with WrongGroup without queuing an input.
func (*Call) AnswerWithCost ¶
AnswerWithCost charges late Fuel with result conversion on resumption. Like Answer, it panics with WrongGroup for foreign Values before queuing.
func (*Call) Delivery ¶
Delivery is the id of the Host Delivery that started the Run; empty when none did (ADR 0125).
func (*Call) Fail ¶
func (c *Call) Fail(e *ScriptError)
Fail queues a copied ScriptError; nil fails as host error. Foreign Values in Data panic with WrongGroup without queuing an input.
func (*Call) RequestCharge ¶
func (c *Call) RequestCharge(fuel int64) (*ChargeRequest, error)
RequestCharge queues a charge request into the Group that made the Call, from any goroutine. Only a suspending Operation declared Metering "read-only" may ask, one unresolved request at a time; an invalid amount, an ineligible call or an overlap is HostError invalid value, with no id.
func (*Call) ScriptName ¶
type CallFailed ¶
type CallFailed struct {
Script string
Call CallID
Operation OperationRef
Detail string
}
type CapabilityDef ¶
type CapabilityDef struct {
// contains filtered or unexported fields
}
func (*CapabilityDef) Grant ¶
func (d *CapabilityDef) Grant(ops []string, binding any) (*Grant, error)
func (*CapabilityDef) GrantAll ¶
func (d *CapabilityDef) GrantAll(binding any) *Grant
func (*CapabilityDef) Name ¶
func (d *CapabilityDef) Name() string
type CapabilityOption ¶
type CapabilityOption interface {
// contains filtered or unexported methods
}
CapabilityOption is an Operation declaration or a definition option. Operation implements it, so ordinary calls can pass Operations directly.
func WithReleaseHook ¶
func WithReleaseHook(hook ReleaseHook) CapabilityOption
WithReleaseHook installs synchronous, unmetered cleanup; a panic is ignored.
type CausalWork ¶
type CausalWork struct {
RootDelivery DeliveryID
LiveRuns int64
QueuedMessages int64
DiscardedMessages int64
}
type ChargeRequest ¶
type ChargeRequest struct {
// contains filtered or unexported fields
}
ChargeRequest is a queued charge request (Metered Operations). Its Result is ready once Done closes, at the end of the Pump that processes it.
func (*ChargeRequest) Done ¶
func (r *ChargeRequest) Done() <-chan struct{}
func (*ChargeRequest) ID ¶
func (r *ChargeRequest) ID() ChargeRequestID
func (*ChargeRequest) Result ¶
func (r *ChargeRequest) Result() *ChargeResult
type ChargeRequestID ¶
type ChargeRequestID string
ChargeRequestID is a Group-wide charge request id: q1, q2, … in enqueue order.
type ChargeResult ¶
type ChargeResult struct {
Request ChargeRequestID
Call CallID
Fuel int64 // the requested amount; only "accepted" spends it
Status string // "accepted", "limit" or "inactive"
}
ChargeResult is a charge request's outcome, also reported by its Pump.
type CleanupFailure ¶
type ConsoleImpl ¶
ConsoleImpl shows written Values and starts reads. Read answers through the Call with a line of text without its line break, including an empty line.
type Core ¶
type Core struct {
// contains filtered or unexported fields
}
func (*Core) CalendarCapability ¶
func (c *Core) CalendarCapability(impl CalendarImpl, costs Costs) (*CapabilityDef, error)
CalendarCapability defines the six immediate Calendar Operations. Shapes, domain/result refinements and permitted catalogue failures are Core-owned.
func (*Core) ClockCapability ¶
func (c *Core) ClockCapability(costs Costs) (*CapabilityDef, error)
ClockCapability defines clock.now, which reads the current Pump's Clock.
func (*Core) CompileLibrary ¶
func (c *Core) CompileLibrary(src LibrarySource, imports []*Library, declarations GrantDecls) (*Library, error)
CompileLibrary checks immutable code; imports may also name the ambient stdlib. Calls are rechecked against the importing Script's own Grants at load.
func (*Core) ConsoleCapability ¶
func (c *Core) ConsoleCapability(impl ConsoleImpl, costs Costs) (*CapabilityDef, error)
ConsoleCapability defines fire-and-forget write and suspending read. Its fixed read deadline allows human input independently of the Script's MaxWait.
func (*Core) DefineCapability ¶
func (c *Core) DefineCapability(name string, options ...CapabilityOption) (*CapabilityDef, error)
Example ¶
Define a Capability with a Go function as its Operation, grant it to a Script, and call it from the Script with `ask`.
package main
import (
"context"
"fmt"
"strings"
"time"
talk "northtalk.org/go"
)
func main() {
core := talk.New()
shout, err := core.DefineCapability("shout", talk.Operation{
Name: "loud",
Mode: talk.Immediate,
Args: []talk.Shape{talk.TextShape},
Result: talk.TextShape,
Do: func(_ *talk.Call, args []talk.Value) (talk.Value, error) {
text, _ := args[0].AsText()
return talk.Text(strings.ToUpper(text))
},
})
if err != nil {
panic(err)
}
group := core.NewGroup(talk.GroupOptions{})
script, err := group.Load(talk.LoadOptions{
Name: "greeter",
Source: "on greet name\n ask shout to loud \"hello \" & name\n return it\nend greet\n",
Grants: map[string]*talk.Grant{"shout": shout.GrantAll(nil)},
})
if err != nil {
panic(err)
}
name, err := talk.Text("ada")
if err != nil {
panic(err)
}
_, pending, err := script.Request(context.Background(), talk.Message{Name: "greet", Args: []talk.Value{name}})
if err != nil {
panic(err)
}
if _, err := group.Pump(time.Now(), talk.PumpOptions{}); err != nil {
panic(err)
}
value, _ := pending.Result()
text, _ := value.AsText()
fmt.Println(text)
}
Output: HELLO ADA
func (*Core) DefineCoordinatedCapability ¶
func (c *Core) DefineCoordinatedCapability(name string, coordinator func(binding any) *SegmentLifecycle, options ...CapabilityOption) (*CapabilityDef, error)
DefineCoordinatedCapability resolves each Grant's Segment Coordinator once, when the Grant is created; Grants mapped to one pointer share a participant.
func (*Core) DefineObjectKind ¶
func (c *Core) DefineObjectKind(def ObjectKindDef) (*ObjectKind, error)
DefineObjectKind copies a reusable process-level Object Kind declaration. ParentKinds is manifest metadata; it does not constrain SetParent.
func (*Core) DefineSegmentCapability ¶
func (c *Core) DefineSegmentCapability(name string, lifecycle SegmentLifecycle, options ...CapabilityOption) (*CapabilityDef, error)
func (*Core) HTTPCapability ¶
func (c *Core) HTTPCapability(impl HTTPImpl, costs Costs) (*CapabilityDef, error)
HTTPCapability defines the optional http server Operations. The binding is the Host's own description of the addresses a Grant may listen on; the Core never reads it. The embedded Zig Core makes chapter 7's argument and answer checks, as for every Standard factory.
func (*Core) HTTPCapabilityWith ¶ added in v0.2.0
func (c *Core) HTTPCapabilityWith(server HTTPImpl, client HTTPFetchImpl, costs Costs) (*CapabilityDef, error)
HTTPCapabilityWith defines http with the server Operations, fetch, or both: a nil server or client leaves its Operations out, and costs needs an entry for each Operation offered. The binding also describes the origins a Grant may fetch from.
func (*Core) LocaleCapability ¶
func (c *Core) LocaleCapability(impl LocaleImpl, costs Costs) (*CapabilityDef, error)
LocaleCapability defines the eight immediate Locale Operations. The Core validates Shapes, options, effective tag syntax and result refinements. Every Host failure becomes host error; bad locale is raised only by the Core.
func (*Core) MusicalClockCapability ¶ added in v0.2.0
func (c *Core) MusicalClockCapability(impl MusicalClockImpl, costs Costs, options ...CapabilityOption) (*CapabilityDef, error)
MusicalClockCapability defines the musical clock WithMusicalClock takes (09-embedding.md, The musical clock): the Capability "musical-clock", whose one Operation, wait, is suspending, takes one bar or beat count, has no MaxPending, result Nothing and no error catalogue. costs gives wait's cost. DefineCapability refuses wait as an Operation name, since no source can call it, so only the Core makes this one.
func (*Core) NewGroup ¶
func (c *Core) NewGroup(o GroupOptions, options ...GroupOption) *Group
func (*Core) PeerCapability ¶ added in v0.2.0
func (c *Core) PeerCapability(impl PeerImpl, costs Costs) (*CapabilityDef, error)
PeerCapability defines the optional peer Operations. The binding is the Host's own description of the names a Grant may reach and expose; the Core never reads it. A send to a Peer is the sending Script's Grant's post, or call with `and wait`.
func (*Core) PeerKind ¶ added in v0.2.0
func (c *Core) PeerKind() *ObjectKind
PeerKind is the Core-fixed Object Kind `peer`, with no properties, which a Host makes each Peer with.
func (*Core) Restore ¶
func (c *Core) Restore(save []byte, o RestoreOptions, options ...GroupOption) (_ *Group, result RestoreResult, err error)
Restore checks declarations before rehydrating frames. Host bindings and futures are rebuilt separately from the saved plain machine data.
func (*Core) SqliteCapability ¶
func (c *Core) SqliteCapability(impl SqliteImpl, costs Costs, perStep int64) (*CapabilityDef, error)
SqliteCapability is optional for Hosts. perStep is whole Fuel charged before each SQLite step; a bad one is HostError `invalid value`. Every binding must be a SqliteBinding.
func (*Core) StoreCapability ¶
func (c *Core) StoreCapability(impl StoreImpl, costs Costs) (*CapabilityDef, error)
StoreCapability defines the eight immediate store Operations. The Core checks Shapes, empty keys, result kinds and declared catalogue failure fields. It maps every binding to impl as one Segment Coordinator, the same for every StoreCapability over impl, so writes to several Stores, or one Store through several Grants, in one Segment share its participant (ADR 0069).
func (*Core) TimerCapability ¶
func (c *Core) TimerCapability(impl TimerImpl, costs Costs) (*CapabilityDef, error)
TimerCapability defines the fixed fire-and-forget timer Operations.
func (*Core) UserCapability ¶
func (c *Core) UserCapability(impl UserImpl, costs Costs) (*CapabilityDef, error)
UserCapability defines the optional user Operations. The binding is ignored.
type DateFields ¶
type Decided ¶
type Decided struct {
Delivery DeliveryID
Broadcast BroadcastID
Verdict Verdict
Vetoes []Veto
Undecided []UndecidedBy
}
type Deciding ¶
type Deciding struct {
// contains filtered or unexported fields
}
Deciding settles when the Verdict is sealed, independently of the Run's end.
type Decimal ¶
type Decimal struct {
// contains filtered or unexported fields
}
func (Decimal) Float64Lossy ¶
type DeliveryID ¶
type DeliveryID string
type Diagnostic ¶
type EffectFailure ¶
type EffectResult ¶
type EffectResult struct {
Status EffectStatus
Detail string
}
type EffectStatus ¶
type EffectStatus string
const ( EffectOK EffectStatus = "ok" EffectFailed EffectStatus = "failed" EffectUnknown EffectStatus = "unknown" )
type Grant ¶
type Grant struct {
// contains filtered or unexported fields
}
func (*Grant) Capability ¶
func (g *Grant) Capability() *CapabilityDef
Capability returns the definition the Grant was made from.
type GrantContext ¶
type GrantContext struct {
Group *Group
ScriptName string
GrantName string
Binding any
Now time.Time
Reason ReleaseReason
}
GrantContext identifies one loaded Script's named Grant within its Group.
type GrantDecls ¶
type GrantDecls map[string]map[string]OperationCheck
GrantDecls supplies compile-time modes, argument Shapes, labels and `command` flags by source Grant name.
type Group ¶
type Group struct {
// contains filtered or unexported fields
}
func (*Group) AddLibrary ¶
AddLibrary registers code only after every direct dependency identity matches.
func (*Group) Broadcast ¶
func (g *Group) Broadcast(m Message) (BroadcastID, error)
Broadcast queues a message for the Scripts that want it at the next drain.
func (*Group) Call ¶
func (g *Group) Call(ctx context.Context, fn Value, args []Value, limits *LimitOverride) (DeliveryID, *Pending, error)
Call admits a Function Value into its Home Script's mailbox. Staleness is checked at drain, after earlier Host Inputs; arity belongs to the new Run.
func (*Group) CallPump ¶
func (g *Group) CallPump(ctx context.Context, fn Value, args []Value, limits *LimitOverride, now time.Time, o PumpOptions) (DeliveryID, *Pending, PumpResult, error)
CallPump admits a Function call and performs one ordinary Pump. Staleness and arity retain Call's drain-time and execution-time behavior. This is a worker call; admission and Pump refusals have RequestPump's partial-success contract, and the Pending can remain unsettled after the single Pump.
func (*Group) DecideBroadcast ¶
func (*Group) Dispose ¶
Dispose queues an idempotent lifecycle change for the next Pump. A disposed handle retains identity and encoding and remains a valid Group-owned Value. Disposing an owner stops its Script; routing skips the disposed Object.
func (*Group) Fingerprint ¶
Fingerprint covers declarations, code identities and limits, never state.
func (*Group) Inspect ¶
func (g *Group) Inspect() Inspection
func (*Group) Libraries ¶ added in v0.5.0
Libraries gives the user Libraries the Group holds now, in the order it added them, with every Library ReplaceLibrary recompiled in place of the one it replaced, and no stdlib Library (spec chapter 9). It is what Restore takes. Like ScriptNames it is Host inspection: it charges nothing, records nothing in the Trace, and may be called inside a Pump.
func (*Group) Object ¶
func (g *Group) Object(kind *ObjectKind, id string, native any, opts ...ObjectOption) (*Object, error)
Object registers a stable kind/id pair in this Group. Registration and Dispose may be called from any goroutine, including a Host callback.
func (*Group) ObjectByID ¶
ObjectByID returns the handle with this Object Kind name and id in this Group, disposed or not. It is how a Host reaches the handles Restore made. It may be called from any goroutine, including a Host callback.
func (*Group) Pump ¶
func (g *Group) Pump(now time.Time, o PumpOptions) (PumpResult, error)
Example ¶
A Script variable keeps its value between Requests, and a Pump runs every Delivery waiting in the Group.
package main
import (
"context"
"fmt"
"time"
talk "northtalk.org/go"
)
func main() {
group := talk.New().NewGroup(talk.GroupOptions{})
script, err := group.Load(talk.LoadOptions{Name: "counter", Source: `
script variable count = 0
on bump
put count + 1 into count
return count
end bump
`})
if err != nil {
panic(err)
}
var pending []*talk.Pending
for range 3 {
_, p, err := script.Request(context.Background(), talk.Message{Name: "bump"})
if err != nil {
panic(err)
}
pending = append(pending, p)
}
result, err := group.Pump(time.Now(), talk.PumpOptions{})
if err != nil {
panic(err)
}
fmt.Println(result.State == talk.Idle)
for _, p := range pending {
value, _ := p.Result()
fmt.Println(value)
}
}
Output: true 1 2 3
func (*Group) ReplaceLibrary ¶
ReplaceLibrary validates every transitive dependent before stopping any Run. KeepMailbox keeps every reloaded Script's mailbox, as Reload's does.
func (*Group) RequestPump ¶
func (g *Group) RequestPump(ctx context.Context, to *Object, m Message, now time.Time, o PumpOptions) (DeliveryID, *Pending, PumpResult, error)
RequestPump is Request followed by one Pump under a single worker guard. Other queued work keeps its ordering; this does not wait for the result. On admission refusal the id and Pending are empty and no Pump runs. A Pump refusal retains the admitted id and Pending alongside the error. Like Pump, this is a worker call. Unsupported backends refuse before admission.
func (*Group) Save ¶
Save snapshots a Quiescent Group without draining Host Inputs or closing effects.
func (*Group) ScriptNames ¶
ScriptNames returns the Group's Scripts' names in load order. It is Host inspection, not a worker call, so it records nothing in the Trace and may be called at any time, including from an Operation or hook inside a Pump: the Core never holds the Group's lock while Host code runs.
type GroupOption ¶ added in v0.2.0
type GroupOption interface {
// contains filtered or unexported methods
}
GroupOption is a Group setting beyond GroupOptions, which NewGroup and Restore both take.
func WithMusicalClock ¶ added in v0.2.0
func WithMusicalClock(clock *CapabilityDef) GroupOption
WithMusicalClock supplies the Group's musical clock (ADR 0166), which MusicalClockCapability makes. Every Script is granted it under the reserved name "musical clock", which LoadOptions.Grants can't use, and a wait in a Musical Unit calls it. Without one, such a wait raises `no musical time`. Load refuses a Capability MusicalClockCapability didn't make as invalid value.
type GroupOptions ¶
type GroupOptions struct {
Name string
// OnReady is called, from any goroutine, when a queued Host Input makes
// the Group runnable. The Host puts the Group on its run queue. It must
// not pump from inside the callback.
OnReady func()
Trace TraceSink // nil: no Trace is recorded
// Seed seeds the generator `random` draws from; 0 when the Host has
// none (chapter 7, Random numbers).
Seed uint64
}
type GroupState ¶
type GroupState int
const ( Idle GroupState = iota // nothing runnable until an input or a deadline Sliced // a slice or the cap ran out with work left Stopped Rewound // a Rewind landed, and the Pump returned at once (ADR 0068) )
type HTTPFetchImpl ¶ added in v0.2.0
HTTPFetchImpl makes fetch's requests (chapter 7, Fetching; ADR 0151). The Core has checked the request and raised `out of domain` and `invalid request`. Fetch hears the normalized URL, with `query` added, and the request without `query`: `method` always, `headers` and `body` as given, and `json` as its compact JSON text. It answers through the Call with {status, headers, body}, which the Core checks, or fails with `bad address`, `network error` or `response too large`, and stops the request when the Call's Context is done.
type HTTPImpl ¶
type HTTPImpl interface {
Serve(c *Call, name string, prefix string, message string, options Value) error
Unserve(c *Call, name string) error
Respond(c *Call, exchange *Object, response Value) error
}
HTTPImpl listens, matches, delivers and answers HTTP Exchanges (chapter 7, ADR 0124). The Core has checked the Shapes and raised `invalid serve` and `invalid response`. Serve hears the effective message, httpRequest for an omitted or Nothing one, and an omitted options as an empty map, and answers through the Call with {host, port}. Respond hears the response as the Script gave it, except that `json` is its compact JSON text.
type HostError ¶
type HostError struct {
Code HostErrorCode
Detail string
}
type HostErrorCode ¶
type HostErrorCode string
const ( StateTooLarge HostErrorCode = "state too large" EffectsPending HostErrorCode = "effects pending" InvalidSave HostErrorCode = "invalid save" SaveMismatch HostErrorCode = "save mismatch" UnknownCall HostErrorCode = "unknown call" ClockBackwards HostErrorCode = "clock backwards" NameReused HostErrorCode = "name reused" ReentrantCall HostErrorCode = "reentrant call" WrongGroup HostErrorCode = "wrong group" EffectStateUnknown HostErrorCode = "effect state unknown" InvalidCheckpoint HostErrorCode = "invalid checkpoint" )
const ( LibraryMismatch HostErrorCode = "library mismatch" ReservedName HostErrorCode = "reserved name" )
const DuplicateObjectID HostErrorCode = "duplicate object id"
const InvalidValue HostErrorCode = "invalid value"
const ParentCycle HostErrorCode = "parent cycle"
type Inspection ¶
type Inspection struct {
Scripts []ScriptView // in load order
}
type Library ¶
type Library struct {
// contains filtered or unexported fields
}
Library holds immutable compiled code and unbound Constant values.
func (*Library) Needs ¶
func (l *Library) Needs() []OperationRef
type LibrarySource ¶
type LimitOverride ¶
type LimitOverride struct {
Set LimitOverrideFields // zero numeric fields override only when marked here
FuelPerRun int64
AllocPerRun int64
MaxWait time.Duration // whole milliseconds
MaxJoin int
}
LimitOverride tightens one Delivery. Zero fields are omitted unless marked in Set; nonzero fields always override. A field that loosens is invalid value.
type LimitOverrideFields ¶
type LimitOverrideFields uint8
LimitOverrideFields marks explicitly supplied fields, including zero values. Nonzero fields are always supplied, preserving the numeric-only API.
const ( OverrideFuelPerRun LimitOverrideFields = 1 << iota OverrideAllocPerRun OverrideMaxWait OverrideMaxJoin )
type Limits ¶
type Limits struct {
FuelPerRun int64
AllocPerRun int64
PersistentState int64 // Script-wide; never overridden per Delivery
CallDepth int
PatternSize int // Text Pattern program instructions; never overridden per Delivery
MailboxDepth int
MaxWait time.Duration // whole milliseconds; anything finer is "invalid value"
MaxJoin int
CleanupBudget int64
}
func DefaultLimits ¶
func DefaultLimits() Limits
type LoadError ¶
type LoadError struct {
Diagnostics []Diagnostic
}
type LoadOptions ¶
type LoadOptions struct {
Name string
Source string
// Grants maps the name the Script uses to a Grant, so one Capability can
// be granted twice under two names with different bindings.
Grants map[string]*Grant
// GrantsAsUsed keeps only the granted Operations that the Script and its
// Libraries use plus implicit abandonment dependencies, trimming once at Load.
GrantsAsUsed bool
// ForbidSuspension refuses any possible Suspension Point as "can't
// suspend here"; kept by Reload, Extend, Library replacement and restore.
ForbidSuspension bool
Owner *Object // the Script becomes its Owning Script
Objects map[string]*Object // well-known objects, bound by name
Limits Limits
}
type LocaleImpl ¶
type LocaleImpl interface {
Compare(c *Call, a, b, opts Value, tag string) (Value, error)
Rank(c *Call, texts, opts Value, tag string) (Value, error)
Upper(c *Call, s Value, tag string) (Value, error)
Lower(c *Call, s Value, tag string) (Value, error)
NumberSymbols(c *Call, tag string) (Value, error)
MonthNames(c *Call, opts Value, tag string) (Value, error)
DayNames(c *Call, opts Value, tag string) (Value, error)
Tag(c *Call, tag string) (Value, error)
}
LocaleImpl supplies Collation, case mappings, Locale data and tag fallback. The Grant binding is the default tag string. An omitted or Nothing tag is passed as ""; option maps contain every key in the documented order.
type Message ¶
type Message struct {
Name string
Args []Value
Limits *LimitOverride
}
type MessageView ¶
type MessageView struct {
Delivery DeliveryID // empty for a message a Script sent
From string // for a message a Script sent, the call or Run that sent it
Message Message
}
type MismatchPolicy ¶
type MismatchPolicy int
const ( RejectMismatch MismatchPolicy = iota VariablesOnly ReloadChanged )
type MusicalClockImpl ¶ added in v0.2.0
MusicalClockImpl ends a musical wait. Wait starts a suspending call with the count a Script waits for, a whole number of bars or beats, 1 or more; the Host answers Nothing when that many lines have passed on its Transport, or fails the call, whose code then raises in the Run.
type Object ¶
type Object struct {
// contains filtered or unexported fields
}
func (*Object) Kind ¶
func (o *Object) Kind() *ObjectKind
type ObjectElements ¶
type ObjectElements struct {
Shape Shape
Count func(o *Object) (Value, error)
At func(o *Object, index int64) (Value, error)
Find func(o *Object, name string) (Value, error)
CountCost Cost
AtCost Cost
FindCost Cost
}
ObjectElements is an Object Kind's ordered, named collection of Host Objects (#1143). Shape is an Object Shape or a OneOf of them; results are checked against it, wrapped in Optional. At gets a nonzero index: positive from the front, negative from the end. Its callbacks run inside the Run, synchronously and read-only, like a property's Get.
type ObjectKind ¶
type ObjectKind struct {
// contains filtered or unexported fields
}
type ObjectKindDef ¶
type ObjectKindDef struct {
Name string
Props []Prop
// ParentKinds lists the kinds that may be this kind's parent, for the
// Host Manifest only. SetParent doesn't check it.
ParentKinds []string
// Elements is nil for a kind with no collection.
Elements *ObjectElements
}
type ObjectOption ¶ added in v0.2.0
type ObjectOption func(*objectOptions)
ObjectOption configures Object.
func WithParent ¶ added in v0.2.0
func WithParent(parent *Object) ObjectOption
WithParent makes the object with this parent, set at once, even inside a Pump (ADR 0152). A disposed parent is "invalid value".
type Operation ¶
type Operation struct {
Name string
Args []Shape
Labels []string // one Argument Label per argument after the first, or none (ADR 0115)
Result Shape
Cost Cost
Mode Mode
MaxPending time.Duration
Errors []ErrorDecl
Scope *ScopeDecl
SegmentBound bool
// Metering is empty, "read-only" or "segment-bound" (Metered Operations).
// A suspending "read-only" Operation's Call may RequestCharge.
Metering string
Command bool // also a Host Command, callable by its name alone (ADR 0094)
Description string // tooling only; nothing in the Core reads it (ADR 0076)
Examples []string // tooling only
Do func(c *Call, args []Value) (Value, error)
Start func(c *Call, args []Value) error
Fire func(c *Call, args []Value) error
}
type OperationCheck ¶
type OperationRef ¶
type OperationRef struct{ Capability, Operation string }
type PathStep ¶ added in v0.6.0
type PathStep struct {
Key string
Pos int // counted from 1, or from the end when negative
IsPos bool // a position, not a key
}
PathStep is one segment of a Path: a key, or a 1-based position.
type PeerImpl ¶ added in v0.2.0
type PeerImpl interface {
// Expose with name "" makes a new unnamed exposure.
Expose(c *Call, name string) error
// Unexpose hears either a name or, for peer non-nil, the Peer.
Unexpose(c *Call, name string, peer *Object) error
Reach(c *Call, address string) error
Post(c *Call, peer *Object, message string, args []Value) error
Call(c *Call, peer *Object, message string, args []Value) error
// Caller gives the Caller Identity recorded for c.Delivery, or Nothing
// (ADR 0154).
Caller(c *Call) (Value, error)
}
PeerImpl holds a Host's exposures and carries its Remote Sends (chapter 7, ADRs 0153 to 0155). The embedded Zig Core has checked the Shapes and raised `out of domain`, `wrong kind`, `bad message name` and `not encodable`. Expose, Reach and Call start suspending calls, answered through the Call: Expose and Reach with a Peer made by Group.Object with PeerKind, Call with the receiver's reply. Fail Expose with `bad address` or `name in use`, Reach with `bad address` or `not exposed`, and Call with `send failed` and {reason, error}.
type Pending ¶
type Pending struct {
// contains filtered or unexported fields
}
func (*Pending) Result ¶
func (p *Pending) Result() (Value, *ScriptError)
type PendingCall ¶
type PendingCall struct {
ID CallID
Script, Grant string
Operation OperationRef
Args []Value
}
type Prop ¶
type Prop struct {
Name string
Shape Shape
Get func(o *Object) (Value, error)
Set func(o *Object, v Value) error
GetCost Cost
SetCost Cost
}
Prop declares a Host property. Get and Set run inside Pump, after the instruction and declared cost are paid. Results and failures are validated and their conversion charged. Set nil makes a property read-only. Load and Reload reject writes when the Object binding and literal key are known.
type PumpOptions ¶
type PumpResult ¶
type PumpResult struct {
State GroupState
NextDeadline time.Time // zero if nothing is waiting on time
FuelUsed int64
Reports []Report // in the order they happened
}
type ReleaseHook ¶
type ReleaseHook func(GrantContext)
type ReleaseReason ¶
type ReleaseReason string
ReleaseReason identifies the lifecycle boundary that releases a named Grant.
const ( ReleaseStop ReleaseReason = "stop" ReleaseReload ReleaseReason = "reload" ReleaseRevoke ReleaseReason = "revoke" ReleaseDisable ReleaseReason = "disable" )
type ReloadOptions ¶
type ReloadOptions struct {
KeepMailbox bool
}
ReloadOptions: KeepMailbox keeps the mailbox, a rewound message included (ADR 0068).
type RestoreOptions ¶
type RestoreOptions struct {
Name string
OnReady func()
Trace TraceSink
Libraries []*Library
Grants func(script, name string) *Grant
Resolve func(kind, id string) (native any, ok bool)
Mismatch MismatchPolicy
// KeepMailbox keeps each changed Script's mailbox in a Partial Restore,
// as Reload's keepMailbox does. Ignored unless Mismatch is ReloadChanged
// and the restore is partial.
KeepMailbox bool
}
type RestoreResult ¶
type RestoreResult struct {
Reports []Report
VariablesOnly bool
Reloaded []string
Pending []PendingCall
DiscardedRuns []RunID
Disposed []ObjectRef
DroppedMessages []DeliveryID
AbandonedCalls []CallID
}
type RunAccounting ¶
type RunAccounting struct {
RunAncestry
Script string
Run RunID
Fuel int64
State string
}
type RunAncestry ¶
type RunAncestry struct {
RootDelivery DeliveryID
ParentRun RunID
ParentCall CallID
}
type RunDiscarded ¶
type RunDiscarded struct {
RunAncestry
Script string
Run RunID
Reason string
}
type RunEnd ¶
type RunEnd struct {
Script string
Run RunID // empty for a Delivery cancelled before it started
Delivery DeliveryID // empty for a Run started by another Script's send
Broadcast BroadcastID // empty unless the Delivery was a Broadcast's
Handler string
Fallback bool // a Fallback Handler clause ran it; Handler is then the message's Selector
Outcome Outcome
Effect *EffectFailure // EffectFailureOutcome
CleanupFailed *CleanupFailure // Cancelled, only when its cleanup failed
Result Value // Completed
Error *ScriptError // Errored
Limit string // LimitFault: "fuel", "alloc", "persistent", "depth", "pattern", "join"
At Location
Fuel int64
Alloc int64
}
type RunStarted ¶
type RunStarted struct {
RunAncestry
Script string
Run RunID
Delivery DeliveryID
Selector string
Function *Value
Args []Value
}
type RunView ¶
type RunView struct {
ID RunID
Status RunStatus
Handler string // its Handler, or the display form of the Function Value it runs
Wait string // Suspended: the `seg` end reason it suspended at (chapter 11)
Until time.Time // Suspended: its deadline, if it has one
Calls []CallID // Suspended: the calls, replies or Join Members it waits for; nil when empty
}
type Script ¶
type Script struct {
// contains filtered or unexported fields
}
func (*Script) Extend ¶
Extend adds an Entry atomically, keeping existing frames and Function Values.
func (*Script) Reload ¶
Reload validates and checks carried state before terminating old Runs and rolling back their participants.
func (*Script) RequestPump ¶
func (s *Script) RequestPump(ctx context.Context, m Message, now time.Time, o PumpOptions) (DeliveryID, *Pending, PumpResult, error)
RequestPump admits a Request and performs one Pump while holding the Group's worker guard. The Pending may remain unsettled. If Pump refuses after admission, the nonempty id and Pending are returned alongside its error. Like Group.RequestPump, this is a worker call; admission refusal returns no id or Pending and does not Pump.
type ScriptError ¶
func (*ScriptError) Error ¶
func (e *ScriptError) Error() string
type ScriptView ¶
type ScriptView struct {
DisabledGrants []string // disabled named Grants, in code-point order; empty when none
ForbidSuspension bool // loaded with ForbidSuspension
Name string
Vars []Pair // its Script Variables, in declaration order
Runs []RunView // every Run that hasn't ended, in the order they started
Mailbox []MessageView // in mailbox order
}
type SegmentContext ¶
type SegmentGrant ¶
type SegmentLifecycle ¶
type SegmentLifecycle struct {
Begin func(SegmentContext) EffectResult
Commit func(SegmentContext) EffectResult
Rollback func(SegmentContext) EffectResult
}
type Settlement ¶
type Settlement struct {
Answer *Value
Fail *ScriptError
Reissue, Adopt bool
}
type Shape ¶
type Shape struct {
// contains filtered or unexported fields
}
var ( AnyShape Shape = Shape{shape.Shape{Kind: "any"}} ValueShape Shape = Shape{shape.Shape{Kind: "value"}} NothingShape Shape = kindShape("nothing") BoolShape Shape = kindShape("boolean") NumberShape Shape = kindShape("number") TextShape Shape = kindShape("text") BytesShape Shape = kindShape("bytes") InstantShape Shape = kindShape("instant") RangeShape Shape = kindShape("range") PathShape Shape = kindShape("path") CivilDateShape Shape = kindShape("civil date") PatternShape Shape = kindShape("pattern") FunctionShape Shape = kindShape("function") )
func ObjectShape ¶
func ObjectShape(kind *ObjectKind) Shape
func QuantityKind ¶
func QuantityOf ¶
type SqlParams ¶
SqlParams binds List to `?` and `?NNN`, or, when Named is non-nil, Named to `:name`, keyed without the colon.
type SqlValue ¶
type SqlValue = any
SqlValue is nil (NULL), int64 (INTEGER), float64 (REAL), string (TEXT) or []byte (BLOB).
type SqliteBinding ¶
sqlite is optional (chapter 7, ADR 0070). The binding names a database the Host keeps; Tables, when non-nil, limits the tables a Grant may use, and MaxRows caps the rows a call may give.
type SqliteImpl ¶
type SqliteImpl interface {
// Coordinator is called once per Grant. The same database gives the same pointer.
Coordinator(database string) *SegmentLifecycle
Query(c *Call, sql string, params SqlParams, max int64, beforeStep func() error) (SqlRows, error)
Change(c *Call, sql string, params SqlParams, max int64, beforeStep func() error) (SqlRows, error)
Begin(c *Call) error
Commit(c *Call) error
Rollback(c *Call) error
}
The Core has checked the Shapes and max and converted params by the chapter 7 rules. Query and Change call beforeStep exactly once immediately before every SQLite statement step, including the completion check and the probe past max, and return its error without stepping (Metered Operations, SQLite step authorization). The Core converts the result, raising `sql` for a column named twice and `unrepresentable` for a double it can't hold or a string that isn't valid UTF-8. Change, Begin, Commit and Rollback are Segment-bound: they act inside the calling Segment's transaction, which the coordinator publishes or discards. Begin, Commit and Rollback open, release and roll back a savepoint. A failed call leaves the database as it was. Fail with ScriptError `sql` {reason}, `constraint` {kind}, `sqlite busy`, `not read-only` or `too many rows` {max} (chapter 9).
type Stop ¶
type Stop struct {
Script string
Reason string
DiscardedRuns []RunID
DroppedMessages []DeliveryID
PendingCalls []CallID
}
type StoreImpl ¶
type StoreImpl interface {
Watch(c *Call, name, prefix, message string) error
Unwatch(c *Call, name string) error
Release(GrantContext)
Begin(ctx SegmentContext) EffectResult
Commit(ctx SegmentContext) EffectResult
Rollback(ctx SegmentContext) EffectResult
Get(c *Call, key string, fallback Value) (Value, error)
Set(c *Call, key string, value Value) error
Delete(c *Call, key string) error
Keys(c *Call, prefix string) (Value, error)
Increment(c *Call, key string, by Value) (Value, error)
Swap(c *Call, key string, expected, replacement Value) (bool, error)
}
StoreImpl keeps Stores named by the Grant binding. Writes belong to the calling Segment; Commit applies them together, and Rollback discards them. Omitted fallback and by arguments reach the Host as Nothing. Watch receives the effective message; registration is final at the call and Release drops every registration of its owner (ADR 0061).
type TimerImpl ¶
type TimerImpl interface {
Schedule(c *Call, name string, at Value, message string, args Value) error
Cancel(c *Call, name string) error
}
TimerImpl stores timers by Script and name. The Host delivers due messages with Script.Deliver; the Core does not store or fire durable timers.
type UndecidedBy ¶
type Unhandled ¶
type Unhandled struct {
Delivery DeliveryID
Message Message
Target *Object
}
type UserImpl ¶
type UserImpl interface {
Confirm(c *Call, message string) error
Choose(c *Call, items []string, prompt string, multiple bool) error
Enter(c *Call, message string, fallback string) error
Notify(c *Call, message string, title string) error
}
UserImpl shows the person running a Script its prompts (chapter 7, ADR 0077). An omitted prompt, default or title is "". Confirm, Choose and Enter start a suspending call that the Host answers through the Call: Confirm with a boolean, Choose with one of items, or with multiple a list of them in list order, and Enter with text. Choose and Enter answer Nothing for a cancel. Fail with ScriptError `user busy` while the Script has another prompt unanswered.
type Value ¶
type Value struct {
// contains filtered or unexported fields
}
Value is an immutable Script value. Its zero value is Nothing.
var Nothing Value
func CivilDate ¶
func CivilDate(f DateFields) (Value, error)
func DecodeJSON ¶
func DecodeValue ¶
DecodeValue accepts only the numbers, tags and payloads EncodeValue writes. JSON whitespace and string escapes are allowed, and text is normalised to NFC. Noncanonical forms are refused with InvalidValue.
func Explain ¶ added in v0.2.0
Explain gives the explain Built-in's report for v against s (ADR 0176).
func InstantFromTime ¶
InstantFromTime has no error result in talk.go. Like other Go conversions that cannot report failure, an out-of-model time is refused with a panic.
func ParseCivilDate ¶
func Path ¶ added in v0.6.0
Path builds a Path from its steps (ADR 0184). A position must be a non-zero integer of magnitude at most 2^31 - 1, or the Path is refused.
func ZoneRules ¶ added in v0.3.0
ZoneRules builds Zone Rules for the IANA zone from `from` up to `until`, exclusive, from the Host's time zone database (chapter 9, Zone Rules builders; ADR 0179). It walks the zone's periods with ZoneBounds, keeping only the boundaries where the offset changes.
func (Value) AsCivilDate ¶
func (v Value) AsCivilDate() (DateFields, bool)
func (Value) Equal ¶
Equal compares values using the Spec's Value Semantics. Quantity comparison preserves sequential rounding in Base Unit conversion. Some enormous Unit powers require work proportional to the exponent and are impractical to compare.
func (Value) HomeScript ¶
func (Value) PatternSource ¶
Source Files
¶
- accounting.go
- calendar_capability.go
- capability.go
- charge_request.go
- core.go
- decision.go
- doc.go
- documentation_hooks.go
- encoding.go
- execution_types.go
- fingerprint.go
- group.go
- group_backend.go
- group_broadcast.go
- group_cancel_run.go
- group_combined.go
- group_crossing.go
- group_dispose.go
- group_effect.go
- group_elements.go
- group_function.go
- group_observe.go
- group_operation.go
- group_path.go
- group_pending.go
- group_property.go
- group_release.go
- group_rewind_run.go
- group_run.go
- group_scope.go
- group_send.go
- group_stop.go
- hostkit_hooks.go
- http_capability.go
- http_fetch.go
- inspection_hooks.go
- library.go
- library_replace.go
- locale_capability.go
- locale_tag.go
- message_hooks.go
- musical_clock.go
- object.go
- peer_capability.go
- replay_hooks.go
- restore.go
- save.go
- script_extend.go
- script_reload.go
- session_guest.go
- session_io_hooks.go
- settle.go
- shape.go
- sqlite_capability.go
- standard_capability.go
- stdlib.go
- store_capability.go
- text.go
- trace_hooks.go
- user_capability.go
- value.go
- zig_analysis.go
- zig_backend.go
- zig_binary.go
- zig_callback.go
- zig_capability.go
- zig_combined.go
- zig_documentation.go
- zig_inline.go
- zig_library.go
- zig_object.go
- zig_record.go
- zig_reload.go
- zig_reply.go
- zig_reply_binary.go
- zig_reply_json.go
- zig_reply_need.go
- zig_save.go
- zig_settle.go
- zig_shared.go
- zone_rules.go
Directories
¶
| Path | Synopsis |
|---|---|
|
Package driver supplies deterministic transcript replay and the terminal driver around the ordinary Session Host, and a Pool that pumps many Groups in parallel.
|
Package driver supplies deterministic transcript replay and the terminal driver around the ordinary Session Host, and a Pool that pumps many Groups in parallel. |
|
internal
|
|
|
analysis
Package analysis is the Session Host's backend-independent view of source.
|
Package analysis is the Session Host's backend-independent view of source. |
|
apicheck
Package apicheck holds the AST check of the public embedding declarations.
|
Package apicheck holds the AST check of the public embedding declarations. |
|
cmd/northtalk
command
Command northtalk runs a Script file, the Go REPL, or replays a Session Transcript.
|
Command northtalk runs a Script file, the Go REPL, or replays a Session Transcript. |
|
cmd/request-pump-report
command
request-pump-report pairs the chronological rounds written by request-pump-bench.sh.
|
request-pump-report pairs the chronological rounds written by request-pump-bench.sh. |
|
cmd/storekit
command
Command storekit checks the memory Store against the language-neutral kit.
|
Command storekit checks the memory Store against the language-neutral kit. |
|
corpus
Package corpus reads Conformance Corpus cases and replays supported backends.
|
Package corpus reads Conformance Corpus cases and replays supported backends. |
|
decimal
Package decimal implements Spec-defined decimal values and arithmetic.
|
Package decimal implements Spec-defined decimal values and arithmetic. |
|
docs
Package docs lets the Session Host read Declaration Documentation that only the Core can reach.
|
Package docs lets the Session Host read Declaration Documentation that only the Core can reach. |
|
examples/tenants
command
Command tenants is the multi-tenant Go Example Host (spec Appendix B, milestone 2): an HTTP server that gives each tenant its own Group, pumped in parallel by the driver Pool.
|
Command tenants is the multi-tenant Go Example Host (spec Appendix B, milestone 2): an HTTP server that gives each tenant its own Group, pumped in parallel by the driver Pool. |
|
generated
Code generated by tools/go/generate.ts from spec/data/corpus.toml; DO NOT EDIT.
|
Code generated by tools/go/generate.ts from spec/data/corpus.toml; DO NOT EDIT. |
|
hostkit
Package hostkit lets a Host kit runner call a Standard factory's immediate Operation as a Script's call would reach it.
|
Package hostkit lets a Host kit runner call a Standard factory's immediate Operation as a Script's call would reach it. |
|
httphost
Package httphost is the HTTP router (spec chapter 9, The HTTP router; ADR 0124): the Host side of the optional http Standard Capability.
|
Package httphost is the HTTP router (spec chapter 9, The HTTP router; ADR 0124): the Host side of the optional http Standard Capability. |
|
messagehooks
Package messagehooks gives the Message Layer what an `op` request carries that the public embedding interface doesn't expose.
|
Package messagehooks gives the Message Layer what an `op` request carries that the public embedding interface doesn't expose. |
|
replay
Package replay exposes message-layer inputs to the conformance runner.
|
Package replay exposes message-layer inputs to the conformance runner. |
|
sessionio
Package sessionio connects the session package to the root package's private Value and guest plumbing.
|
Package sessionio connects the session package to the root package's private Value and guest plumbing. |
|
shape
Script Shape checks (chapter 7): Shapes as data, decoded and checked iteratively so depth is bounded by the budgets, not the call stack.
|
Script Shape checks (chapter 7): Shapes as data, decoded and checked iteratively so depth is bounded by the budgets, not the call stack. |
|
sqlitekit
Package sqlitekit drives a `sqlite` implementation through the language-neutral sqlite kit, `corpus/sqlite-kit/`.
|
Package sqlitekit drives a `sqlite` implementation through the language-neutral sqlite kit, `corpus/sqlite-kit/`. |
|
storekit
Package storekit drives Host Stores through the language-neutral Store kit.
|
Package storekit drives Host Stores through the language-neutral Store kit. |
|
syntax
Package syntax lexes source for the Host-side checks the Go embedding still makes: Selectors, computed message names and Argument Labels.
|
Package syntax lexes source for the Host-side checks the Go embedding still makes: Selectors, computed message names and Argument Labels. |
|
toml
Package toml reads the shared TOML subset used by the Corpus and Host kits.
|
Package toml reads the shared TOML subset used by the Corpus and Host kits. |
|
trace
Package trace writes canonical Trace records using the Spec's generated record and key ordering.
|
Package trace writes canonical Trace records using the Spec's generated record and key ordering. |
|
unicode
Package unicode supplies the Core's text primitives using only the pinned, generated Unicode tables.
|
Package unicode supplies the Core's text primitives using only the pinned, generated Unicode tables. |
|
value
Package value holds the shared value model, used by the Go embedding seam and the internal Abstract Machine.
|
Package value holds the shared value model, used by the Go embedding seam and the internal Abstract Machine. |
|
valueops
Package machine executes standalone lowered Abstract Machine instructions with heap-resident frames, clause dispatch, unwind state and Cost Model 0.
|
Package machine executes standalone lowered Abstract Machine instructions with heap-resident frames, clause dispatch, unwind state and Cost Model 0. |
|
zigwasm
Package zigwasm owns the embedded Zig reactor and its guest memory.
|
Package zigwasm owns the embedded Zig reactor and its guest memory. |
|
Package notify is the notification router (Store Notifications, The router; ADR 0061).
|
Package notify is the notification router (Store Notifications, The router; ADR 0061). |
|
Package peer is a Host's Peer Router (chapter 9, The peer router; ADR 0181): it holds the Peer Exposures of every Group attached to it, carries Remote Sends between them as `post` Deliveries and `call` Requests, at most once, and withdraws Peer Exposures over their Lifetime.
|
Package peer is a Host's Peer Router (chapter 9, The peer router; ADR 0181): it holds the Peer Exposures of every Group attached to it, carries Remote Sends between them as `post` Deliveries and `call` Requests, at most once, and withdraws Peer Exposures over their Lifetime. |
|
Package session is chapter 12's Session Host for Go.
|
Package session is chapter 12's Session Host for Go. |
|
sqlite
module
|
|
|
Package store supplies the in-memory Host implementation of the store Standard Capability (chapter 7, ADR 0050 and ADR 0062).
|
Package store supplies the in-memory Host implementation of the store Standard Capability (chapter 7, ADR 0050 and ADR 0062). |