erlang

Erlang : Mnesia : Updating a single field value in a row

你。 提交于 2019-12-22 05:03:43
问题 I have an mnesia table with three fields, i, a and b, created using the record -record(rec, {i, a,b}). Now I insert a row into the table as: mnesia:transaction( fun() -> mnesia:write("T", #rec{i=1, a=2, b=3}, write) end ). Now what do I do if I want to update this row, and change only the value of a to 10, while leaving i and b with the same values? Is there any SQL equivalent like " UPDATE T SET a=10 WHERE i=1 "? If I do something like this: mnesia:transaction( fun() -> mnesia:write("T",

How to develop custom functions on top of Ejabberd?

青春壹個敷衍的年華 提交于 2019-12-22 04:46:09
问题 I'm developing a real time chat app. After searching around for a while, I found Ejabberd and Erlang is a good option. The question is the Ejabberd is not providing all the functions I need. I need some custom features such as location based matching and anonymous login. So how to development custom functions on top of Ejabberd? write modules for it? or develop another standalone server app (web or other kind of server app) to interact with it? update: another concern is the way we add custom

Why use OTP with erlang?

浪尽此生 提交于 2019-12-22 04:26:05
问题 As the question said: What benefits brings using the OTP design principles when developing with erlang? (I am developing a server which will just receive commands and send responses) 回答1: OTP is a battle-hardened set of design elements and idioms used in the creation of, as Jonas said, fault-tolerant systems among other things (like flexibility, live updates, etc.). In brief you want to use it for these environments, or environments that may grow into these, because a lot of the blood, sweat

rebar unable to get dependency from github

断了今生、忘了曾经 提交于 2019-12-22 04:07:33
问题 I am unable to get any dependency from github using rebar. rebar.config file: {sub_dirs, ["rel"]}. {deps_dir, ["deps"]}. {erl_opts, [debug_info]}. {deps, [ {thrift_erl, "0.5.0", {git, "git://github.com/xslogic/thrift_erl", "HEAD"}}, {eleveldb, "1.0.1", {git, "git://github.com/xslogic/eleveldb", "HEAD"}} ]}. When I do ./rebar compile I get: Dependency not available: thrift_erl-0.5.0 ({git, "git://github.com/xslogic/thrift_erl", "HEAD"}) Dependency not available: eleveldb-1.0.1 ({git, "git:/

rebar unable to get dependency from github

你说的曾经没有我的故事 提交于 2019-12-22 04:07:00
问题 I am unable to get any dependency from github using rebar. rebar.config file: {sub_dirs, ["rel"]}. {deps_dir, ["deps"]}. {erl_opts, [debug_info]}. {deps, [ {thrift_erl, "0.5.0", {git, "git://github.com/xslogic/thrift_erl", "HEAD"}}, {eleveldb, "1.0.1", {git, "git://github.com/xslogic/eleveldb", "HEAD"}} ]}. When I do ./rebar compile I get: Dependency not available: thrift_erl-0.5.0 ({git, "git://github.com/xslogic/thrift_erl", "HEAD"}) Dependency not available: eleveldb-1.0.1 ({git, "git:/

How to parse config file with erlang?

♀尐吖头ヾ 提交于 2019-12-22 02:22:05
问题 i am developing one program with erlang, which need to read config file when starting, then load the config data to database. originally, using Ruby or C i can load YAML file or conf file. I want to know, in erlang's world, is there any good way to load config file? thanks! This is the YAML-Style file I need to load, and i do not care the style of the config file a: a1: a2: 1 a3: 2 b: b1: b2: 3 b3: 4 回答1: If you store the config data as Erlang terms you can use the built-in file:consult/1

Erlang : Disallowed Nodes / Maybe Cookie question

六月ゝ 毕业季﹏ 提交于 2019-12-22 01:53:59
问题 Trying to get two erlang nodes talking to each other : one on a Ubuntu machine and one on Windows XP. We're getting a " Connection attempt from disallowed node " message which prevents one node receiving messages from the other. They're both using 5.XXX versions of Erlang OTP. Both nodes have the same cookie ( .erlang.cookie) We are starting the receiver node with : erl -name fred@ipaddress and calling the function on it with 'fred@ipaddress' (in single quotes) We've turned firewalls off. So

Creating mnesia disk_copies of existing ram table

梦想的初衷 提交于 2019-12-21 22:02:48
问题 I have a complete mnesia ram_copies-only database but I am experiencing problems adding a disk_copy table to a node. At the moment I do: Create all my ram_copy tables/nodes Start mnesia on the disk_copy-to-be node. Create a new schema (I didnt create a schema for the ram_copy tables) using mnesia:create_schema([Node]) Copy the table I wish to be a disk_copy, using mnesia:add_table_copy(table, Node, disk_copy) I then wait for the tables to be created Everything seems to go according to plan

Running the report browser (rb) for SASL error reports whilst in a remote shell

被刻印的时光 ゝ 提交于 2019-12-21 20:47:54
问题 Folks we are now delploying a lot of Erlang instances and we are seeing bugs been thrown and would like to examine them... Normally we connect to the running instance with a remote shell and get access to an Erlang console that way, but this doesn't work for rb or error messages... How do I get remote access to my SASL error messages without dropping the server, starting it non-detached and looking at the shell? 回答1: I ran into this back in R11B and ended up creating a clone of rb that works

How to automatically launch needed services and apps?

六月ゝ 毕业季﹏ 提交于 2019-12-21 19:57:35
问题 I am writing my first erlang application and I want to do things the way they should be done in the erlang ecosystem. My app depends on ssl, inets services and log4erl application to be already started and as for now I start them manually in the erlang shell. After that I start my app's supervisor that starts other parts. The question is how should I organize things so that there would be no need to start ssl, inets and log4erl manually ? 回答1: You should try Erlang release handling system.