Skip to content

zeam-vm/worker_pool

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

WorkerPool

A pool module for user-defined workers.

Example

The following module is a sample worker module, which sends :ok and a doubled list of each element to the host process after being called.

defmodule SampleWorker do
  use WorkerPool.Worker

  @impl true
  def work({pid, list}), do: send(pid, {:ok, Enum.map(list, & &1 * 2)})
end
WorkerPool.start_link(SampleWorker)

WorkerPool.get_worker(SampleWorker) |> send({:work, {self(), [1, 2, 3]}})
receive do
  {:ok, result} -> IO.inspect result
  after 1000 -> IO.puts "Timeout"
end

Installation

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

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

Documentation can be generated with ExDoc and published on HexDocs. Once published, the docs can be found at https://hexdocs.pm/worker_pool.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages