Search by

adachsoft / task-repository-replication

Arkadiusz Adach

Durable replication of task repositories to synchronous or asynchronous replicas.

Package info

gitlab.com/a.adach/task-repository-replication

Issues

pkg:composer/adachsoft/task-repository-replication

Statistics

Installs: 5

Dependents: 0

Suggesters: 0

Stars: 0

v0.1.1 2026-12-01 18:14 UTC

This package is auto-updated.

Last update: 2026-12-01 17:15:11 UTC


README

Task Repository Replication decorates the repository contracts from adachsoft/task-contracts and forwards changes from a primary task data set to one or more replicas. It is intended for applications that need a durable handoff between primary writes and replica updates.

Features

  • Synchronous replication during the primary repository operation or asynchronous replication through an explicit worker.
  • A durable, file-backed outbox with per-replica progress tracking.
  • Decorators for task, comment, attachment metadata, and attachment content contracts.
  • Replication status inspection and repository reconciliation.
  • Factory-based assembly that keeps application repository implementations behind the task contracts.

Installation

Install the package with Composer:

composer require adachsoft/task-repository-replication

The package requires PHP 8.3 or later. Provide repository implementations compatible with adachsoft/task-contracts and a PSR-20 clock implementation in your application.

Requirements

  • PHP 8.3 or later.
  • Repository implementations compatible with adachsoft/task-contracts.
  • A PSR-20 clock implementation.

Usage

Assemble the replication runtime with the primary repositories, configured replicas, a writable outbox, and a clock. Use the runtime's repository decorators in place of the primary repositories. See the integration example for the complete setup and delivery workflow.

Integration

Create a RepositorySetDto for the primary storage and one for each replica. Configure each replica with a unique ReplicaName and a delivery mode, then assemble the runtime with a writable directory for the file-backed outbox:

$outbox = FileOutboxFactory::create('/var/lib/my-app/replication-outbox');

$runtime = RepositoryReplicationFactory::create(
    $primaryRepositories,
    new ReplicaConfigurationCollection([
        new ReplicaConfigurationDto(
            new ReplicaName('reporting'),
            ReplicationModeEnum::ASYNC,
            $reportingRepositories,
        ),
    ]),
    $outbox,
    $clock,
);

Use the runtime's tasks, comments, attachments, and attachmentContent properties in place of the corresponding primary repositories. For asynchronous delivery, schedule calls to $runtime->worker->runUntilIdle($replicaName) and monitor progress through $runtime->status->getAll(). The reconciler accepts a replica name and can run in dry-run mode before applying repairs. Synchronous replicas are applied as part of the primary repository operation. The runtime also exposes $runtime->reconciler for repairing replica state.

See the integration example for the complete assembly flow and operational notes.