Skip to content

Feature request: Circuit breaker DynamoDB persistence, support single-table (composite key) reuse #8315

Description

@Iamrodos

Use case

CircuitBreakerDynamoDBPersistence lets us rename attributes but assumes a partition-key-only table. Our single-table design uses a composite key, and DynamoDB requires the sort key on every call so the persistence layer can't operate against it. It would be inert, failing open on every call (logged at WARNING) and never trips.

Solution/User Experience

Match the Idempotency utility's sort_key_attr + static_pk_value:

CircuitBreakerDynamoDBPersistence(
    table_name="my-single-table",
    key_attr="PK", sort_key_attr="SK", static_pk_value="CIRCUIT_BREAKER",
)

sort_key_attr stays optional, omit it and behavior is unchanged (partition-key-only, as today). Only when you supply it does the layer write the composite key: static_pk_value into the partition, circuit name into the sort key. No separate table, consistent with the rest of Powertools.

Happy to do a PR for this.

Alternative solution

A dedicated single-attribute table works but adds infra/IAM and breaks the single-table model, the same reason Idempotency added composite-key support.

Acknowledgment

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature-requestfeature requesttriagePending triage from maintainers

    Type

    No type
    No fields configured for issues without a type.

    Projects

    Status
    Triage

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions