In the world of modern software architecture, microservices have become the default choice for building scalable and flexible applications. By breaking down a monolith into smaller, independent services, teams can develop, deploy, and scale parts of the system without affecting the whole. However, this architectural freedom comes with a significant challenge: guaranteeing data integrity across distributed services.
How do you ensure an operation that spans multiple services completes successfully? What happens when one service succeeds but the next one fails? You risk falling into the dreaded trap of inconsistent data states, where your application's data is partially updated, corrupt, and untrustworthy.
This is where the concept of atomic actions becomes critical. Let's explore how action.do allows you to prevent inconsistent data and build truly resilient systems.
Imagine a standard user registration flow in a microservices environment:
This seems straightforward, but what happens if the Email Service is down when the API call is made? The user record is created, but the welcome email is never sent. The system is now in an inconsistent state. The user exists but hasn't been properly onboarded. This partial failure can lead to a poor user experience and complex manual cleanup for your support team.
Traditional error handling with try/catch blocks is a start, but it doesn't solve the core problem of observability, retries, and auditable proof of execution in a distributed system.
The solution lies in treating each step in your business process as an atomic action.
An atomic action is a single, indivisible operation that either completes successfully or fails entirely, leaving no partial state behind.
Think of it as a transaction. It's an "all or nothing" guarantee. By wrapping each critical operation—like an API call, a database update, or sending a notification—in an atomic action, you ensure that it can be executed, monitored, and managed reliably.
This is the core philosophy behind action.do. It provides the fundamental building block for reliable automation.
action.do is not just a function call; it's a managed, observable layer for your most critical operations. It transforms fragile function calls into robust, guaranteed tasks.
Let's see how action.do elegantly solves our user registration problem. You would define a specific action, 'send-welcome-email', and execute it as part of your workflow.
import { DotDo } from '@do-platform/sdk';
const client = new DotDo({ apiKey: 'YOUR_API_KEY' });
// Execute a predefined action, 'send-welcome-email'
async function sendWelcomeEmail(userId: string) {
try {
const result = await client.action('send-welcome-email').execute({
userId: userId,
template: 'new-user-template-2024',
});
console.log(`Action completed with status: ${result.status}`);
// The orchestrator knows the email was sent successfully.
return result;
} catch (error) {
// The action failed even after retries.
// The orchestrator can now decide to roll back the user creation
// or flag the user for manual review.
console.error(`Action 'send-welcome-email' failed for user ${userId}.`);
}
}
In this model, the parent process (the "agentic workflow" orchestrator) doesn't need to know the implementation details of sending an email. It only needs to execute the 'send-welcome-email' action and check the result. If the action fails, the orchestrator has the clear signal it needs to handle the exception, preventing the system from ever entering an inconsistent state.
While action.do is focused on executing a single, atomic task, its true power is realized when these actions are chained together. You can use an orchestration agent (like workflow.do) to link multiple actions into a sophisticated business process.
Because each step is an atomic action managed by action.do, the entire workflow becomes resilient. A failure in any step is clearly reported and can be handled gracefully by the orchestrator, ensuring overall data integrity is always maintained.
Stop wrestling with inconsistent data and partial failures. Start building your business processes on a foundation of Reliable, Atomic, and Auditable tasks.
What is an 'atomic action'?
An atomic action is a single, indivisible operation that either completes successfully or fails entirely, leaving no partial state. This guarantees data integrity and reliability in your workflows.
How is action.do different from a simple function call?
action.do provides a layer of abstraction with built-in observability, retries, and audit trails. It treats actions as manageable, versioned services, making your automation more robust and transparent than a standard function.
What kind of actions can I perform with action.do?
You can define any action that can be scripted, such as making an API call, sending an email, updating a database record, interacting with a smart contract, or running a shell command.
Can actions be chained together?
Yes. action.do is designed as a fundamental building block. You can use an orchestration agent (like workflow.do) to chain multiple atomic actions together to create complex and powerful services.