id_effect 0.9.0

Effect<A, E, R>: lazy Send effects over a typed capability list, run on a fiber runtime (Tokio executor), with layers, streams, schedules and coordination
Documentation
# Async messaging (production)

> **Labs crate — unpublished, no API guarantees ([ADR 0010]https://github.com/Industrial/id_effect/blob/main/docs/adrs/0010-crate-tiers.md).**
> `id_effect_jobs` and `id_effect_events` live in [`labs/`]https://github.com/Industrial/id_effect/tree/main/labs.
> Use them via a path or git dependency on `labs/`; they are not on crates.io. Build and test them
> with `cargo … --manifest-path labs/Cargo.toml`.

Platform async messaging stacks on a **sqlx `PgPool`** (`id_effect_sql::pg::PgPool`, published,
feature `pg`), with adapters in the labs crates
[`id_effect_jobs`](https://github.com/Industrial/id_effect/tree/main/labs/id_effect_jobs) and
[`id_effect_events`](https://github.com/Industrial/id_effect/tree/main/labs/id_effect_events).

## SQL platform

[`id_effect_sql::pg`](https://docs.rs/id_effect_sql/latest/id_effect_sql/pg/index.html) (feature `pg`) is built on sqlx:

- `PgSqlClient` implements [`SqlClient`]https://docs.rs/id_effect_sql/latest/id_effect_sql/trait.SqlClient.html
- `provide_pg_sql_client::<E>(pool)` is a `Layer` providing `SqlClientService` + `PgPool` (`PgSqlEnv`)
- Set `DATABASE_URL` (devenv provides `postgresql://postgres@127.0.0.1:5432/id_effect`)

## Jobs — Apalis (pull workers)

`ApalisJobQueue` is **enqueue-only**. Workers pull tasks via Apalis `WorkerBuilder` + `PostgresStorage::poll`. There is no FIFO `dequeue` on the storage side. `id_effect_jobs` uses the stable apalis 1.0 family.

<!-- ignore: labs crate id_effect_jobs is outside the workspace, not a book_snippets dependency -->
```rust,ignore
use id_effect_jobs::{ApalisJobQueue, JobQueue, JobSpec};
use id_effect_tokio::TokioRuntime;

ApalisJobQueue::setup(&pool).await?;
let queue = ApalisJobQueue::new(&pool, "app_jobs");
// `enqueue` is an `Effect<JobRecord, JobError>`; sqlx needs tokio's IO driver.
let record = TokioRuntime::current()?
    .run(queue.enqueue(JobSpec::new("notify", b"payload")))
    .await
    .into_result()?;
```

`JobRunner` / `FabricJobRunner` methods and `drain_jobs(runner, limit, handler)` are effects too (`R = HNil`); `drain_jobs` runs every job in one effect without parking a thread.

Enable: `id_effect_jobs` features `apalis` (+ `postgres`).

## Transactional outbox

`id_effect_jobs` ships no PostgreSQL outbox adapter today: the `OutboxTable` trait has only the
in-process `MemoryOutbox` + `relay_outbox` (`memory` feature, for unit tests). A durable outbox
relay returns with the 0.10 jobs battery.

## Idempotent inbox — obix + job

`ObixInbox` wires obix [`Inbox`](https://docs.rs/obix/latest/obix/struct.Inbox.html) to the [`job`](https://docs.rs/job) poller for idempotent consumers.

## Kafka — rdkafka

`RdKafkaBroker` implements `MessageBroker` with [rdkafka](https://docs.rs/rdkafka). `KafkaBrokerStub` is an in-memory test double (`memory` feature).

## SQL event journal

`EsEntityPgBackend` (`id_effect_events` feature `es-entity`) implements `SqlJournalBackend` on the same `PgPool`.

Apply `ES_ENTITY_EVENT_JOURNAL_DDL` via `apply_es_entity_journal_ddl`.

## Feature matrix

| Crate | Feature | Adapter |
|-------|---------|---------|
| `id_effect_jobs` (labs) | `memory` (default) | in-process test doubles |
| `id_effect_jobs` (labs) | `apalis` | Apalis PostgreSQL queue |
| `id_effect_jobs` (labs) | `obix` | obix idempotent inbox |
| `id_effect_jobs` (labs) | `kafka` | rdkafka broker |
| `id_effect_events` (labs) | `postgres` | `EsEntityPgBackend` |

## Examples

```bash
cargo run --manifest-path labs/Cargo.toml -p id_effect_jobs --example 010_messaging_e2e
cargo run --manifest-path labs/Cargo.toml -p id_effect_jobs --example 020_events_workflow_e2e
```

## See also

- ADR: [`docs/platform/adrs/adr-sql-driver-choice.md`]https://github.com/Industrial/id_effect/blob/main/docs/platform/adrs/adr-sql-driver-choice.md
- [Data access (`id_effect_sql`)]./ch28-00-data.md