Skip to content

Commit

Permalink
KOGITO-9412: Create the serverless-workflow-timeouts-showcase for the…
Browse files Browse the repository at this point in the history
… Operator Dev Mode (#1696)

* KOGITO-9412: Create the serverless-workflow-timeouts-showcase for the Operator Dev Mode
    - Initial version

* move the workflow resources to SonataFlow

* increase memory settings and code review fixes

* readme updates

* Adjust to naming to SonataWorkflow

* Readme updates and restore the workflow-timouets.sw.json name changed by mistake
  • Loading branch information
wmedvede authored Jun 26, 2023
1 parent 73b9cf7 commit f5fbd5f
Show file tree
Hide file tree
Showing 34 changed files with 2,183 additions and 0 deletions.
2 changes: 2 additions & 0 deletions serverless-workflow-examples/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
<module>serverless-workflow-testing-with-rest-assured</module>
<module>serverless-workflow-timeouts-showcase-embedded</module>
<module>serverless-workflow-timeouts-showcase-extended</module>
<module>serverless-workflow-timeouts-showcase-operator-devmode</module>
</modules>
</profile>

Expand Down Expand Up @@ -133,6 +134,7 @@
<module>serverless-workflow-testing-with-rest-assured</module>
<module>serverless-workflow-timeouts-showcase-embedded</module>
<module>serverless-workflow-timeouts-showcase-extended</module>
<module>serverless-workflow-timeouts-showcase-operator-devmode</module>
</modules>
</profile>
</profiles>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
id: callback_state_timeouts
version: '1.0'
name: Callback State Timeouts Example
description: Simple process to show the callback state timeout working
start: PrintStartMessage
events:
- name: callbackEvent
source: ''
type: callback_event_type
functions:
- name: systemOut
type: custom
operation: sysout
states:
- name: PrintStartMessage
type: operation
actions:
- name: printSystemOut
functionRef:
refName: systemOut
arguments:
message: "${\"callback-state-timeouts: \" + $WORKFLOW.instanceId + \" has started.\"}"
transition: CallbackState
- name: CallbackState
type: callback
action:
name: callbackAction
functionRef:
refName: systemOut
arguments:
message: "${\"callback-state-timeouts: \" + $WORKFLOW.instanceId + \" has executed the callbackFunction.\"}"
eventRef: callbackEvent
transition: CheckEventArrival
timeouts:
eventTimeout: PT30S
- name: CheckEventArrival
type: switch
dataConditions:
- condition: "${ .eventData != null }"
transition: EventArrived
defaultCondition:
transition: EventNotArrived
- name: EventArrived
type: inject
data:
exitMessage: "The callback event has arrived."
transition: PrintExitMessage
- name: EventNotArrived
type: inject
data:
exitMessage: "The callback event has not arrived, and the timeout has overdue."
transition: PrintExitMessage
- name: PrintExitMessage
type: operation
actions:
- name: printSystemOut
functionRef:
refName: systemOut
arguments:
message: "${\"callback-state-timeouts: \" + $WORKFLOW.instanceId + \" has finalized. \" + .exitMessage + \" eventData: \" + .eventData}"
end: true
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
id: event_state_timeouts
version: "1.0"
name: Event State Timeouts Example
description: Simple process to show the event state timeout working
start: PrintStartMessage
events:
- name: event1
source: ''
type: event1_event_type
- name: event2
source: ''
type: event2_event_type
functions:
- name: systemOut
type: custom
operation: sysout
states:
- name: PrintStartMessage
type: operation
actions:
- name: printSystemOut
functionRef:
refName: systemOut
arguments:
message: "${\"event-state-timeouts: \" + $WORKFLOW.instanceId + \" has started.\"}"
transition: WaitForEvent
- name: WaitForEvent
type: event
onEvents:
- eventRefs: [ event1 ]
eventDataFilter:
data: "${ \"The event1 was received.\" }"
toStateData: "${ .exitMessage }"
actions:
- name: printAfterEvent1
functionRef:
refName: systemOut
arguments:
message: "${\"event-state-timeouts: \" + $WORKFLOW.instanceId + \" executing actions for event1.\"}"
- eventRefs: [ event2 ]
eventDataFilter:
data: "${ \"The event2 was received.\" }"
toStateData: "${ .exitMessage }"
actions:
- name: printAfterEvent2
functionRef:
refName: systemOut
arguments:
message: "${\"event-state-timeouts: \" + $WORKFLOW.instanceId + \" executing actions for event2.\"}"
timeouts:
eventTimeout: PT30S
transition: PrintExitMessage
- name: PrintExitMessage
type: operation
actions:
- name: printSystemOut
functionRef:
refName: systemOut
arguments:
message: "${\"event-state-timeouts: \" + $WORKFLOW.instanceId + \" has finalized. \" + if .exitMessage != null then .exitMessage else \"The event state did not receive any event, and the timeout has overdue\" end }"
end: true
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
id: switch_state_timeouts
version: "1.0"
name: Switch State Timeouts Example
description: Simple process to show the switch state timeout working
start: PrintStartMessage
events:
- name: visaApprovedEvent
source: ''
type: visa_approved_event_type
- name: visaDeniedEvent
source: ''
type: visa_denied_event_type
functions:
- name: systemOut
type: custom
operation: sysout
states:
- name: PrintStartMessage
type: operation
actions:
- name: printSystemOut
functionRef:
refName: systemOut
arguments:
message: "${\"switch-state-timeouts: \" + $WORKFLOW.instanceId + \" has started.\"}"
transition: ChooseOnEvent
- name: ChooseOnEvent
type: switch
eventConditions:
- eventRef: visaApprovedEvent
transition: ApprovedVisa
- eventRef: visaDeniedEvent
transition: DeniedVisa
defaultCondition:
transition: HandleNoVisaDecision
timeouts:
eventTimeout: PT30S
- name: ApprovedVisa
type: inject
data:
exitMessage: "Your visa was approved."
transition: PrintExitMessage
- name: DeniedVisa
type: inject
data:
exitMessage: "Your visa was denied."
transition: PrintExitMessage
- name: HandleNoVisaDecision
type: inject
data:
exitMessage: "No decision was made. The switch state did not receive any event, and the timeout has overdue."
transition: PrintExitMessage
- name: PrintExitMessage
type: operation
actions:
- name: printSystemOut
functionRef:
refName: systemOut
arguments:
message: "${\"switch-state-timeouts: \" + $WORKFLOW.instanceId + \" has finalized. \" + .exitMessage}"
end: true
Loading

0 comments on commit f5fbd5f

Please sign in to comment.