You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: dsl.md
+38-29
Original file line number
Diff line number
Diff line change
@@ -21,9 +21,9 @@
21
21
+[Interoperability](#interoperability)
22
22
-[Supported Protocols](#supported-protocols)
23
23
-[Custom and Non-Standard Interactions](#custom-and-non-standard-interactions)
24
-
-[Creating a Custom Function](#creating-a-custom-function)
25
-
-[Using a Custom Function](#using-a-custom-function)
26
-
-[Publishing a Custom Function](#publishing-a-custom-function)
24
+
+[Creating a Custom Function](#creating-a-custom-function)
25
+
+[Using a Custom Function](#using-a-custom-function)
26
+
+[Publishing a Custom Function](#publishing-a-custom-function)
27
27
+[Events](#events)
28
28
+[Extensions](#extensions)
29
29
+[External Resources](#external-resources)
@@ -394,7 +394,8 @@ A timeout error **must** have its `type` set to `https://serverlessworkflow.io/s
394
394
Serverless Workflow DSL is designed to seamlessly interact with a variety of services, ensuring robust service interoperability.
395
395
396
396
#### Supported Protocols
397
-
- [**HTTP**](dsl-reference.md#http-call): Allows the workflow to make standard HTTP requests to web services. This is useful for RESTful services and web APIs that communicate over the HTTP protocol.
397
+
398
+
- [**HTTP**](dsl-reference.md#http-call): Allows the workflow to make standard HTTP requests to web services. This is useful for RESTful services and web APIs that communicate over the HTTP protocol.
398
399
- [**gRPC**](dsl-reference.md#grpc-call): Supports Remote Procedure Call (RPC) using gRPC, a high-performance, open-source universal RPC framework. This is suitable for connecting to services that require low-latency and high-throughput communication.
399
400
- [**AsyncAPI**](dsl-reference.md#asyncapi-call): Facilitates interaction with asynchronous messaging protocols. AsyncAPI is designed for event-driven architectures, allowing workflows to publish and subscribe to events.
400
401
- [**OpenAPI**](dsl-reference.md#openapi-call): Enables communication with services that provide OpenAPI specifications, which is useful for defining and consuming RESTful APIs.
@@ -411,47 +412,54 @@ For custom interactions, the workflow can define [tasks](dsl-reference.md#run) t
411
412
412
413
Serverless Workflow DSL supports the creation and publication of custom functions to extend the DSL capabilities.
413
414
414
-
Custom functions allow you to define specific tasks and interactions that are not covered by the default supported protocols. Here’s how you can define and use custom functions within your workflows.
415
+
Custom functions allow you to define specific tasks and interactions that are not covered by the default supported protocols.
416
+
417
+
Here’s how you can define and use custom functions within your workflows:
415
418
416
-
1. In your repository, create a new directory for your function, for example, `/.serverless-workflow/functions/my-custom-function.
419
+
1. In your repository, create a new directory for your function, for example, `/serverless-workflow/functions/my-custom-function`. It is strongly recommended that custom function authors include the semantic version of the function in its path. For instance, you might structure the path as `/serverless-workflow/functions/my-custom-function/1.0.0` to reflect the function's version.
417
420
418
-
2. Create a `function.yaml` file containing the [function's definition](dsl-reference.md#task).
421
+
2. Create a `function.yaml` file containing the [function's definition](dsl-reference.md#task). Ideally, the function should document both its input and output. This is important for documentation and validation purposes.
419
422
420
423
```yaml
421
424
#function.yaml
422
-
validateEmailAddress:
423
-
describe:
424
-
summary: Validate email addresses from input data
425
-
input:
426
-
schema:
425
+
input:
426
+
schema:
427
+
document:
427
428
type: object
429
+
description: The function's input
428
430
properties:
429
431
emailAddress:
430
432
type: string
431
-
output:
432
-
schema:
433
+
description: The email address to validate.
434
+
output:
435
+
schema:
436
+
document:
433
437
type: object
438
+
description: The function's output
434
439
properties:
435
440
isValid:
436
441
type: boolean
437
-
run:
438
-
script:
439
-
type: javascript
440
-
source: |
441
-
function validateEmail(email) {
442
-
const re = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,6}$/;
443
-
return re.test(email);
444
-
}
445
-
const emailAddress = '${ .emailAddress }';
446
-
return { isValid: validateEmail(emailAddress) };
447
-
442
+
description: A boolean indicating whether or not the email address is valid.
443
+
run:
444
+
script:
445
+
language: javascript
446
+
code: |
447
+
function validateEmail(email) {
448
+
const re = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,6}$/;
449
+
return re.test(email);
450
+
}
451
+
return { isValid: validateEmail(emailAddress) };
452
+
arguments:
453
+
emailAddress: ${ .emailAddress }
448
454
```
449
455
450
456
3. Optionally, add all the local files your function might need into its directory.
451
457
452
458
4. Commit and push your function to your repository.
453
459
454
-
5. Optionally, submit your function to the Serverless Worfklow Function Registry, allowing users to find your function.
460
+
5. Optionally, submit your function to the [Serverless Workflow Catalog](https://github.com/serverlessworkflow/catalog), allowing users to find your function.
461
+
462
+
For more information about authoring a new custom function, visit the [Serverless Workflow Catalog](https://github.com/serverlessworkflow/catalog).
Consider submitting your function to the Serverless Workflow Function Registry.
486
+
Consider submitting your function to the [Serverless Workflow Function Catalog](https://github.com/serverlessworkflow/catalog).
480
487
481
488
This optional step allows users to discover and utilize your function, enhancing its visibility and usability within the Serverless Workflow community. By registering your function, you contribute to a shared repository of resources that can streamline workflow development for others.
482
489
490
+
For detailed instructions on how to contribute your custom function, please refer to the [CONTRIBUTING.md](https://github.com/serverlessworkflow/catalog/blob/main/CONTRIBUTING.md) file.
491
+
483
492
### Events
484
493
485
494
Events play a crucial role in Serverless Workflow by facilitating communication and coordination between different components and services. They enable workflows to react to external stimuli, paving the way for event-driven architectures and real-time processing scenarios. Events are essentially messages that convey information about a specific occurrence or action, allowing workflows to respond dynamically to changes in their environment.
0 commit comments