# Module cloudi_write_ahead_logging

- Description
- Data Types
- Function Index
- Function Details

### CloudI Write Ahead Logging (WAL)

File storage for transaction logging done by cloudi_service_queue.

Copyright © 2014-2021 Michael Truog

Version: 2.0.2 May 27 2021 01:43:07 ------------------------------------------------------------------------

Authors: Michael Truog (`mjtruog at protonmail dot com`).

## Description

### CloudI Write Ahead Logging (WAL)

File storage for transaction logging done by cloudi_service_queue. No disk index is maintained, but an in-memory index is kept.

## Data Types

### checksum_algorithms()

`checksum_algorithms() = crc32 | md5 | ripemd160 | sha | sha224 | sha256 | sha384 | sha512`

### non_neg_integer_64bit()

`non_neg_integer_64bit() = 0..18446744073709551615`

### pos_integer_64bit()

`pos_integer_64bit() = 1..18446744073709551615`

### retry_function()

`retry_function() = fun((Chunk::cloudi_service_queue:request(), Retry::boolean()) -> {ok, cloudi_service:trans_id()} | {error, timeout})`

### state()

`state() = #state{file = string(), file_size_limit = pos_integer_64bit(), compression = 0..9, checksum = undefined | checksum_algorithms(), checksum_size = pos_integer_64bit(), position = non_neg_integer(), chunks = #{cloudi_service:trans_id() := #chunk{size = pos_integer_64bit(), position = non_neg_integer_64bit(), request = cloudi_service_queue:request() | undefined, retries = non_neg_integer()}}, chunks_free = [#chunk{size = pos_integer_64bit(), position = non_neg_integer_64bit(), request = cloudi_service_queue:request() | undefined, retries = non_neg_integer()}]}`

### update_function()

`update_function() = fun((cloudi_service_queue:request()) -> {cloudi_service:trans_id(), cloudi_service_queue:request()} | undefined)`

## Function Index

erase/2 |
erase_retry/4 |
fetch_keys/1 |
new/5 |
size/1 |
size_free/1 |
store_end/3 |
store_fail/2 |
store_start/2 |
update/3 |

## Function Details

### erase/2

`erase(ChunkId::cloudi_service:trans_id(), State::#state{file = string(), file_size_limit = pos_integer_64bit(), compression = 0..9, checksum = undefined | checksum_algorithms(), checksum_size = pos_integer_64bit(), position = non_neg_integer(), chunks = #{cloudi_service:trans_id() := #chunk{size = pos_integer_64bit(), position = non_neg_integer_64bit(), request = cloudi_service_queue:request() | undefined, retries = non_neg_integer()}}, chunks_free = [#chunk{size = pos_integer_64bit(), position = non_neg_integer_64bit(), request = cloudi_service_queue:request() | undefined, retries = non_neg_integer()}]}) -> {cloudi_service_queue:request(), #state{file = string(), file_size_limit = pos_integer_64bit(), compression = 0..9, checksum = undefined | checksum_algorithms(), checksum_size = pos_integer_64bit(), position = non_neg_integer(), chunks = #{cloudi_service:trans_id() := #chunk{size = pos_integer_64bit(), position = non_neg_integer_64bit(), request = cloudi_service_queue:request() | undefined, retries = non_neg_integer()}}, chunks_free = [#chunk{size = pos_integer_64bit(), position = non_neg_integer_64bit(), request = cloudi_service_queue:request() | undefined, retries = non_neg_integer()}]}}`

### erase_retry/4

`erase_retry(ChunkId::cloudi_service:trans_id(), RetryMax::non_neg_integer(), RetryF::retry_function(), State::#state{file = string(), file_size_limit = pos_integer_64bit(), compression = 0..9, checksum = undefined | checksum_algorithms(), checksum_size = pos_integer_64bit(), position = non_neg_integer(), chunks = #{cloudi_service:trans_id() := #chunk{size = pos_integer_64bit(), position = non_neg_integer_64bit(), request = cloudi_service_queue:request() | undefined, retries = non_neg_integer()}}, chunks_free = [#chunk{size = pos_integer_64bit(), position = non_neg_integer_64bit(), request = cloudi_service_queue:request() | undefined, retries = non_neg_integer()}]}) -> #state{file = string(), file_size_limit = pos_integer_64bit(), compression = 0..9, checksum = undefined | checksum_algorithms(), checksum_size = pos_integer_64bit(), position = non_neg_integer(), chunks = #{cloudi_service:trans_id() := #chunk{size = pos_integer_64bit(), position = non_neg_integer_64bit(), request = cloudi_service_queue:request() | undefined, retries = non_neg_integer()}}, chunks_free = [#chunk{size = pos_integer_64bit(), position = non_neg_integer_64bit(), request = cloudi_service_queue:request() | undefined, retries = non_neg_integer()}]}`

