josevalim / xgen Goto Github PK
View Code? Open in Web Editor NEWIntegrating Elixir, Mix and OTP
Integrating Elixir, Mix and OTP
Consider this:
def start_link(word_list) do
GenServer.start_link __MODULE__, word_list, global: :anagrams
end
def lookup(word) do
GenServer.call {:global, :anagrams}, { :lookup, word }
end
The last parameter to start_list is global: :anagrams, a keyword list.
The first parameter to GenServer.call is a tuple.
This actually makes it slightly tricky to remove duplication.
Once a stream has finished enumerating (due to a duration timeout or a event timeout) the GenEvent handler is removed. However there can be messages from that handler in the message queue. Given that a spawn is always used in examples and tests is this intentionally not resolved? A flush could be used after removing the handler:
defp flush(ref) do
receive do
{ ^ref, _ } -> flush(ref)
after
0 -> nil
end
end
We started a conversation here about PubSub/GenEvent/pg2 https://groups.google.com/forum/#!topic/elixir-lang-core/o5ZE8816zAE around building pubsub with GenEvent or PG2 or RabbitMQ and you asked me to start an issue.
Not sure GenEvent is the best thing to build abstractions over since its kind of warty. Not sure of the alternative.
The main issue is with rolling upgrades.
It is not clear what Task.Sup is for without reading docs. @josevalim suggested on IRC that Task.Supervisor is a better name.
Currently Task.find/2
exit with reasons {reason, {Task, :await, [task,0]}}
but this is not the correct mfa.
OTP
functions like :gen_server.call/2
exit in the function called so that the mfa matches the head of the stacktrace. It would be nice to do this too for Task.find/2
and perhaps elsewhere in xgen.
Task
s can only be created on other nodes if they are supervised. Could xgen
provide a task supervisor on each node started with:
Task.Sup.start_link(local: Task.Node)
Task.Node
would have the Task.Sup
API (except no documented start_link
) but take a node name as the first argument instead of a pid/name. For example:
Task.Node.async(node_name, fn() -> :ok end)
Implemented as:
defp async(node_name, task) do
Task.Sup.async({__MODULE__, node_name}, task)
end
This would allow :rpc
like functionality "for free" on all nodes.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.