Struct migrate_state_dynamodb::DdbStateLock[][src]

pub struct DdbStateLock(_);
Expand description

Implements StateLock storing migration state in an AWS DynamoDB database table.


⚠️ Warning! State locking is not yet implemented, but it is planned to be implemented.
Thus, you have to manually ensure you don't run migrations in parallel in the meantime...

You can configure how and where migration state is stored via DdbStateLockBuilder which is created via DdbStateLock::with_builder() (or lower-level DdbStateLock::builder()).

In general migration state is stored as a single record with a partition key, an optional sort key and payload attribute of binary array type (payload contains migration state itself).

Example usage:

use migrate_state_dynamodb::DdbStateLock;
use migrate_core::Plan;

let ddb_client = rusoto_dynamodb::DynamoDbClient::new(rusoto_core::Region::default());

let mut state_lock = DdbStateLock::with_builder("ddb-table-name", ddb_client, |it| {
    // Available configurations.
    // In this example we pass values that are already set by default just to demo
    it.partition_key_attr_name("partition_key")
        .sort_key_attr_name("sort_key")
        .payload_attr_name("payload")
        // yeah, `rusoto_dynamodb::AttributeValue` API is a bit ugly...
        .partition_key_attr_val(rusoto_dynamodb::AttributeValue {
            s: Some("migrate-state".to_owned()),
            ..Default::default()
        })
        .sort_key_attr_val(rusoto_dynamodb::AttributeValue {
            s: Some("migrate-state".to_owned()),
            ..Default::default()
        })
});

let plan = Plan::builder(state_lock);

Implementations

Returns DdbStateLockBuilder to configure and create an instance of DdbStateLock.

Takes two required arguments:

  • table_name - Name of the DynamoDB table to store state in
  • ddb - [DynamoDb] client implementation to use for all DynamoDB API calls

Same as DdbStateLock::builder(), but accepts third argument, which is a clousure that takes builder to configure it in a single method call chain. Method exists only for convenience of creating DdbStateLock in one expression.

The return value of the closure is ignored, it is intended only for a single simple method call chain. Use DdbStateLock::builder() method to implement more advanced configuration flow.

use migrate_state_dynamodb::DdbStateLock;

let state_lock = DdbStateLock::with_builder("table-name", ddb_client, |it| {
    it.partition_key_attr_name("pk")
        .sort_key_attr_name("sk")
});

Trait Implementations

General concept Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Performs the conversion.

Should always be Self

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.