-
| In 0.8 x we can easily to implement the workflow shows below, but in 1.0, it seems that very hard to do so. Can any one tell me how to call a open api when I listen one event occurred. | 
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 6 replies
-
| @Flex-Xuan I'm not sure why you would think that this workflow is harder to implement in 1.0.0, as IMHO everything is simpler than before. As a matter of fact, there actually are many ways to achieve it: Using a combination of  document:
  dsl: '1.0.0'
  namespace: default
  name: monitor-vitals
  version: '0.1.0'
do:
  - monitorVitals:
      fork:
        branches:
          - monitorBloodPressure:
              do:
                - onHighBloodPressure:
                    listen:
                      to:
                        one:
                          with:
                            type: com.event-driven-hospital-api.events.measurements.blood-pressure.v1
                            data: ${ .bp > 120 } #adds a condition to events to match
                - handleHighBloodPressure:
                    ...
                    then: onHighBloodPressure #loop back to listen
          - monitorBodyTemperature:
              do:
                - onHighTemperature:
                    listen:
                      to:
                        one:
                          with:
                            type: com.event-driven-hospital-api.events.measurements.temperature.v1
                            data: ${ .temperature > 39 } #adds a condition to events to match
                - handleHighTemperature:
                    ...
                    then: onHighTemperature #loop back to listen
          - monitorRespirationRate:
              do:
                - onHighRespirationRate:
                    listen:
                      to:
                        one:
                          with:
                            type: com.event-driven-hospital-api.events.measurements.respiration.v1
                            data: ${ .rate > 20 } #adds a condition to events to match
                - handleHighRespirationRate:
                    ...
                    then: onHighRespirationRate #loop back to listenUsing a combination of an  document:
  dsl: '1.0.0'
  namespace: default
  name: monitor-vitals
  version: '0.1.0'
do:
  - monitorVitals:
      listen:
        to:
          any:
            - with:
                type: com.event-driven-hospital-api.events.measurements.blood-pressure.v1
                data: ${ .bp > 120 } #adds a condition to events to match
            - with:         
                type: com.event-driven-hospital-api.events.measurements.temperature.v1
                data: ${ .temperature > 39 } #adds a condition to events to match
            - with:
                type: com.event-driven-hospital-api.events.measurements.respiration.v1
                data: ${ .rate > 20 } #adds a condition to events to match
  - evaluateActionToUndertake:
      switch:
        - highBloodPressure:
            when: .type == "com.event-driven-hospital-api.events.measurements.blood-pressure.v1"
            then: handleHighBloodPressure
        - highTemperature:
            when: .type == "com.event-driven-hospital-api.events.measurements.temperature.v1"
            then: handleHighTemperature
        - highRespirationRate:
            when: .type == "com.event-driven-hospital-api.events.measurements.respiration.v1"
            then: handleHighRespiration
        - default:
            then: raiseUnsupportedEventType
  - handleHighBloodPressure:
      ...
      then: monitorVitals #loopback
  - handleHighTemperature:
      ...
      then: monitorVitals #loopback
  - handleHighTemperature:
      ...
      then: handleHighRespiration #loopback
  - raiseUnsupportedEventType:
      raise:
        type: https://event-driven-hospital-api.com/errors/unsupportedEventType
        status: 400
        title: Unsupported Event Type
        detail: ...I hope this answers your question 😉 | 
Beta Was this translation helpful? Give feedback.

To quote the spec about
forktasks:@Flex-Xuan Yes, all branches must complete for a
forktask to complete, unless you setcompete: true, in which case it completes when the first branch ran to completion.Yes, exactly! To quote the spec about
dotasks: