Module mnesia_to_khepri_converter

Behavior defining converter modules used during Mnesia->Khepri copy.

Description

Behavior defining converter modules used during Mnesia->Khepri copy.

All callbacks are run in the same process, so process-based features like the dictionary and mailbox are usable from the callback functions.

Unlike what the "optional callback functions" line says above, at least one of init_copy_to_khepri/3 or init_copy_to_khepri/4 is required, depending on how the copy is started.

Function Index

init_copy_to_khepri/3Initializes the state of the converter module.
init_copy_to_khepri/4Initializes the state of the converter module, using Args.
copy_to_khepri/3Copies a record to a Khepri store.
delete_from_khepri/3Deletes a key from a Khepri store.
finish_copy_to_khepri/1Performs any post-copy operations.

Function Details

init_copy_to_khepri/3

init_copy_to_khepri(StoreId, MigrationId, Tables) -> Ret

Initializes the state of the converter module.

This callback is used when a table copy is initiated like this:
mnesia_to_khepri:copy_all_tables(
  StoreId,
  <<"my_migration">>,
  my_converter_mod).

See init_copy_to_khepri/4 if you want to pass arguments to the converter module.

It it called after involved tables were marked as "being migrated" (i.e. copy in progress). This state is recorded in the destination Khepri store StoreId.

Unlike what the "optional callback functions" line says above, at least one of init_copy_to_khepri/3 or init_copy_to_khepri/4 is required, depending on how the copy is started.

See also: init_copy_to_khepri/4.

init_copy_to_khepri/4

init_copy_to_khepri(StoreId, MigrationId, Tables, Args) -> Ret

Initializes the state of the converter module, using Args.

This callback is used when a table copy is initiated like this:
mnesia_to_khepri:copy_all_tables(
  StoreId,
  <<"my_migration">>,
  {my_converter_mod, Args}).

See init_copy_to_khepri/3 if you don't need to pass arguments to the converter module.

It it called after involved tables were marked as being migrated. This state is recorded in the destination Khepri store StoreId.

Unlike what the "optional callback functions line says above, at least one of init_copy_to_khepri/3 or init_copy_to_khepri/4 is required, depending on how the copy is started.

See also: init_copy_to_khepri/3.

copy_to_khepri/3

copy_to_khepri(Table, Record, Priv) -> Ret

Copies a record to a Khepri store.

This callback is called for each record to copy. Record comes from table Table initially. It may not be called at all if there are not records to copy.

The callback is responsible for deciding if the record should be written to Khepri and how. The destination Khepri store was passed to init_copy_to_khepri/2 or init_copy_to_khepri/3.

delete_from_khepri/3

delete_from_khepri(Table, Key, Priv) -> Ret

Deletes a key from a Khepri store.

This callback is called for each deletion which occurred in Mnesia concurrently to the copy in progress. Only the Mnesia key is available, not the record that was deleted. It may not be called at all if there were no concurrent deletions.

The callback is responsible for deciding what to do in Khepri. The destination Khepri store was passed to init_copy_to_khepri/3 or init_copy_to_khepri/4.

finish_copy_to_khepri/1

finish_copy_to_khepri(Priv) -> ok

Performs any post-copy operations.

It it called after involved tables were marked as "migrated" (i.e. copy is finished). This state is recorded in the destination Khepri store StoreId.

This callback is optional.


Generated by EDoc