Tarantool Lua API

xlog

The xlog module provides the pairs() and meta() functions for reading Tarantool's snapshot files or write-ahead-log (WAL) files. A description of the file format is in the "Data persistence" section of the Tarantool documentation.

Methods2

function M.pairs(filename: string) -> iterator fun(...) -> ...integer

Open a file, and allow iterating over one file entry at a time.

Each result from pairs() is formatted with MsgPack so its structure can be specified with __serialize.

Example:

xlog = require('xlog')
t = {}
for k, v in xlog.pairs('00000000000000000004.xlog') do
    table.insert(t, setmetatable(v, { __serialize = 'map' }))
end
return t

The result will look like this:

--
- - {'HEADER': {'lsn': 5, 'replica_id': 1, 'type': 'INSERT',
                'timestamp': 1794563695.9269},
    'BODY': {'space_id': 512, 'tuple': [2]}}
...

Possible errors: the file does not contain properly formatted snapshot or write-ahead-log information.

Parameters
filenamestring

The name of a snapshot or write-ahead-log file.

Returns
iteratorfun(...) -> ...integer

which can be used in a for/end loop.

function M.meta(filename: string) -> meta xlog.meta

Open an xlog file and return its meta block.

Possible errors: failed to open a file, or the file does not contain a properly formatted meta block.

Example:

xlog.meta('00000000000000000000.snap')
Parameters
filenamestring

The name of a snapshot or write-ahead-log file.

Returns
metaxlog.meta

The meta block of the file.