Custom Migration Services
Migration services provide an alternative path for dependency injection to customize Migration SDK behavior.
Replacing most DI services is controlled through the application's IServiceProvider container, which typically does not change after application startup and is not easily available in all contexts.
Migration services are those DI services that the Migration SDK obtains through the migration plan, which may or may not ultimately come from the IServiceProvider container.
This allows migration services to be customized on a per-plan basis, and makes service customization easier in interoperability scenarios (e.g. Python).
Supported Migration Services
The services available to override through the migration services feature are listed in the plan builder's service collection. If the migration service is generic the open generic type is listed in the supported services list.
Supported migration services are available through the plan builder's services property.
plan_builder = MigrationPlanBuilder()
for service in plan_builder.services.supported_services:
print(service.name) # Service name contains the
Overriding Migration Services
All migration services have default implementations provided by the Migration SDK. When a migration service is registered with the plan builder it will be used in place of the default implementation for that plan.
Override migration services on a per-plan basis through the plan builder's services property.
Migration Service Class
Like hooks, migration services are created by inheriting from a service base class.
from typing import TypeVar
from tableau_migration import (
empty_pager,
MigrationContentLoaderBase
)
TContent = TypeVar("T")
class EmptyMigrationContentLoader(MigrationContentLoaderBase[TContent]):
def get_migration_content_pager(self, page_size: int):
return empty_pager(TContent)
Registration
Migration services are then registered with the service builder for a given service type.
plan_builder.services.set(MigrationContentLoaderBase[IUser], EmptyMigrationContentLoader[IUser])
Generic Migration Services
Many migration services are generic, meaning they have type arguments. Normally these type arguments represent migrating content types, so that different migration service implementations can be used for different content types.
When a migration service overrides a closed generic type, meaning all type arguments are specified, that override will only be used for those type arguments.
Alternatively, a migration service can override the open generic type, meaning no type arguments are specified. Migration service overrides for open generic types are used when no other override is registered for the specific type arguments involved.