// Copyright 2017 Alexander Gallego // include "timestamp.fbs"; namespace smf.wal; // TAG: alpha enum wal_entry_compression_type:byte { none, zstd } struct wal_header { compression: wal_entry_compression_type = none; size: uint = 0; checksum: uint = 0; } struct wal_invalid_entry { invalid_entry: ulong; } enum tx_put_operation:byte { begin, data, commit, abort, /// \brief either the end of the txn OR a full transaction that is a small payload /// i.e.: fits in one request full } enum tx_put_invalidation_reason:byte { server_connection_timeout, client_connection_timeout } table tx_put_invalidation { reason: tx_put_invalidation_reason; /// iff this->op == tx_put_operation::abort /// use to write an abort, for a specific offset /// This is the offset from the tx_put_reply. offset: ulong; } table tx_put_kv { key: [ubyte]; value: [ubyte]; } union tx_put_data { tx_put_kv, tx_put_invalidation} /// This is the datastructure that gets persisted on disk. /// Please be tender while extending table tx_put_fragment { /// what should we do with this trasaction fragment op: tx_put_operation; /// sequence id client_seq: ulong; /// In seastar clients we will use a losely ticked timer which moves /// every 10 micros. /// This is needed for systems doing window aggregations, etc. /// epoch: smf.timestamp; data: tx_put_data; } table tx_put_partition_pair { /// xxhash32(topic, tx_put_fragment::data::key) partition: uint (key); txs: [tx_put_fragment]; } /// brief - stores `puts` transactionally table tx_put_request { topic: string; data: [tx_put_partition_pair]; } table tx_put_reply { /// \brief the committed offset into the WAL offset: ulong; } table tx_get_request { topic: string; partition: uint; offset: ulong; /// (1 << 31) - 1 Max payload payload by flatbuffers 2GB-1 /// we decrease it by 100 bytes so we can stuff headers in there /// plus plenty of room for growth /// /// >>> (2**31)-100 /// 2147483548 /// max_bytes: uint = 2147483548; } /// \brief the broker might have decided to compress the tx_put_fragment. /// table tx_get_fragment { hdr: wal_header; fragment: [ubyte]; } table tx_get_reply { next_offset: ulong; gets: [tx_get_fragment]; }