syndicate-nim/src/syndicate/protocols/trace.nim

264 lines
7.3 KiB
Nim
Raw Normal View History

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