Skip to content

Update Temporal DSL post #72

@mrsimonemms

Description

@mrsimonemms

Please update the post on Temporal DSL. The pre-release version (v0.0.x) used the non-standard Go templating method of generating code - the public preview (v0.x.x) of Temporal DSL now uses the Serverless Workflow standard of JQ RuntimeExpressions.

Replace the Money Transfer Demo example YAML with the YAML code below:

document:
  dsl: 1.0.0
  namespace: MoneyTransfer # Mapped to the task queue
  name: AccountTransferWorkflow # Workflow name
  version: 0.0.1
  title: Money Transfer Demo
  summary: Temporal's world-famous Money Transfer Demo, in DSL form
do:
  - queryState:
      listen:
        to:
          one:
            with:
              # ID maps to the query name in Temporal
              id: transferStatus
              # Temporal query - used to make read requests
              type: query
              # The data returned from the query - for application/json, this must be a string so Go interpolation works correctly
              data:
                approvalTime: ${ .data.stateApprovalTime }
                chargeResult:
                  chargeId: ${ .data.stateChargeId }
                progressPercentage: ${ .data.stateProgressPercentage }
                transferState: ${ .data.stateTransferState }
                workflowStatus: ${ .data.stateWorkflowStatus }
  - setup:
      set:
        idempotencyKey: ${ uuid }
        stateApprovalTime: 30
        stateChargeId: ${ uuid }
        stateProgressPercentage: 0
        stateTransferState: starting
        stateWorkflowStatus: ""
  - validate:
      call: http
      with:
        method: post
        endpoint: http://server:3000/validate
  - updateState:
      set:
        stateProgressPercentage: 25
        stateTransferState: running
  - withdraw:
      call: http
      with:
        method: post
        endpoint: http://server:3000/withdraw
        headers:
          content-type: application/json
        body:
          amount: ${ .input.amount }
          attempt: ${ .data.activity.attempt }
          idempotencyKey: ${ .data.idempotencyKey }
          name: ${ .data.workflow.workflow_type_name }
  - updateState:
      set:
        stateProgressPercentage: 50
  - deposit:
      call: http
      with:
        method: post
        endpoint: http://server:3000/deposit
        headers:
          content-type: application/json
        body:
            amount: ${ .input.amount }
            attempt: ${ .data.activity.attempt }
            idempotencyKey: ${ .data.idempotencyKey }
            name: ${ .data.workflow.workflow_type_name }
  - updateState:
      set:
        stateProgressPercentage: 75
  - sendNotification:
      call: http
      with:
        method: post
        endpoint: http://server:3000/notify
        headers:
          content-type: application/json
        body:
          amount: ${ .input.amount }
          fromAccount: ${ .input.fromAccount }
          toAccount: ${ .input.toAccount }
  - updateState:
      set:
        stateProgressPercentage: 100
        stateTransferState: finished

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions