StateMigrator
StateMigrator
__init__(component: Component, migrate_func: Callable) -> None
Creates a StateMigrator object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
component |
Component
|
Component to perform the migration for. |
required |
migrate_func |
Callable
|
Function to apply to the state of each instance of the component. |
required |
Raises:
Type | Description |
---|---|
TypeError
|
if component is not a valid Component |
ValueError
|
if migrate_func does not have exactly one parameter |
migrate(instance_ids: List[str] = [], num_workers: int = 4) -> List[MigrationResult]
Performs the migrate_func for component instances' states. If instance_ids is empty, then migrate_func is performed for all instances of the component.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
instance_ids |
List[str]
|
List of instance ids to perform migration for. Defaults to empty list. |
[]
|
num_workers |
int
|
Number of workers to use for parallel processing the migration. Defaults to 4. |
4
|
Returns:
Type | Description |
---|---|
List[MigrationResult]
|
List[MigrationResult]: List of objects with instance_id and exception keys, where exception is None if the migration was successful for that instance name. |
copy_db(src: RedisParams, dest: RedisParams) -> None
async
Copy a component and its state from one Redis instance to another.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
src |
RedisParams
|
RedisParams for the source Redis instance. |
required |
dest |
RedisParams
|
RedisParams for the destination Redis instance. |
required |