221V 3 лет назад
Родитель
Сommit
a05937adf1
4 измененных файлов с 30 добавлено и 16 удалено
  1. 1 1
      ebin/n4u.app
  2. 0 14
      src/handlers/n2o_mq.erl
  3. 28 0
      src/handlers/n4u_mq.erl
  4. 1 1
      src/wf.erl

+ 1 - 1
ebin/n4u.app

@@ -2,7 +2,7 @@
   {description, "N4U WebSocket Application Server"},
   {vsn, "4.4.20"},
   {applications, [kernel, stdlib, asn1, public_key, ssl, crypto, ranch, cowboy, fs, active, sh, gproc, nitro]},
-  {modules, [n2o, n4u_app, n4u_sup, n4u_async, n2o_xhr, n4u_cx, n2o_cowboy, n2o_multipart, n2o_static, n2o_stream, n4u_document, n2o_proto, n2o_relay, n4u_error, n4u_io, n4u_log, n2o_mq, n2o_pickle, n2o_query, n2o_secret, n2o_session, n2o_syn, n4u_client, n2o_file, n4u_heart, n4u_http, n2o_nitrogen, n2o_text, wf, wf_convert, wf_utils]},
+  {modules, [n2o, n4u_app, n4u_sup, n4u_async, n2o_xhr, n4u_cx, n2o_cowboy, n2o_multipart, n2o_static, n2o_stream, n4u_document, n2o_proto, n2o_relay, n4u_error, n4u_io, n4u_log, n4u_mq, n2o_pickle, n2o_query, n2o_secret, n2o_session, n2o_syn, n4u_client, n2o_file, n4u_heart, n4u_http, n2o_nitrogen, n2o_text, wf, wf_convert, wf_utils]},
   {registered, [n4u_sup]},
   {mod, {n4u_app, []}},
   {env, []}

+ 0 - 14
src/handlers/n2o_mq.erl

@@ -1,14 +0,0 @@
--module(n2o_mq).
--include_lib("n4u/include/n4u.hrl").
--export([send/2, reg/1, reg/2, unreg/1]).
-
-send(Pool, Message) -> gproc:send({p,l,Pool},Message).
-reg(Pool) -> reg(Pool,undefined).
-reg(Pool, Value) ->
-    case get({pool,Pool}) of
-         undefined -> gproc:reg({p,l,Pool},Value), put({pool,Pool},Pool);
-         _Defined -> skip end.
-unreg(Pool) ->
-    case get({pool,Pool}) of
-         undefined -> skip;
-         _Defined -> gproc:unreg({p,l,Pool}), erase({pool,Pool}) end.

+ 28 - 0
src/handlers/n4u_mq.erl

@@ -0,0 +1,28 @@
+-module(n4u_mq).
+
+-export([send/2, reg/1, reg/2, unreg/1]).
+
+
+send(Pool, Message) -> gproc:send({p, l, Pool}, Message).
+
+
+reg(Pool) -> reg(Pool, undefined).
+
+reg(Pool, Value) ->
+  case erlang:get({pool, Pool}) of
+    undefined ->
+      gproc:reg({p, l, Pool}, Value),
+      erlang:put({pool, Pool}, Pool);
+    
+    _Defined -> skip
+  end.
+
+
+unreg(Pool) ->
+  case erlang:get({pool,Pool}) of
+    undefined -> skip;
+    _Defined ->
+      gproc:unreg({p, l, Pool}),
+      erlang:erase({pool, Pool})
+  end.
+

+ 1 - 1
src/wf.erl

@@ -79,7 +79,7 @@ header(K,V) -> wf:context((?CTX)#cx{req=wf:header(K,V,?REQ)}).
 % Message Bus communications wf:reg wf:send
 
 -ifndef(REGISTRATOR).
--define(REGISTRATOR, (wf:config(n2o,mq,n2o_mq))).
+-define(REGISTRATOR, (wf:config(n4u, mq, n4u_mq))).
 -endif.
 
 send(Pool, Message) -> ?REGISTRATOR:send(Pool,Message).