Skip to content
/ dirq Public

An almost-FIFO, filesystem directory based queue, translated into Elixir from the Perl library Directory::Queue

License

Notifications You must be signed in to change notification settings

pzingg/dirq

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Dirq

An almost-FIFO, filesystem directory based queue, translated from the Perl library Directory::Queue

Installation

If available in Hex, the package can be installed by adding dirq to your list of dependencies in mix.exs:

def deps do
  [
    {:dirq, "~> 0.1.0"}
  ]
end

Usage

A simple producer:

queue = Dirq.Queue.new("/tmp/test")
Enum.each(1..100, fn i ->
  name = Dirq.Queue.add(queue, %{data: "element " <> to_string(i)}, :json_atoms)
  IO.puts("added element " <> to_string(i) <> " as " <> name)
end)

A simple consumer:

Dirq.Queue.iterate(queue) |> Enum.each(fn name ->
  if Dirq.Queue.lock(queue, name) do
    IO.puts("reading element " <> name)
    Dirq.Queue.get(queue, name, :json_atoms) |> IO.inspect()
    Dirq.Queue.remove(queue, name)
    # Or use Dirq.Queue.unlock(queue, name) to peek at data
  end
end)

About

An almost-FIFO, filesystem directory based queue, translated into Elixir from the Perl library Directory::Queue

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages