如果我的状态不改变,是否需要OTP? [英] is OTP needed if my state does not change?
问题描述
最好的打包方式是什么,以便其他应用程序使用? / strong>
需要考虑的其他一些事情:
- 没有数据争用问题或改变状态,所以似乎不需要gen_server。
- 我喜欢可以调用
应用程序:start / 1
并且有东西正常工作。 - 某些进程应该拥有ets表。看来我不应该把它留在客户端代码中。
以上引导我认为我应该创建一个应用程序,从主管的 init / 1
函数调用安装代码,但我不确定这是否是一个愚蠢的方法来处理它。
如果模块是完全静态的,那么在这样的应用程序中不需要任何进程。如果您在OTP中实现应用程序
行为,则应该能够将ETS表直接连接到主应用程序进程(启动应用程序中的表 start / 2
回调)。这样,您将拥有一个最小的流程模型,允许您跳过主管
和任何 gen_server
。
你一定要使用OTP,但这并不意味着你绝对必须有一个主管
或$ code> gen_server 。
使用 I have an erlang project whose state is entirely read only, and composed of ets tables and a compiled module. It takes a few seconds to build the tables when the code starts. What is the best way to package this so it can be used by other applications? Some other things to consider: The above leads me to think I should create an application, and call the setup code from the supervisor's If the module is entirely static you won't need any processes in such an application. If you implement the You should certainly use OTP, but that doesn't mean that you absolutely must have a Use 这篇关于如果我的状态不改变,是否需要OTP?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
。
application:start/1
and have things "just work".init/1
function, but I'm unsure if this is a silly way to approach it.application
behavior in OTP you should be able to connect the ETS tables directly to the main application process (initiate the tables in the application start/2
callback). That way you'll have a minimal process model, allowing you to skip both the supervisor
and any gen_server
.supervisor
or a gen_server
.appmon
to view the process hierarchy of your application.