6 files added
1 files modified
New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <project version="4"> |
| | | <component name="ProjectRootManager" version="2" languageLevel="JDK_1_3" default="true"> |
| | | <output url="file://$PROJECT_DIR$/out" /> |
| | | </component> |
| | | <component name="SbtLocalSettings"> |
| | | <option name="modificationStamps"> |
| | | <map> |
| | | <entry key="$USER_HOME$/IdeaProjects/play2" value="1478179325000" /> |
| | | </map> |
| | | </option> |
| | | <option name="externalProjectsViewState"> |
| | | <projects_view /> |
| | | </option> |
| | | </component> |
| | | <component name="masterDetails"> |
| | | <states> |
| | | <state key="ProjectJDKs.UI"> |
| | | <settings> |
| | | <last-edited>1.8</last-edited> |
| | | <splitter-proportions> |
| | | <option name="proportions"> |
| | | <list> |
| | | <option value="0.2" /> |
| | | </list> |
| | | </option> |
| | | </splitter-proportions> |
| | | </settings> |
| | | </state> |
| | | </states> |
| | | </component> |
| | | </project> |
New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <project version="4"> |
| | | <component name="ProjectModuleManager"> |
| | | <modules> |
| | | <module fileurl="file://$PROJECT_DIR$/moral_socket.iml" filepath="$PROJECT_DIR$/moral_socket.iml" /> |
| | | </modules> |
| | | </component> |
| | | </project> |
New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <project version="4"> |
| | | <component name="VcsDirectoryMappings"> |
| | | <mapping directory="" vcs="Git" /> |
| | | </component> |
| | | </project> |
New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <module type="ERLANG_MODULE" version="4"> |
| | | <component name="FacetManager"> |
| | | <facet type="erlang" name="Erlang"> |
| | | <configuration /> |
| | | </facet> |
| | | </component> |
| | | <component name="NewModuleRootManager" inherit-compiler-output="true"> |
| | | <exclude-output /> |
| | | <content url="file://$MODULE_DIR$"> |
| | | <sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" /> |
| | | </content> |
| | | <orderEntry type="jdk" jdkName="Erlang 19" jdkType="Erlang SDK" /> |
| | | <orderEntry type="sourceFolder" forTests="false" /> |
| | | </component> |
| | | </module> |
New file |
| | |
| | | Subproject commit 0000000000000000000000000000000000000000 |
| | | Subproject commit 42b19ded9f08910c8bcd0ee1424e9231bc6eae65 |
New file |
| | |
| | | Subproject commit 0000000000000000000000000000000000000000 |
| | | Subproject commit bb36cb3d490772fdf8d6cb3024de0e3afe4e25fb |
| | |
| | | %% API |
| | | -export([init/0]). |
| | | |
| | | %%-include_lib("eunit/include/eunit.hrl"). |
| | | %%-include("../priv/mongodb-erlang/include/mongo_protocol.hrl"). |
| | | |
| | | %-include("/Users/bin.shen/git/rabbitmq-erlang-client/include/amqp_client.hrl"). |
| | | |
| | | |
| | | init() -> |
| | | A = <<1,2>>, |
| | | B = <<3,4,5>>, |
| | | C = <<A/binary, B/binary>>, |
| | | io:format("~p~n", [C]). |
| | | %% A = <<1,2>>, |
| | | %% B = <<3,4,5>>, |
| | | %% C = <<A/binary, B/binary>>, |
| | | %% io:format("~p~n", [C]){port, 27017}, |
| | | |
| | | %% application:ensure_all_started(mongodb), |
| | | |
| | | |
| | | application:start (bson), |
| | | application:start (crypto), |
| | | application:start (poolboy), |
| | | application:start (mongodb), |
| | | |
| | | |
| | | %% Database = <<"test1">>, |
| | | %% {ok, Connection} = mc_worker_api:connect ([{database, Database}]), |
| | | %% io:format("Connection ~p~n", [Connection]), |
| | | %% |
| | | %% Collection = <<"test2">>, |
| | | %% mc_worker_api:insert(Connection, Collection, [ |
| | | %% {<<"name">>, <<"Yankees">>, <<"home">>, {<<"city">>, <<"New York">>, <<"state">>, <<"NY">>}, <<"league">>, <<"American">>}, |
| | | %% {<<"name">>, <<"Mets">>, <<"home">>, {<<"city">>, <<"New York">>, <<"state">>, <<"NY">>}, <<"league">>, <<"National">>}, |
| | | %% {<<"name">>, <<"Phillies">>, <<"home">>, {<<"city">>, <<"Philadelphia">>, <<"state">>, <<"PA">>}, <<"league">>, <<"National">>}, |
| | | %% {<<"name">>, <<"Red Sox">>, <<"home">>, {<<"city">>, <<"Boston">>, <<"state">>, <<"MA">>}, <<"league">>, <<"American">>} |
| | | %% ]), |
| | | |
| | | %% Database = <<"test1">>, |
| | | %% case mc_worker_api:connect([ |
| | | %% {database, Database}, |
| | | %% {host, "127.0.0.1"}, |
| | | %% {port, 27017} |
| | | %% ]) of |
| | | %% {ok, Connection} -> |
| | | %% io:format("Connection ~p~n", [Connection]), |
| | | %% |
| | | %% Cursor = mc_worker_api:find(Connection, <<"test2">>, {}), |
| | | %% io:format("~p cursor: ~p~n", [self(), Cursor]), |
| | | %% mc_cursor:close(Cursor); |
| | | %% |
| | | %% {error, Reason} -> |
| | | %% io:format("unable to connect to ~p: ~p~n", [Database, Reason]) |
| | | %% end, |
| | | |
| | | {ok, Connection} = mc_worker_api:connect([ |
| | | {database, <<"moral_db">>}, |
| | | {login, <<"moral_user">>}, |
| | | {password, <<"m2o0r1a6l_passw0rd">>}, |
| | | {host, "121.40.92.176"}, |
| | | {port, 27017} |
| | | ]), |
| | | |
| | | io:format("Connection is XXX : ~p~n", [Connection]), |
| | | io:format("*****************###"), |
| | | |
| | | mc_worker_api:insert(Connection, <<"alerts">>, [ |
| | | {<<"mac">>, <<"accf23b87fbf">>, <<"x1">>, <<"1">>, <<"x2">>, <<"2">>} |
| | | ]), |
| | | |
| | | %% Cursor = mc_worker_api:find_one(Connection, <<"test2">>, {}), |
| | | |
| | | |
| | | %% Cursor = mc_worker_api:find(Connection, <<"alerts">>, {}), |
| | | %% Result = mc_cursor:rest(Cursor), |
| | | %% io:format("~p~n", [Result]), |
| | | %% mc_cursor:close(Cursor), |
| | | %% mc_worker_api:disconnect(Connection), |
| | | |
| | | %%process({}) -> |
| | | %% ok; |
| | | %% |
| | | %%process(Cursor) -> |
| | | %% io:format("----Cursor:~p~n", [Cursor]), |
| | | %% Record = mc_worker_api:(Cursor), |
| | | %% io:format("Record:~p~n", [Record]), |
| | | %% case Record of |
| | | %% {} -> |
| | | %% no_more; |
| | | %% _ -> |
| | | %% process(Cursor) |
| | | %% end, |
| | | |
| | | %% {ok, Connection} = amqp_connection:start(#amqp_params_network{}), |
| | | %% %% Open a channel on the connection |
| | | %% {ok, Channel} = amqp_connection:open_channel(Connection), |
| | | |
| | | %% %% Declare a queue |
| | | %% #'queue.declare_ok'{queue = Q} = amqp_channel:call(Channel, #'queue.declare'{}), |
| | | %% |
| | | %% %% Publish a message |
| | | %% Payload = <<"foobar">>, |
| | | %% Publish = #'basic.publish'{exchange = <<>>, routing_key = Q}, |
| | | %% amqp_channel:cast(Channel, Publish, #amqp_msg{payload = Payload}), |
| | | %% |
| | | %% %% Get the message back from the queue |
| | | %% Get = #'basic.get'{queue = Q}, |
| | | %% {#'basic.get_ok'{delivery_tag = Tag}, Content} |
| | | %% = amqp_channel:call(Channel, Get), |
| | | %% |
| | | %% %% Do something with the message payload |
| | | %% %% (some work here) |
| | | %% |
| | | %% %% Ack the message |
| | | %% amqp_channel:cast(Channel, #'basic.ack'{delivery_tag = Tag}), |
| | | %% |
| | | %% %% Close the channel |
| | | %% amqp_channel:close(Channel), |
| | | %% %% Close the connection |
| | | %% amqp_connection:close(Connection), |
| | | |
| | | %% application:start(emongo), |
| | | %% emongo:add_pool(pool1, "192.168.1.102", 27017, "test1", 1), |
| | | %% emongo:insert(pool1, "test2", {name:2334}), |
| | | |
| | | io:format("*****************###"), |
| | | |
| | | ok. |