Ankusa.Intake.Memory (ankusa v0.7.0)

Copy Markdown View Source

An in-memory Ankusa.Intake for tests, benches and the fleet drill's fake. Not a production mode: its "replicas" are one process.

Options (intake.memory): path (a file every record is appended to and the log is reloaded from at start, so a replacement node started on an empty data directory finds the log of the node it replaces) and latency_ms (every confirm is delayed by it).

Faults are injected per call, by instance, from a test:

  • fail(instance, class, count) — the next count publishes answer {:error, class} and store nothing
  • lost_ack(instance, class, count) — the next count publishes store the batch and answer {:error, class} (a timeout the broker completed)
  • hold(instance) / release(instance) — publishes wait, unanswered
  • hold_replay(instance) / release_replay(instance) — replay waits
  • set_latency/2, set_ready/2, set_verify/2, set_earliest/2
  • put_raw(instance, record) — a record as it would sit in the log

records/1 reads the log back.

Summary

Functions

Returns a specification to start this module under a supervisor.

The next count publishes (default: all) fail with class and store nothing.

Clears every injected publish fault.

The next count publishes store the batch and answer class: a lost ack.

How many publish calls the log has seen (confirmed or not).

A record exactly as it sits in the log (a test of unknown kinds and versions).

Every record of the log, in position order.

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

fail(instance, class, count \\ :infinity)

The next count publishes (default: all) fail with class and store nothing.

heal(instance)

Clears every injected publish fault.

hold(instance)

hold_replay(instance)

lost_ack(instance, class, count \\ 1)

The next count publishes store the batch and answer class: a lost ack.

publish_calls(instance)

How many publish calls the log has seen (confirmed or not).

put_raw(instance, record)

A record exactly as it sits in the log (a test of unknown kinds and versions).

records(instance)

Every record of the log, in position order.

release(instance)

release_replay(instance)

set_earliest(instance, position)

set_latency(instance, ms)

set_ready(instance, ready?)

set_verify(instance, result)

start_link(opts)