### fetch_keys/1

`fetch_keys(State::#state{file = string(), file_size_limit = pos_integer_64bit(), compression = 0..9, checksum = undefined | checksum_algorithms(), checksum_size = pos_integer_64bit(), position = non_neg_integer(), chunks = #{cloudi_service:trans_id() := #chunk{size = pos_integer_64bit(), position = non_neg_integer_64bit(), request = cloudi_service_queue:request() | undefined, retries = non_neg_integer()}}, chunks_free = [#chunk{size = pos_integer_64bit(), position = non_neg_integer_64bit(), request = cloudi_service_queue:request() | undefined, retries = non_neg_integer()}]}) -> [cloudi_service:trans_id()]`

### new/5

`new(FilePath::string(), FileSizeLimit::1024..18446744073709551615, Compression::0..9, Checksum::undefined | checksum_algorithms(), RetryF::retry_function()) -> #state{file = string(), file_size_limit = pos_integer_64bit(), compression = 0..9, checksum = undefined | checksum_algorithms(), checksum_size = pos_integer_64bit(), position = non_neg_integer(), chunks = #{cloudi_service:trans_id() := #chunk{size = pos_integer_64bit(), position = non_neg_integer_64bit(), request = cloudi_service_queue:request() | undefined, retries = non_neg_integer()}}, chunks_free = [#chunk{size = pos_integer_64bit(), position = non_neg_integer_64bit(), request = cloudi_service_queue:request() | undefined, retries = non_neg_integer()}]}`

### size/1

`size(State::#state{file = string(), file_size_limit = pos_integer_64bit(), compression = 0..9, checksum = undefined | checksum_algorithms(), checksum_size = pos_integer_64bit(), position = non_neg_integer(), chunks = #{cloudi_service:trans_id() := #chunk{size = pos_integer_64bit(), position = non_neg_integer_64bit(), request = cloudi_service_queue:request() | undefined, retries = non_neg_integer()}}, chunks_free = [#chunk{size = pos_integer_64bit(), position = non_neg_integer_64bit(), request = cloudi_service_queue:request() | undefined, retries = non_neg_integer()}]}) -> non_neg_integer()`

### size_free/1

`size_free(State::#state{file = string(), file_size_limit = pos_integer_64bit(), compression = 0..9, checksum = undefined | checksum_algorithms(), checksum_size = pos_integer_64bit(), position = non_neg_integer(), chunks = #{cloudi_service:trans_id() := #chunk{size = pos_integer_64bit(), position = non_neg_integer_64bit(), request = cloudi_service_queue:request() | undefined, retries = non_neg_integer()}}, chunks_free = [#chunk{size = pos_integer_64bit(), position = non_neg_integer_64bit(), request = cloudi_service_queue:request() | undefined, retries = non_neg_integer()}]}) -> non_neg_integer()`

### store_end/3

`store_end(ChunkId::cloudi_service:trans_id(), Chunk::#chunk{size = pos_integer_64bit(), position = non_neg_integer_64bit(), request = cloudi_service_queue:request() | undefined, retries = non_neg_integer()}, State::#state{file = string(), file_size_limit = pos_integer_64bit(), compression = 0..9, checksum = undefined | checksum_algorithms(), checksum_size = pos_integer_64bit(), position = non_neg_integer(), chunks = #{cloudi_service:trans_id() := #chunk{size = pos_integer_64bit(), position = non_neg_integer_64bit(), request = cloudi_service_queue:request() | undefined, retries = non_neg_integer()}}, chunks_free = [#chunk{size = pos_integer_64bit(), position = non_neg_integer_64bit(), request = cloudi_service_queue:request() | undefined, retries = non_neg_integer()}]}) -> #state{file = string(), file_size_limit = pos_integer_64bit(), compression = 0..9, checksum = undefined | checksum_algorithms(), checksum_size = pos_integer_64bit(), position = non_neg_integer(), chunks = #{cloudi_service:trans_id() := #chunk{size = pos_integer_64bit(), position = non_neg_integer_64bit(), request = cloudi_service_queue:request() | undefined, retries = non_neg_integer()}}, chunks_free = [#chunk{size = pos_integer_64bit(), position = non_neg_integer_64bit(), request = cloudi_service_queue:request() | undefined, retries = non_neg_integer()}]}`

