Skip to content
This repository has been archived by the owner on Aug 9, 2022. It is now read-only.

edgurgel/watcher

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Watcher

Build Status Hex.pm Coverage Status

Watcher will monitor a GenEvent manager and a handler. If any of them die the watcher will stop.

If added on a supervision tree the watcher will restart, add the handler and keep processing events.

Why?

elixir-lang/elixir#2662

Installation

First, add Watcher to your mix.exs dependencies:

def deps do
  [{:watcher, "~> 1.0.0"}]
end

and run mix deps.get. Now, list the :watcher application as your application dependency:

def application do
  [applications: [:watcher]]
end

Basic Usage

Instead of adding a handler with GenEvent.add_handler(manager, handler, args) or GenEvent.add_mon_handler(manager, handler, args) just use

Watcher.start_link(manager, handler, args)

Or add to a supervision tree

worker(Watcher, [manager, handler, args])

Watcher will also accept the same options that a GenServer accepts (name, debug, etc)