270 lines
8.0 KiB
Nim
270 lines
8.0 KiB
Nim
|
|
import
|
|
preserves, protocol
|
|
|
|
type
|
|
TargetedTurnEvent*[Cap] {.preservesRecord: "event".} = object
|
|
`target`*: Target[Cap]
|
|
`detail`*: TurnEvent[Cap]
|
|
|
|
`LinkedTaskReleaseReason`* {.preservesOr, pure.} = enum
|
|
`cancelled`, `normal`
|
|
TurnId*[Cap] = Preserve[Cap]
|
|
AssertionDescriptionKind* {.pure.} = enum
|
|
`value`, `opaque`
|
|
AssertionDescriptionValue*[Cap] {.preservesRecord: "value".} = object
|
|
`value`*: Preserve[Cap]
|
|
|
|
AssertionDescriptionOpaque*[Cap] {.preservesRecord: "opaque".} = object
|
|
`description`*: Preserve[Cap]
|
|
|
|
`AssertionDescription`*[Cap] {.preservesOr.} = object
|
|
case orKind*: AssertionDescriptionKind
|
|
of AssertionDescriptionKind.`value`:
|
|
`value`*: AssertionDescriptionValue[Cap]
|
|
|
|
of AssertionDescriptionKind.`opaque`:
|
|
`opaque`*: AssertionDescriptionOpaque[Cap]
|
|
|
|
|
|
NameKind* {.pure.} = enum
|
|
`anonymous`, `named`
|
|
NameAnonymous* {.preservesRecord: "anonymous".} = object
|
|
|
|
NameNamed*[Cap] {.preservesRecord: "named".} = object
|
|
`name`*: Preserve[Cap]
|
|
|
|
`Name`*[Cap] {.preservesOr.} = object
|
|
case orKind*: NameKind
|
|
of NameKind.`anonymous`:
|
|
`anonymous`*: NameAnonymous
|
|
|
|
of NameKind.`named`:
|
|
`named`*: NameNamed[Cap]
|
|
|
|
|
|
ActorId*[Cap] = Preserve[Cap]
|
|
FacetId*[Cap] = Preserve[Cap]
|
|
`FacetStopReason`* {.preservesOr, pure.} = enum
|
|
`explicitAction`, `inert`, `parentStopping`, `actorStopping`
|
|
TaskId*[Cap] = Preserve[Cap]
|
|
ActorActivationKind* {.pure.} = enum
|
|
`start`, `turn`, `stop`
|
|
ActorActivationStart*[Cap] {.preservesRecord: "start".} = object
|
|
`actorName`*: Name[Cap]
|
|
|
|
ActorActivationStop* {.preservesRecord: "stop".} = object
|
|
`status`*: ExitStatus
|
|
|
|
`ActorActivation`*[Cap] {.preservesOr.} = object
|
|
case orKind*: ActorActivationKind
|
|
of ActorActivationKind.`start`:
|
|
`start`*: ActorActivationStart[Cap]
|
|
|
|
of ActorActivationKind.`turn`:
|
|
`turn`*: TurnDescription[Cap]
|
|
|
|
of ActorActivationKind.`stop`:
|
|
`stop`*: ActorActivationStop
|
|
|
|
|
|
Target*[Cap] {.preservesRecord: "entity".} = object
|
|
`actor`*: ActorId[Cap]
|
|
`facet`*: FacetId[Cap]
|
|
`oid`*: Oid[Cap]
|
|
|
|
TurnCauseKind* {.pure.} = enum
|
|
`turn`, `cleanup`, `linkedTaskRelease`, `periodicActivation`, `delay`,
|
|
`external`
|
|
TurnCauseTurn*[Cap] {.preservesRecord: "caused-by".} = object
|
|
`id`*: TurnId[Cap]
|
|
|
|
TurnCauseCleanup* {.preservesRecord: "cleanup".} = object
|
|
|
|
TurnCauseLinkedTaskRelease*[Cap] {.preservesRecord: "linked-task-release".} = object
|
|
`id`*: TaskId[Cap]
|
|
`reason`*: LinkedTaskReleaseReason
|
|
|
|
TurnCausePeriodicActivation* {.preservesRecord: "periodic-activation".} = object
|
|
`period`*: float64
|
|
|
|
TurnCauseDelay*[Cap] {.preservesRecord: "delay".} = object
|
|
`causingTurn`*: TurnId[Cap]
|
|
`amount`*: float64
|
|
|
|
TurnCauseExternal*[Cap] {.preservesRecord: "external".} = object
|
|
`description`*: Preserve[Cap]
|
|
|
|
`TurnCause`*[Cap] {.preservesOr.} = object
|
|
case orKind*: TurnCauseKind
|
|
of TurnCauseKind.`turn`:
|
|
`turn`*: TurnCauseTurn[Cap]
|
|
|
|
of TurnCauseKind.`cleanup`:
|
|
`cleanup`*: TurnCauseCleanup
|
|
|
|
of TurnCauseKind.`linkedTaskRelease`:
|
|
`linkedtaskrelease`*: TurnCauseLinkedTaskRelease[Cap]
|
|
|
|
of TurnCauseKind.`periodicActivation`:
|
|
`periodicactivation`*: TurnCausePeriodicActivation
|
|
|
|
of TurnCauseKind.`delay`:
|
|
`delay`*: TurnCauseDelay[Cap]
|
|
|
|
of TurnCauseKind.`external`:
|
|
`external`*: TurnCauseExternal[Cap]
|
|
|
|
|
|
TurnEventKind* {.pure.} = enum
|
|
`assert`, `retract`, `message`, `sync`, `breakLink`
|
|
TurnEventAssert*[Cap] {.preservesRecord: "assert".} = object
|
|
`assertion`*: AssertionDescription[Cap]
|
|
`handle`*: protocol.Handle
|
|
|
|
TurnEventRetract* {.preservesRecord: "retract".} = object
|
|
`handle`*: protocol.Handle
|
|
|
|
TurnEventMessage*[Cap] {.preservesRecord: "message".} = object
|
|
`body`*: AssertionDescription[Cap]
|
|
|
|
TurnEventSync*[Cap] {.preservesRecord: "sync".} = object
|
|
`peer`*: Target[Cap]
|
|
|
|
TurnEventBreakLink*[Cap] {.preservesRecord: "break-link".} = object
|
|
`source`*: ActorId[Cap]
|
|
`handle`*: protocol.Handle
|
|
|
|
`TurnEvent`*[Cap] {.preservesOr.} = object
|
|
case orKind*: TurnEventKind
|
|
of TurnEventKind.`assert`:
|
|
`assert`*: TurnEventAssert[Cap]
|
|
|
|
of TurnEventKind.`retract`:
|
|
`retract`*: TurnEventRetract
|
|
|
|
of TurnEventKind.`message`:
|
|
`message`*: TurnEventMessage[Cap]
|
|
|
|
of TurnEventKind.`sync`:
|
|
`sync`*: TurnEventSync[Cap]
|
|
|
|
of TurnEventKind.`breakLink`:
|
|
`breaklink`*: TurnEventBreakLink[Cap]
|
|
|
|
|
|
TurnDescription*[Cap] {.preservesRecord: "turn".} = object
|
|
`id`*: TurnId[Cap]
|
|
`cause`*: TurnCause[Cap]
|
|
`actions`*: seq[ActionDescription[Cap]]
|
|
|
|
ExitStatusKind* {.pure.} = enum
|
|
`ok`, `Error`
|
|
`ExitStatus`* {.preservesOr.} = object
|
|
case orKind*: ExitStatusKind
|
|
of ExitStatusKind.`ok`:
|
|
`ok`* {.preservesLiteral: "ok".}: bool
|
|
|
|
of ExitStatusKind.`Error`:
|
|
`error`*: protocol.Error
|
|
|
|
|
|
TraceEntry*[Cap] {.preservesRecord: "trace".} = object
|
|
`timestamp`*: float64
|
|
`actor`*: ActorId[Cap]
|
|
`item`*: ActorActivation[Cap]
|
|
|
|
Oid*[Cap] = Preserve[Cap]
|
|
ActionDescriptionKind* {.pure.} = enum
|
|
`dequeue`, `enqueue`, `dequeueInternal`, `enqueueInternal`, `spawn`, `link`,
|
|
`facetStart`, `facetStop`, `linkedTaskStart`
|
|
ActionDescriptionDequeue*[Cap] {.preservesRecord: "dequeue".} = object
|
|
`event`*: TargetedTurnEvent[Cap]
|
|
|
|
ActionDescriptionEnqueue*[Cap] {.preservesRecord: "enqueue".} = object
|
|
`event`*: TargetedTurnEvent[Cap]
|
|
|
|
ActionDescriptionDequeueInternal*[Cap] {.preservesRecord: "dequeue-internal".} = object
|
|
`event`*: TargetedTurnEvent[Cap]
|
|
|
|
ActionDescriptionEnqueueInternal*[Cap] {.preservesRecord: "enqueue-internal".} = object
|
|
`event`*: TargetedTurnEvent[Cap]
|
|
|
|
ActionDescriptionSpawn*[Cap] {.preservesRecord: "spawn".} = object
|
|
`link`*: bool
|
|
`id`*: ActorId[Cap]
|
|
|
|
ActionDescriptionLink*[Cap] {.preservesRecord: "link".} = object
|
|
`parentActor`*: ActorId[Cap]
|
|
`childToParent`*: protocol.Handle
|
|
`childActor`*: ActorId[Cap]
|
|
`parentToChild`*: protocol.Handle
|
|
|
|
ActionDescriptionFacetStart*[Cap] {.preservesRecord: "facet-start".} = object
|
|
`path`*: seq[FacetId[Cap]]
|
|
|
|
ActionDescriptionFacetStop*[Cap] {.preservesRecord: "facet-stop".} = object
|
|
`path`*: seq[FacetId[Cap]]
|
|
`reason`*: FacetStopReason
|
|
|
|
ActionDescriptionLinkedTaskStart*[Cap] {.preservesRecord: "linked-task-start".} = object
|
|
`taskName`*: Name[Cap]
|
|
`id`*: TaskId[Cap]
|
|
|
|
`ActionDescription`*[Cap] {.preservesOr.} = object
|
|
case orKind*: ActionDescriptionKind
|
|
of ActionDescriptionKind.`dequeue`:
|
|
`dequeue`*: ActionDescriptionDequeue[Cap]
|
|
|
|
of ActionDescriptionKind.`enqueue`:
|
|
`enqueue`*: ActionDescriptionEnqueue[Cap]
|
|
|
|
of ActionDescriptionKind.`dequeueInternal`:
|
|
`dequeueinternal`*: ActionDescriptionDequeueInternal[Cap]
|
|
|
|
of ActionDescriptionKind.`enqueueInternal`:
|
|
`enqueueinternal`*: ActionDescriptionEnqueueInternal[Cap]
|
|
|
|
of ActionDescriptionKind.`spawn`:
|
|
`spawn`*: ActionDescriptionSpawn[Cap]
|
|
|
|
of ActionDescriptionKind.`link`:
|
|
`link`*: ActionDescriptionLink[Cap]
|
|
|
|
of ActionDescriptionKind.`facetStart`:
|
|
`facetstart`*: ActionDescriptionFacetStart[Cap]
|
|
|
|
of ActionDescriptionKind.`facetStop`:
|
|
`facetstop`*: ActionDescriptionFacetStop[Cap]
|
|
|
|
of ActionDescriptionKind.`linkedTaskStart`:
|
|
`linkedtaskstart`*: ActionDescriptionLinkedTaskStart[Cap]
|
|
|
|
|
|
proc `$`*[Cap](x: TargetedTurnEvent[Cap] | AssertionDescription[Cap] | Name[Cap] |
|
|
ActorActivation[Cap] |
|
|
Target[Cap] |
|
|
TurnCause[Cap] |
|
|
TurnEvent[Cap] |
|
|
TurnDescription[Cap] |
|
|
TraceEntry[Cap] |
|
|
ActionDescription[Cap]): string =
|
|
`$`(toPreserve(x, Cap))
|
|
|
|
proc encode*[Cap](x: TargetedTurnEvent[Cap] | AssertionDescription[Cap] |
|
|
Name[Cap] |
|
|
ActorActivation[Cap] |
|
|
Target[Cap] |
|
|
TurnCause[Cap] |
|
|
TurnEvent[Cap] |
|
|
TurnDescription[Cap] |
|
|
TraceEntry[Cap] |
|
|
ActionDescription[Cap]): seq[byte] =
|
|
encode(toPreserve(x, Cap))
|
|
|
|
proc `$`*(x: ExitStatus): string =
|
|
`$`(toPreserve(x))
|
|
|
|
proc encode*(x: ExitStatus): seq[byte] =
|
|
encode(toPreserve(x))
|