### store_fail/2

`store_fail(Chunk::#chunk{size = pos_integer_64bit(), position = non_neg_integer_64bit(), request = cloudi_service_queue:request() | undefined, retries = non_neg_integer()}, State::#state{file = string(), file_size_limit = pos_integer_64bit(), compression = 0..9, checksum = undefined | checksum_algorithms(), checksum_size = pos_integer_64bit(), position = non_neg_integer(), chunks = #{cloudi_service:trans_id() := #chunk{size = pos_integer_64bit(), position = non_neg_integer_64bit(), request = cloudi_service_queue:request() | undefined, retries = non_neg_integer()}}, chunks_free = [#chunk{size = pos_integer_64bit(), position = non_neg_integer_64bit(), request = cloudi_service_queue:request() | undefined, retries = non_neg_integer()}]}) -> #state{file = string(), file_size_limit = pos_integer_64bit(), compression = 0..9, checksum = undefined | checksum_algorithms(), checksum_size = pos_integer_64bit(), position = non_neg_integer(), chunks = #{cloudi_service:trans_id() := #chunk{size = pos_integer_64bit(), position = non_neg_integer_64bit(), request = cloudi_service_queue:request() | undefined, retries = non_neg_integer()}}, chunks_free = [#chunk{size = pos_integer_64bit(), position = non_neg_integer_64bit(), request = cloudi_service_queue:request() | undefined, retries = non_neg_integer()}]}`

### store_start/2

`store_start(ChunkRequest::cloudi_service_queue:request(), State::#state{file = string(), file_size_limit = pos_integer_64bit(), compression = 0..9, checksum = undefined | checksum_algorithms(), checksum_size = pos_integer_64bit(), position = non_neg_integer(), chunks = #{cloudi_service:trans_id() := #chunk{size = pos_integer_64bit(), position = non_neg_integer_64bit(), request = cloudi_service_queue:request() | undefined, retries = non_neg_integer()}}, chunks_free = [#chunk{size = pos_integer_64bit(), position = non_neg_integer_64bit(), request = cloudi_service_queue:request() | undefined, retries = non_neg_integer()}]}) -> {#chunk{size = pos_integer_64bit(), position = non_neg_integer_64bit(), request = cloudi_service_queue:request() | undefined, retries = non_neg_integer()}, #state{file = string(), file_size_limit = pos_integer_64bit(), compression = 0..9, checksum = undefined | checksum_algorithms(), checksum_size = pos_integer_64bit(), position = non_neg_integer(), chunks = #{cloudi_service:trans_id() := #chunk{size = pos_integer_64bit(), position = non_neg_integer_64bit(), request = cloudi_service_queue:request() | undefined, retries = non_neg_integer()}}, chunks_free = [#chunk{size = pos_integer_64bit(), position = non_neg_integer_64bit(), request = cloudi_service_queue:request() | undefined, retries = non_neg_integer()}]}} | full`

### update/3

`update(ChunkId::cloudi_service:trans_id(), UpdateF::update_function(), State::#state{file = string(), file_size_limit = pos_integer_64bit(), compression = 0..9, checksum = undefined | checksum_algorithms(), checksum_size = pos_integer_64bit(), position = non_neg_integer(), chunks = #{cloudi_service:trans_id() := #chunk{size = pos_integer_64bit(), position = non_neg_integer_64bit(), request = cloudi_service_queue:request() | undefined, retries = non_neg_integer()}}, chunks_free = [#chunk{size = pos_integer_64bit(), position = non_neg_integer_64bit(), request = cloudi_service_queue:request() | undefined, retries = non_neg_integer()}]}) -> {cloudi_service_queue:request() | undefined, #state{file = string(), file_size_limit = pos_integer_64bit(), compression = 0..9, checksum = undefined | checksum_algorithms(), checksum_size = pos_integer_64bit(), position = non_neg_integer(), chunks = #{cloudi_service:trans_id() := #chunk{size = pos_integer_64bit(), position = non_neg_integer_64bit(), request = cloudi_service_queue:request() | undefined, retries = non_neg_integer()}}, chunks_free = [#chunk{size = pos_integer_64bit(), position = non_neg_integer_64bit(), request = cloudi_service_queue:request() | undefined, retries = non_neg_integer()}]}}`

Generated by EDoc