golem-add-transactions-rust

Implements saga-pattern transactions with compensation logic in Rust Golem agents.

1.5k|212|Updated Nov 24, 2023
One-click install
npx skills add https://github.com/golemcloud/golem --skill golem-add-transactions-rust
Or copy as Structured Prompt for Agentâ–¼
Please help me install this Agent Skill.
Skill: golem-add-transactions-rust
Source: https://github.com/golemcloud/golem/tree/main/golem-skills/skills/rust/golem-add-transactions-rust
Command: npx skills add https://github.com/golemcloud/golem --skill golem-add-transactions-rust

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires golem_rust.

What problem does it solve?

Multi-step operations in distributed agents can fail partway through, leaving systems in inconsistent states. This Skill guides you through adding saga-pattern transactions to Rust Golem agents so every step has a compensation action that automatically rolls back completed work when a failure occurs.

Core Features & Use Cases

  • Operation Definition: Create operations with paired execute and compensate functions using sync_operation for synchronous logic or operation with pinned async closures for async logic.
  • Fallible Transactions: Use fallible_transaction to compensate completed steps and return the error when a step fails.
  • Infallible Transactions: Use infallible_transaction to compensate and retry the entire transaction until it eventually succeeds.
  • Use Case: Build an order-processing agent that reserves inventory and then charges payment; if the payment step fails, the inventory reservation is automatically cancelled in reverse order.

Quick Start

Add a saga transaction to my Rust Golem agent that reserves inventory and charges a payment with automatic compensation on failure.

Frequently Asked Questions about golem-add-transactions-rust

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I add transactions with rollback to a Rust Golem agent?â–¼

Define each step as an operation with an execute function and a compensate function, then run them inside fallible_transaction or infallible_transaction. If a step fails, completed steps are compensated automatically in reverse order.

What is the difference between fallible_transaction and infallible_transaction in golem_rust?â–¼

fallible_transaction compensates completed steps and returns the error when a step fails. infallible_transaction compensates completed steps and then retries the entire transaction until it eventually succeeds.

When should I use sync_operation versus operation in golem_rust?â–¼

Use sync_operation when both execute and compensate logic are synchronous. Use operation with closures returning Box::pin(async move { ... }) when either the execute or compensate logic needs to perform async work such as HTTP requests.

Why does my Golem transaction closure fail to compile?â–¼

Transaction closures must be wrapped with boxed(async move { ... }) from golem_rust, and all tx.execute calls require .await. Agent methods using transactions must also be declared as async fn.

Does Golem saga compensation run more than once?â–¼

Yes, compensation logic may be called more than once, so it must be idempotent. Compensation always runs in the reverse order of execution for all completed steps.