Comments (9)
Here's an example how it could be done, very easy :/.
https://github.com/fishcakez/agent_telnet/blob/code_change/rel/agent_telnet.appup
https://github.com/fishcakez/agent_telnet/blob/code_change/lib/agent_telnet/supervisor.ex#L9-10
https://github.com/fishcakez/agent_telnet/blob/code_change/lib/agent_telnet/protocol.ex#L34-L36
fishcakez@407255f
from xgen.
very easy :/
Do you mean "very easy :)" or "not very easy :/" ? :P
from xgen.
I mean very easy, :/ because API is not very nice.
On 11 April 2014 19:51, José Valim [email protected] wrote:
very easy :/
Do you mean "very easy :)" or "not very easy :/" ? :P
Reply to this email directly or view it on GitHubhttps://github.com//issues/10#issuecomment-40240610
.
from xgen.
Ah, got it. I still think we should allow a { M, F, A } to be given as state in code change and simply apply that to the state. And starting considering allowing { M, F, A } everywhere else too.
from xgen.
do you mean?
code_change(_vsn, state, { m, f, a }), do: { :ok, Kernel.apply(m, f, [state | a]) }
{update, module, { advanced, { m, f, [a] } }}
That works very nicely!
from xgen.
Yes, exactly!
from xgen.
We just need to work on it and write a test.
from xgen.
This ones free
test ":sys.change_code/4 with mfa" do
{ :ok, pid } = Agent.start_link(fn -> %{} end)
:ok = :sys.suspend(pid)
mfa = { Map, :put, [:hello, :world] }
assert :sys.change_code(pid, __MODULE__, "vsn", mfa) == :ok
:ok = :sys.resume(pid)
assert Agent.get(pid, &Map.get(&1, :hello)) == :world
assert Agent.stop(pid) == :ok
end
test ":sys.change_code/4 with raising mfa" do
{ :ok, pid } = Agent.start_link(fn -> %{} end)
:ok = :sys.suspend(pid)
mfa = { :erlang, :error, [] }
assert match?({ :error, _ }, :sys.change_code(pid, __MODULE__, "vsn", mfa))
:ok = :sys.resume(pid)
assert Agent.get(pid, &(&1)) == %{}
assert Agent.stop(pid) == :ok
end
from xgen.
The test cases worked like a charm! Thank you!
from xgen.
Related Issues (10)
- Decide if agents should run in a distributed environment or not
- PubSub HOT 1
- Add Task.find/2
- Make server naming more consistent HOT 4
- Task.Sup abbreviation is unclear
- Task.Node HOT 6
- Task.find/2 exit reason has wrong mfa and stacktrace HOT 3
- GenEvent.stream/1 leaks messages when duration or timeout is not infinity HOT 1
- Decide if GenServer.async_call/2 should stay or if it should go HOT 1
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 xgen.