Skip to content

Commit

Permalink
added source from local repo
Browse files Browse the repository at this point in the history
  • Loading branch information
Zsolt Keszthelyi committed Apr 19, 2013
1 parent c80060f commit 7916099
Show file tree
Hide file tree
Showing 1,004 changed files with 73,066 additions and 3 deletions.
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
.eunit
deps
*.o
*.so
*.beam
*.plt
*.plt
*~
*.swp
priv/logs/*
erl_crash.dump
7 changes: 7 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
compile:
./rebar compile

clean:
./rebar clean

.PHONY: compile clean
15 changes: 13 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@
ansible_rpc_server
Ansible RPC Server
==================

JSON-RPC server with an Ansible Runner service
JSON-RPC server with an Ansible Runner service. Accepts JSON-RPC 1.1 requests over RabbitMq .
( not production ready )


Needs a 'test' exchange declared.
Requests need to be published to 'rpc\_queue/service\_name' queue.

Based on: https://github.com/tonyg/erlang-rfc4627

For request format see: rrpc\_test\_publisher:sample\_\request/0

Playbooks can register a playbook\_out variable that will be returned as a response to the RPC request.
7 changes: 7 additions & 0 deletions client
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

export ERL_LIBS=libs

erl -pa ebin lib/*/ebin lib/*/priv -sname rrpc_client -setcookie aaa -boot start_sasl -config priv/rrpc -s reloader


11 changes: 11 additions & 0 deletions ebin/rrpc.app
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{application,rrpc,
[{description,[]},
{vsn,"1"},
{registered,[]},
{applications,[kernel,stdlib]},
{mod,{rrpc_app,[]}},
{env,[]},
{modules,[reloader,rrpc,rrpc_amr,rrpc_app,rrpc_apr,
rrpc_consumer,rrpc_consumer_sup,rrpc_services_sup,
rrpc_sup,rrpc_test_publisher,rrpc_test_service,
rrpc_util,service_ansible,start]}]}.
56 changes: 56 additions & 0 deletions include/amqp_client.hrl
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
%% The contents of this file are subject to the Mozilla Public License
%% Version 1.1 (the "License"); you may not use this file except in
%% compliance with the License. You may obtain a copy of the License at
%% http://www.mozilla.org/MPL/
%%
%% Software distributed under the License is distributed on an "AS IS"
%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
%% License for the specific language governing rights and limitations
%% under the License.
%%
%% The Original Code is RabbitMQ.
%%
%% The Initial Developer of the Original Code is VMware, Inc.
%% Copyright (c) 2007-2013 VMware, Inc. All rights reserved.
%%

-ifndef(AMQP_CLIENT_HRL).
-define(AMQP_CLIENT_HRL, true).

-include_lib("rabbit.hrl").
-include_lib("rabbit_framing.hrl").

-record(amqp_msg, {props = #'P_basic'{}, payload = <<>>}).

-record(amqp_params_network, {username = <<"guest">>,
password = <<"guest">>,
virtual_host = <<"/">>,
host = "localhost",
port = undefined,
channel_max = 0,
frame_max = 0,
heartbeat = 0,
connection_timeout = infinity,
ssl_options = none,
auth_mechanisms =
[fun amqp_auth_mechanisms:plain/3,
fun amqp_auth_mechanisms:amqplain/3],
client_properties = [],
socket_options = []}).

-record(amqp_params_direct, {username = <<"guest">>,
password = none,
virtual_host = <<"/">>,
node = node(),
adapter_info = none,
client_properties = []}).

-record(amqp_adapter_info, {host = unknown,
port = unknown,
peer_host = unknown,
peer_port = unknown,
name = unknown,
protocol = unknown,
additional_info = []}).

-endif.
34 changes: 34 additions & 0 deletions include/amqp_client_internal.hrl
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
%% The contents of this file are subject to the Mozilla Public License
%% Version 1.1 (the "License"); you may not use this file except in
%% compliance with the License. You may obtain a copy of the License at
%% http://www.mozilla.org/MPL/
%%
%% Software distributed under the License is distributed on an "AS IS"
%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
%% License for the specific language governing rights and limitations
%% under the License.
%%
%% The Original Code is RabbitMQ.
%%
%% The Initial Developer of the Original Code is VMware, Inc.
%% Copyright (c) 2007-2013 VMware, Inc. All rights reserved.
%%

-include("amqp_client.hrl").

-define(PROTOCOL_VERSION_MAJOR, 0).
-define(PROTOCOL_VERSION_MINOR, 9).
-define(PROTOCOL_HEADER, <<"AMQP", 0, 0, 9, 1>>).
-define(PROTOCOL, rabbit_framing_amqp_0_9_1).

-define(MAX_CHANNEL_NUMBER, 65535).

-define(LOG_DEBUG(Format), error_logger:info_msg(Format)).
-define(LOG_INFO(Format, Args), error_logger:info_msg(Format, Args)).
-define(LOG_WARN(Format, Args), error_logger:warning_msg(Format, Args)).
-define(LOG_ERR(Format, Args), error_logger:error_msg(Format, Args)).

-define(CLIENT_CAPABILITIES, [{<<"publisher_confirms">>, bool, true},
{<<"exchange_exchange_bindings">>, bool, true},
{<<"basic.nack">>, bool, true},
{<<"consumer_cancel_notify">>, bool, true}]).
42 changes: 42 additions & 0 deletions include/amqp_gen_consumer_spec.hrl
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
%% The contents of this file are subject to the Mozilla Public License
%% Version 1.1 (the "License"); you may not use this file except in
%% compliance with the License. You may obtain a copy of the License at
%% http://www.mozilla.org/MPL/
%%
%% Software distributed under the License is distributed on an "AS IS"
%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
%% License for the specific language governing rights and limitations
%% under the License.
%%
%% The Original Code is RabbitMQ.
%%
%% The Initial Developer of the Original Code is VMware, Inc.
%% Copyright (c) 2011-2013 VMware, Inc. All rights reserved.
%%

-include("amqp_client.hrl").

-ifndef(edoc).
-type(state() :: any()).
-type(consume() :: #'basic.consume'{}).
-type(consume_ok() :: #'basic.consume_ok'{}).
-type(cancel() :: #'basic.cancel'{}).
-type(cancel_ok() :: #'basic.cancel_ok'{}).
-type(deliver() :: #'basic.deliver'{}).
-type(from() :: any()).
-type(reason() :: any()).
-type(ok_error() :: {ok, state()} | {error, reason(), state()}).

-spec(init/1 :: ([any()]) -> {ok, state()}).
-spec(handle_consume/3 :: (consume(), pid(), state()) -> ok_error()).
-spec(handle_consume_ok/3 :: (consume_ok(), consume(), state()) ->
ok_error()).
-spec(handle_cancel/2 :: (cancel(), state()) -> ok_error()).
-spec(handle_cancel_ok/3 :: (cancel_ok(), cancel(), state()) -> ok_error()).
-spec(handle_deliver/3 :: (deliver(), #amqp_msg{}, state()) -> ok_error()).
-spec(handle_info/2 :: (any(), state()) -> ok_error()).
-spec(handle_call/3 :: (any(), from(), state()) ->
{reply, any(), state()} | {noreply, state()} |
{error, reason(), state()}).
-spec(terminate/2 :: (any(), state()) -> state()).
-endif.
28 changes: 28 additions & 0 deletions include/gm_specs.hrl
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
%% The contents of this file are subject to the Mozilla Public License
%% Version 1.1 (the "License"); you may not use this file except in
%% compliance with the License. You may obtain a copy of the License at
%% http://www.mozilla.org/MPL/
%%
%% Software distributed under the License is distributed on an "AS IS"
%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
%% License for the specific language governing rights and limitations
%% under the License.
%%
%% The Original Code is RabbitMQ.
%%
%% The Initial Developer of the Original Code is VMware, Inc.
%% Copyright (c) 2007-2013 VMware, Inc. All rights reserved.
%%

-ifdef(use_specs).

-type(callback_result() :: 'ok' | {'stop', any()} | {'become', atom(), args()}).
-type(args() :: any()).
-type(members() :: [pid()]).

-spec(joined/2 :: (args(), members()) -> callback_result()).
-spec(members_changed/3 :: (args(), members(), members()) -> callback_result()).
-spec(handle_msg/3 :: (args(), pid(), any()) -> callback_result()).
-spec(terminate/2 :: (args(), term()) -> any()).

-endif.
110 changes: 110 additions & 0 deletions include/rabbit.hrl
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
%% The contents of this file are subject to the Mozilla Public License
%% Version 1.1 (the "License"); you may not use this file except in
%% compliance with the License. You may obtain a copy of the License
%% at http://www.mozilla.org/MPL/
%%
%% Software distributed under the License is distributed on an "AS IS"
%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
%% the License for the specific language governing rights and
%% limitations under the License.
%%
%% The Original Code is RabbitMQ.
%%
%% The Initial Developer of the Original Code is VMware, Inc.
%% Copyright (c) 2007-2013 VMware, Inc. All rights reserved.
%%

-record(user, {username,
tags,
auth_backend, %% Module this user came from
impl %% Scratch space for that module
}).

-record(internal_user, {username, password_hash, tags}).
-record(permission, {configure, write, read}).
-record(user_vhost, {username, virtual_host}).
-record(user_permission, {user_vhost, permission}).

-record(vhost, {virtual_host, dummy}).

-record(content,
{class_id,
properties, %% either 'none', or a decoded record/tuple
properties_bin, %% either 'none', or an encoded properties binary
%% Note: at most one of properties and properties_bin can be
%% 'none' at once.
protocol, %% The protocol under which properties_bin was encoded
payload_fragments_rev %% list of binaries, in reverse order (!)
}).

-record(resource, {virtual_host, kind, name}).

-record(exchange, {name, type, durable, auto_delete, internal, arguments,
scratches, policy}).
-record(exchange_serial, {name, next}).

-record(amqqueue, {name, durable, auto_delete, exclusive_owner = none,
arguments, pid, slave_pids, sync_slave_pids, policy,
gm_pids}).

%% mnesia doesn't like unary records, so we add a dummy 'value' field
-record(route, {binding, value = const}).
-record(reverse_route, {reverse_binding, value = const}).

-record(binding, {source, key, destination, args = []}).
-record(reverse_binding, {destination, key, source, args = []}).

-record(topic_trie_node, {trie_node, edge_count, binding_count}).
-record(topic_trie_edge, {trie_edge, node_id}).
-record(topic_trie_binding, {trie_binding, value = const}).

-record(trie_node, {exchange_name, node_id}).
-record(trie_edge, {exchange_name, node_id, word}).
-record(trie_binding, {exchange_name, node_id, destination}).

-record(listener, {node, protocol, host, ip_address, port}).

-record(runtime_parameters, {key, value}).

-record(basic_message, {exchange_name, routing_keys = [], content, id,
is_persistent}).

-record(ssl_socket, {tcp, ssl}).
-record(delivery, {mandatory, sender, message, msg_seq_no}).
-record(amqp_error, {name, explanation = "", method = none}).

-record(event, {type, props, timestamp}).

-record(message_properties, {expiry, needs_confirming = false}).

-record(plugin, {name, %% atom()
version, %% string()
description, %% string()
type, %% 'ez' or 'dir'
dependencies, %% [{atom(), string()}]
location}). %% string()

%%----------------------------------------------------------------------------

-define(COPYRIGHT_MESSAGE, "Copyright (C) 2007-2013 VMware, Inc.").
-define(INFORMATION_MESSAGE, "Licensed under the MPL. See http://www.rabbitmq.com/").
-define(ERTS_MINIMUM, "5.6.3").

%% EMPTY_FRAME_SIZE, 8 = 1 + 2 + 4 + 1
%% - 1 byte of frame type
%% - 2 bytes of channel number
%% - 4 bytes of frame payload length
%% - 1 byte of payload trailer FRAME_END byte
%% See rabbit_binary_generator:check_empty_frame_size/0, an assertion
%% called at startup.
-define(EMPTY_FRAME_SIZE, 8).

-define(MAX_WAIT, 16#ffffffff).

-define(HIBERNATE_AFTER_MIN, 1000).
-define(DESIRED_HIBERNATE, 10000).
-define(CREDIT_DISC_BOUND, {2000, 500}).

-define(INVALID_HEADERS_KEY, <<"x-invalid-headers">>).
-define(ROUTING_HEADERS, [<<"CC">>, <<"BCC">>]).
-define(DELETED_HEADER, <<"BCC">>).
Loading

0 comments on commit 7916099

Please sign in to comment.