Simplepq v0.1.0 Simplepq View Source

Simple queue that’s stored on the disc.

Warning! At this moment all functions don’t handle case when the file don’t exist. Errors can be raised.

Link to this section Summary

Functions

Adds elemet to the end of queue

Creates file on the filesystem and create Simplepq.Queue associated with this file

Reads first element from queue without removing

Return count elemens in the queue

Opens queue from file file_path

Rejects first elemet from the the queue. This method don’t return elemnt and don’t have special return for the case when queue is empty. It’s just return this queue

Link to this section Functions

Link to this function add(queue, message) View Source
add(Simplepq.Queue, String.t()) ::
  {:ok, queue :: Simplepq.Queue} | {:error, :file.posix()}

Adds elemet to the end of queue.

Returns {:ok, queue} if element added, else {:error, :file.posix()}.

Link to this function create(file_path) View Source
create(String.t()) :: {:ok, queue :: Simplepq.Queue} | {:error, :file.posix()}

Creates file on the filesystem and create Simplepq.Queue associated with this file.

Returns {:ok, queue} in case of success, else {:error, :file.posix()}.

Link to this function get(queue) View Source
get(Simplepq.Queue) :: {:ok, message :: String.t()} | {:error, :empty}

Reads first element from queue without removing.

Returns {:ok, message} if element exists, or {:error, :empty} when queue is empty.

Link to this function length(queue) View Source
length(Simplepq.Queue) :: number()

Return count elemens in the queue.

Opens queue from file file_path.

Returns {:ok, queue} in case of success, or {:error, :bad_file} when file can not be converted to term or term is not .

Link to this function reject(queue) View Source
reject(Simplepq.Queue) ::
  {:ok, queue :: Simplepq.Queue} | {:error, :file.posix()}

Rejects first elemet from the the queue. This method don’t return elemnt and don’t have special return for the case when queue is empty. It’s just return this queue.

Returns {:ok, queue} if element successfully rejected or queue is empty. Else {:error, reason} when caused problem on writing the file