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
Use case
CircuitBreakerDynamoDBPersistencelets 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:sort_key_attrstays 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_valueinto 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