Callback module for the Redis stream replica.
You may implement this callback module to make your own handling of commands replicated from a Redis/Valkey instance.
Summary
Types
The message from the callback module.
The options passed by user to the callback module when starting the replica.
The reply from the callback module.
The state of the callback module.
Callbacks
Handles &Vdr.RedisStream.Replica.call/2 calls.
Called when the replica has received and handled a batch of commands from the Redis. RDB snapshot and online commands are both handled by this callback.
Called when the replica is about to shutdown (in &Vdr.RedisStream.Replica.terminate/2).
Handles generic messages sent to the replica process which the replica process has not handled itself.
Called when the replica has established a connection to the Redis and is about to start replicating.
Called when the replica has read and handle the RDB snapshot from the Redis and starts to stream online commands.
Called when the replica is started.
Types
Callbacks
@callback handle_call(state(), message()) :: {:reply, reply(), state()} | {:noreply, state()} | {:error, term()}
Handles &Vdr.RedisStream.Replica.call/2 calls.
@callback handle_commands( state(), [Vdr.RedisStream.ReplicaCommand.t()] ) :: {:ok, state()} | {:error, term()}
Called when the replica has received and handled a batch of commands from the Redis. RDB snapshot and online commands are both handled by this callback.
RDB snapshot data is converted to corresponding ReplicaCommand structs. For example, if the RDB snapshot contains a list of ["a", "b", "c"] under "l" in database 0, it will be passed as RPUSH command to the callback:
%Vdr.RedisStream.ReplicaCommand{
db: 0,
command: {:rpush, "l", ["a", "b", "c"]},
...
}
Called when the replica is about to shutdown (in &Vdr.RedisStream.Replica.terminate/2).
Handles generic messages sent to the replica process which the replica process has not handled itself.
Called when the replica has established a connection to the Redis and is about to start replicating.
Called when the replica has read and handle the RDB snapshot from the Redis and starts to stream online commands.
Called when the replica is started.