golem-atomic-block-rust

Implements atomic blocks, idempotence mode, and oplog commit controls in Rust Golem agents.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires golem_rust.

What problem does it solve?

When a durable Golem agent crashes between two external side effects (like reserving inventory and charging a payment), recovery can leave the system in an inconsistent half-done state. This Skill explains how to use Golem's Rust durability APIs to group external effects for replay, control idempotency behavior, and manage oplog replication.

Core Features & Use Cases

  • Atomic Blocks: Wrap multiple external side effects with atomically or atomically_async so the whole group replays together after a crash.
  • Idempotence Mode Control: Opt out of the default idempotent HTTP behavior with with_idempotence_mode(false, ...) for non-idempotent calls.
  • Oplog Commit and Idempotency Keys: Use oplog_commit to wait for replica replication and generate_idempotency_key for exactly-once external API calls.
  • Use Case: An order-processing agent must reserve inventory and charge a customer; wrapping both calls in atomically ensures recovery re-runs both together instead of skipping the reservation.

Quick Start

Show me how to wrap an inventory reservation and a payment charge in an atomic block in my Rust Golem agent so both replay together after a crash.

Frequently Asked Questions about golem-atomic-block-rust

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

FAQPage Schema
How do I group external side effects atomically in a Golem Rust agent?

Use golem_rust::atomically to wrap two or more external side effects so the entire block replays together after a crash. For async code, use atomically_async with the same semantics.

Are POST requests retried by default in Golem?

Yes. Idempotence mode defaults to true, so all outgoing HTTP requests including POST, PUT, PATCH, and DELETE are treated as idempotent and work with status-code-keyed retry policies out of the box.

When should I use with_idempotence_mode(false) in Golem?

Use it to opt out for a specific non-idempotent call where accidental duplication would be more harmful than missing the call. The worker traps on uncertain outcomes so a higher-level retry decides what to do.

Does atomically reduce oplog size or speed up recovery in Golem?

No. atomically does not shrink the oplog or skip replay, and it is not an STM or transaction primitive. For large oplogs or slow recovery, use snapshot-based recovery instead.

How do I generate an idempotency key for payment APIs in Golem Rust?

Call golem_rust::generate_idempotency_key to create a durable key that persists across agent restarts. Pass this key to external payment APIs to ensure exactly-once processing.