forked from serverlessworkflow/specification
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request serverlessworkflow#988 from neuroglia-io/feat-add-…
…use-cases Add use cases and examples
- Loading branch information
Showing
45 changed files
with
1,286 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# Examples | ||
|
||
Welcome to the Serverless Workflow Examples directory! This section contains a collection of brief YAML files, each representing a single workflow definition. | ||
|
||
These examples are designed to demonstrate specific features and functionalities of the Serverless Workflow DSL. They serve as a practical reference to help you understand and implement different aspects of Serverless Workflows in your projects. | ||
|
||
## Contributing | ||
|
||
We welcome contributions! If you have an example demonstrating a unique feature or use case of Serverless Workflow, feel free to submit a pull request. | ||
|
||
For more detailed information on contributing, including guidelines and best practices, please refer to our [Contributing Guide](./CONTRIBUTING.md). |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,4 +12,4 @@ do: | |
uri: https://petstore.swagger.io/v2/pet/1 | ||
authentication: | ||
bearer: | ||
token: ${ .token } | ||
token: ${ .token } |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
document: | ||
dsl: '1.0.0' | ||
namespace: samples | ||
name: call-custom-function-cataloged | ||
version: '1.0.0' | ||
do: | ||
- log: | ||
call: https://raw.githubusercontent.com/serverlessworkflow/catalog/main/functions/log/1.0.0/function.yaml | ||
with: | ||
message: Hello, world! | ||
level: information | ||
timestamp: true | ||
format: '{TIMESTAMP} [{LEVEL}] ({CONTEXT}): {MESSAGE}' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
document: | ||
dsl: '1.0.0' | ||
namespace: samples | ||
name: call-custom-function-inline | ||
version: '1.0.0' | ||
use: | ||
functions: | ||
getPetById: | ||
input: | ||
schema: | ||
document: | ||
type: object | ||
properties: | ||
petId: | ||
type: string | ||
required: [ petId ] | ||
call: http | ||
with: | ||
method: get | ||
endpoint: https://petstore.swagger.io/v2/pet/{petId} | ||
do: | ||
- getPet: | ||
call: getPetById | ||
with: | ||
petId: 69 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
document: | ||
dsl: '1.0.0-alpha1' | ||
namespace: test | ||
name: grpc-example | ||
version: '0.1.0' | ||
do: | ||
- greet: | ||
call: grpc | ||
with: | ||
proto: | ||
endpoint: file://app/greet.proto | ||
service: | ||
name: GreeterApi.Greeter | ||
host: localhost | ||
port: 5011 | ||
method: SayHello | ||
arguments: | ||
name: ${ .user.preferredDisplayName } |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
document: | ||
dsl: 1.0.0-alpha1 | ||
namespace: examples | ||
name: call-http-shorthand-endpoint | ||
version: 1.0.0-alpha1 | ||
do: | ||
- getPet: | ||
call: http | ||
with: | ||
method: get | ||
endpoint: ${ "https://petstore.swagger.io/v2/pet/\(.petId)" } |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
document: | ||
dsl: '1.0.0-alpha1' | ||
namespace: test | ||
name: openapi-example | ||
version: '0.1.0' | ||
do: | ||
- findPet: | ||
call: openapi | ||
with: | ||
document: | ||
endpoint: https://petstore.swagger.io/v2/swagger.json | ||
operationId: findPetsByStatus | ||
parameters: | ||
status: available |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
document: | ||
dsl: '1.0.0' | ||
namespace: default | ||
name: conditional-task | ||
version: '1.0.0' | ||
do: | ||
- raiseErrorIfUnderage: | ||
if: .customer.age < 18 | ||
raise: | ||
error: | ||
type: https://superbet-casinos.com/customer/access-forbidden | ||
status: 400 | ||
title: Access Forbidden | ||
then: end | ||
- placeBet: | ||
call: http | ||
with: | ||
method: post | ||
endpoint: https://superbet-casinos.com/api/bet/on/football | ||
body: | ||
customer: .customer | ||
bet: .bet |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
document: | ||
dsl: 1.0.0-alpha1 | ||
namespace: examples | ||
name: call-http-shorthand-endpoint | ||
version: 1.0.0-alpha1 | ||
do: | ||
- getPet: | ||
call: http | ||
with: | ||
method: get | ||
endpoint: https://petstore.swagger.io/v2/pet/{petId} | ||
- buyPet: | ||
call: http | ||
with: | ||
method: put | ||
endpoint: https://petstore.swagger.io/v2/pet/{petId} | ||
body: '${ . + { status: "sold" } }' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
document: | ||
dsl: '1.0.0-alpha1' | ||
namespace: test | ||
name: emit | ||
version: '0.1.0' | ||
do: | ||
- emitEvent: | ||
emit: | ||
event: | ||
with: | ||
source: https://petstore.com | ||
type: com.petstore.order.placed.v1 | ||
data: | ||
client: | ||
firstName: Cruella | ||
lastName: de Vil | ||
items: | ||
- breed: dalmatian | ||
quantity: 101 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
document: | ||
dsl: '1.0.0-alpha1' | ||
namespace: test | ||
name: for-example | ||
version: '0.1.0' | ||
do: | ||
- checkup: | ||
for: | ||
each: pet | ||
in: .pets | ||
at: index | ||
while: .vet != null | ||
do: | ||
- waitForCheckup: | ||
listen: | ||
to: | ||
one: | ||
with: | ||
type: com.fake.petclinic.pets.checkup.completed.v2 | ||
output: | ||
as: '.pets + [{ "id": $pet.id }]' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
document: | ||
dsl: '1.0.0-alpha1' | ||
namespace: test | ||
name: fork-example | ||
version: '0.1.0' | ||
do: | ||
- raiseAlarm: | ||
fork: | ||
compete: true | ||
branches: | ||
- callNurse: | ||
call: http | ||
with: | ||
method: put | ||
endpoint: https://fake-hospital.com/api/v3/alert/nurses | ||
body: | ||
patientId: ${ .patient.fullName } | ||
room: ${ .room.number } | ||
- callDoctor: | ||
call: http | ||
with: | ||
method: put | ||
endpoint: https://fake-hospital.com/api/v3/alert/doctor | ||
body: | ||
patientId: ${ .patient.fullName } | ||
room: ${ .room.number } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
document: | ||
dsl: '1.0.0-alpha1' | ||
namespace: test | ||
name: listen-to-all | ||
version: '0.1.0' | ||
do: | ||
- callDoctor: | ||
listen: | ||
to: | ||
all: | ||
- with: | ||
type: com.fake-hospital.vitals.measurements.temperature | ||
data: ${ .temperature > 38 } | ||
- with: | ||
type: com.fake-hospital.vitals.measurements.bpm | ||
data: ${ .bpm < 60 or .bpm > 100 } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
document: | ||
dsl: '1.0.0-alpha1' | ||
namespace: test | ||
name: listen-to-any | ||
version: '0.1.0' | ||
do: | ||
- callDoctor: | ||
listen: | ||
to: | ||
any: | ||
- with: | ||
type: com.fake-hospital.vitals.measurements.temperature | ||
data: ${ .temperature > 38 } | ||
- with: | ||
type: com.fake-hospital.vitals.measurements.bpm | ||
data: ${ .bpm < 60 or .bpm > 100 } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
document: | ||
dsl: '1.0.0-alpha1' | ||
namespace: test | ||
name: listen-to-one | ||
version: '0.1.0' | ||
do: | ||
- waitForStartup: | ||
listen: | ||
to: | ||
one: | ||
with: | ||
type: com.virtual-wf-powered-race.events.race.started.v1 | ||
- startup: | ||
call: http | ||
with: | ||
method: post | ||
endpoint: | ||
uri: https://virtual-wf-powered-race.com/api/v4/cars/{carId}/start |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
document: | ||
dsl: '1.0.0-alpha1' | ||
namespace: test | ||
name: raise-not-implemented | ||
version: '0.1.0' | ||
do: | ||
- notImplemented: | ||
raise: | ||
error: | ||
type: https://serverlessworkflow.io/errors/not-implemented | ||
status: 500 | ||
title: Not Implemented | ||
detail: ${ "The workflow '\( $workflow.definition.document.name ):\( $workflow.definition.document.version )' is a work in progress and cannot be run yet" } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
document: | ||
dsl: '1.0.0-alpha1' | ||
namespace: test | ||
name: run-container | ||
version: '0.1.0' | ||
do: | ||
- runContainer: | ||
run: | ||
container: | ||
image: hello-world |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
document: | ||
dsl: '1.0.0-alpha1' | ||
namespace: test | ||
name: run-subflow | ||
version: '0.1.0' | ||
do: | ||
- registerCustomer: | ||
run: | ||
workflow: | ||
namespace: test | ||
name: register-customer | ||
version: '0.1.0' | ||
input: | ||
customer: .user |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
document: | ||
dsl: '1.0.0-alpha1' | ||
namespace: test | ||
name: set | ||
version: '0.1.0' | ||
schedule: | ||
on: | ||
one: | ||
with: | ||
type: io.serverlessworkflow.samples.events.trigger.v1 | ||
do: | ||
- initialize: | ||
set: | ||
startEvent: ${ $workflow.input[0] } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
document: | ||
dsl: '1.0.0' | ||
namespace: default | ||
name: try-catch-retry | ||
version: '1.0.0' | ||
do: | ||
- tryGetPet: | ||
try: | ||
- getPet: | ||
call: http | ||
with: | ||
method: get | ||
endpoint: https://petstore.swagger.io/v2/pet/{petId} | ||
catch: | ||
errors: | ||
with: | ||
type: https://serverlessworkflow.io.io/dsl/errors/types/communication | ||
status: 503 | ||
retry: | ||
delay: | ||
seconds: 3 | ||
backoff: | ||
exponential: {} | ||
limit: | ||
attempt: | ||
count: 5 |
Oops, something went wrong.