batch_please v0.4.2 BatchPlease.FileBatcher

Link to this section Summary

Types

The state of a single FileBatcher batch

Items can be of any type that is representable with the given encode and decode functions (which, by default, use JSON)

Functions

Callback to create a new FileBatcher batch

Link to this section Types

Link to this type batch()
batch() :: %{opts: Keyword.t, filename: String.t, file: File.io_device, encode: (item -> {:ok, binary} | {:error, String.t})}

The state of a single FileBatcher batch.

filename is a string holding the name of the file containing items from the current batch.

file is a filehandle to the current batch file.

encode is a function which takes an item as input and encodes it into string format. It returns either {:ok, encoded_item} or {:error, message}. Defaults to [Poison.encode/1](https://hexdocs.pm/poison/3.1.0/Poison.html#encode/1).decodeis a function which takes a string-encoded item as input and decodes it, returning eitheror. Defaults to [Poison.decode/1`](https://hexdocs.pm/poison/3.1.0/Poison.html#decode/1).

Link to this type item()
item() :: any

Items can be of any type that is representable with the given encode and decode functions (which, by default, use JSON).

Link to this section Functions

Link to this function batch_init(opts)

Callback to create a new FileBatcher batch.

opts[:batch_directory] can be used to specify where to put batch files (default /tmp).

opts[:encode] can be used to manually specify an encoder function.