FateLogWriter
Writes a FateWeaver log to a FateSink. A log holds any number of typed channels.
Each channel has a type, so the compiler rejects a value that doesn't match its schema. Schemas are written into the log, so a reader can decode the file without the classes that produced it. Most types need no hand-written schema, because createChannel infers one from a class.
File format
The file starts with a 4-byte header of magic bytes and a version. After that comes a run of entries. A schema entry (kind 0) defines a channel. A message entry (kind 1) carries one value for a channel that is already defined. Since version 3, every message entry also carries the time it was logged, in nanoseconds, so readers can line up channels without a timestamp channel.
Timestamps
write without a timestamp stamps the entry with the time elapsed on timeSource since this writer was created. Only differences between stamps mean anything. A writer fed by a gay.zharel.fateweaver.telemetry.FateLogBackend gets its stamps from the registry instead.
Threading
A writer can be shared between threads. The sink receives entries one at a time, and a channel's schema entry always comes before its first message.
Example
FateLogWriter.create("mylog.fate").use { writer ->
val userChannel = writer.createChannel("users", User::class)
val eventChannel = writer.createChannel("events", Event::class)
userChannel.put(User("alice", 25))
eventChannel.put(Event("login", System.currentTimeMillis()))
}Parameters
Where the log bytes go
Stamps entries written without a timestamp. Defaults to TimeSource.Monotonic.
Constructors
Creates a writer that writes to stream, as in file logging.
Types
Functions
Returns whether this writer has a channel with the same name as channel.
Creates a channel whose schema is inferred from the reified type T, type arguments included. Prefer this to the KClass overload, which loses them.
Creates a channel with the given name and schema, and adds it to the log.
Creates a channel with the given name and a schema inferred from cls by reflection.
Nanoseconds elapsed on timeSource since this writer was created.
Writes an object to a channel identified by name, inferring the schema from the object's runtime class.