Comments (4)
You can pass a gen_server_opts: :runtime
to defstart
:
def MyServer do
defstart start_link(arg1, arg2), gen_server_opts: :runtime do
# ...
end
# ...
end
Now, your start_link
accepts three arguments: arg1
, arg2
, and GenServer options, so you can do the following:
MyServer.start_link(arg1, arg2, name: {:via, Registry, {MyRegistry, some_name}})
from exactor.
from exactor.
Normally, defcast
and defcall
take the server as the first argument, so you can pass the same via tuple as in start_link
. That's of course clumsy, because the clients must be aware of the exact shape of the via tuple.
If you want to wrap that knowledge inside the GenServer module, you can use private versions of defcastp
and defcallp
and wrap them with a plain function:
def MyServer do
def some_op(name, arg1, arg2), do: some_op_cast(via_tuple(name), arg1, arg2)
defcastp some_op_cast(arg1, arg2, ...) do
# ...
end
defp via_tuple(name), do:
{:via, Registry, {MyRegistry, some_name}}
end
Unfortunately, at this point ExActor doesn't really give you much compared to plain GenServer. ExActor only helps for the simplest cases where all arguments are passed as is. As soon as you somehow need to transform those arguments, it will be pretty much the same amount of code as with GenServer. This is the reason why I mostly stopped using ExActor myself. It sometimes help, but not always, so it seems to me that using a plain GenServer is generally a better way, because it's less magical and standard part of Elixir.
from exactor.
nod I understand, thank you.
from exactor.
Related Issues (19)
- function undefined error at elixir v0.11.0 HOT 2
- Can't build docs for project what uses exactor HOT 1
- Any roadmap to supervise the started actor? HOT 5
- DSL for :local, :global name registration from supervisor's spec HOT 3
- Pass timeout parameter HOT 3
- how does it differ from elixir agent HOT 7
- stop_server not usable from within defstart HOT 4
- Elixir > 1.2 throws compile-time warnings for unused variables HOT 3
- defcall can not use in quote HOT 3
- Struct pattern matching error HOT 3
- `export:` only accept atom.
- Testing support HOT 11
- Possibility of custom process registration dispatching logic? HOT 7
- Support for Elixir 1.5 @impl HOT 4
- Generate typespecs as well HOT 1
- Broken link in README
- Unused variable warnings when variables created in map pattern match HOT 1
- Why was ExActor not a good idea? HOT 5
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 exactor.