Comments (3)
@cjimison yes, but it's not super clear how to do it because I've got a bit of work to do in naming and documentation. This is what you are looking for:
defmodule MyApp.Supervisor do
def init([]) do
children = [
worker(Discovery.Poller, ["my_service", [
{Discovery.Handler.NodeConnect, [
{MyEventHandler, []}
]}
]], id: :my_service),
]
supervise(children, strategy: :one_for_one)
end
end
defmodule MyEventHandler do
use Discovery.NodeConnector.Handler
def on_connect(node, service, state), do: state
def on_disconnect(node, service, state), do: state
end
The event handler will fire each time a connect / disconnect event is fired
from discovery.
Bad ass, this is exactly what I needed to know! I saw the NodeConnector.Handler in the code base, just wasn’t sure how add my own via the publicly exposed API (and I am now happily reverting my hacks :).
Thanks for the help!
-Chris
On Apr 8, 2015, at 11:16 AM, Jamie Winsor [email protected] wrote:
defmodule MyEventHandler do
use Discovery.NodeConnector.Handlerdef on_connect(node, service, state), do: state
def on_disconnect(node, service, state), do: state
end
from discovery.
@cjimison no problem at all, this is something I need to make more clear in the documentation!
from discovery.
Related Issues (7)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from discovery.