FateRegistry

class FateRegistry @JvmOverloads constructor(val timeSource: TimeSource = TimeSource.Monotonic)

The set of FateBackends that logged values are routed to, plus the time source that stamps them.

Most code uses Fate, which wraps one shared registry. This is a class so a test can build its own with a kotlin.time.TestTimeSource and a MockFateBackend without affecting anything else.

Timestamps

Every value is stamped in nanoseconds with the time elapsed on timeSource since the registry was created or last restarted. Only differences between stamps mean anything.

Backends

Every registered backend receives every value. Backends can change while other threads are logging. A table notices the change on its next log and rebuilds its entries against the new set.

Warnings

Telemetry reports a wrong type, a schema it can't infer, or a backend that threw through warningHandler, then carries on. A logging mistake should not end a match. Each distinct message is reported once, so a bad value logged every loop does not flood the output.

Constructors

Link copied to clipboard
constructor(timeSource: TimeSource = TimeSource.Monotonic)

Properties

Link copied to clipboard

How many backends are registered.

Link copied to clipboard

The root table, whose path is empty.

Link copied to clipboard

Stamps every logged value. Defaults to TimeSource.Monotonic.

Link copied to clipboard

Where warnings go. The default prints to standard error. A handler must not throw, and may be called from any thread.

Functions

Link copied to clipboard
fun register(backend: FateBackend)

Adds backend. It receives every value logged after this call, including on paths that were already being logged.

Link copied to clipboard
fun reset()

Closes and removes every backend, and forgets which warnings have been reported.

Link copied to clipboard

Makes the next timestamp count from zero again.

Link copied to clipboard
fun table(name: String): FateTable

Returns the table at name under the root.

Link copied to clipboard

Removes backend without closing it.

Link copied to clipboard
fun warn(message: String)

Reports message to warningHandler, unless this exact message has been reported before. After 1000 distinct messages, new ones are dropped.