Overview
Serverless Workflow DSL is designed to seamlessly interact with a variety of services, ensuring robust service interoperability. Whether you’re working with REST APIs, gRPC services, event-driven architectures, or custom integrations, the DSL provides the tools you need.Supported Protocols
The Serverless Workflow DSL supports several standard protocols out of the box:HTTP
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.gRPC
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.AsyncAPI
Facilitates interaction with asynchronous messaging protocols. AsyncAPI is designed for event-driven architectures, allowing workflows to publish and subscribe to events.OpenAPI
Enables communication with services that provide OpenAPI specifications, which is useful for defining and consuming RESTful APIs.A2A
Enables interaction with A2A servers (agents described by A2A).Custom and Non-Standard Interactions
In addition to the default supported protocols, the DSL also provides mechanisms to interact with services in non-standard or unsupported ways using custom processes. This flexibility allows workflows to extend their capabilities beyond the built-in protocols and integrate with any service, regardless of the communication method. For custom interactions, the workflow can define tasks that:- Execute shell commands
- Execute scripts
- Run containers
Creating a Custom Function
Create Function Directory
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.Define the Function
Create a
function.yaml file containing the function’s definition. Ideally, the function should document both its input and output. This is important for documentation and validation purposes.Add Supporting Files
Optionally, add all the local files your function might need into its directory.
Publish to Catalog (Optional)
Optionally, submit your function to the Serverless Workflow Catalog, allowing users to find your function.
Using a Custom Function
Once a custom function is defined, it can be used within a workflow to perform specific tasks. The following example demonstrates how to use thevalidateEmailAddress custom function in a workflow:
Publishing a Custom Function
Consider submitting your function to the Serverless Workflow Function Catalog. 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. For detailed instructions on how to contribute your custom function, please refer to the CONTRIBUTING.md file.Frequently Asked Questions
Which protocol should I use for my service integration?
Which protocol should I use for my service integration?
- Use HTTP for RESTful APIs and standard web services
- Use gRPC for high-performance, low-latency service-to-service communication
- Use AsyncAPI for event-driven architectures and message brokers
- Use OpenAPI when you have an OpenAPI specification for your service
- Use custom functions for proprietary protocols or complex integrations
Can I use multiple protocols in the same workflow?
Can I use multiple protocols in the same workflow?
Yes! A workflow can call different services using different protocols. Each task can specify its own call type (HTTP, gRPC, AsyncAPI, etc.).
What happens if a service call fails?
What happens if a service call fails?
When a call fails, the runtime raises a communication error with type
https://serverlessworkflow.io/spec/1.0.0/errors/communication. You can handle these errors using the try/catch mechanism and implement retry strategies as needed.Can I create a custom function that calls multiple services?
Can I create a custom function that calls multiple services?
Yes! Custom functions can orchestrate multiple service calls, perform data transformations, or implement complex business logic. The function definition can include multiple tasks that call different services using various protocols.