diff --git a/idl-compiler.py b/idl-compiler.py index 9c70b39631..e5b9f43bb2 100755 --- a/idl-compiler.py +++ b/idl-compiler.py @@ -487,12 +487,14 @@ class RpcVerb(ASTBase): - [[one_way]] - the handler function is annotated by future return type to designate that a client doesn't need to wait for an answer. + - [[ip]] - ip addressable send function will be generated instead of + host id addressable The `-> return_values` clause is optional for two-way messages. If omitted, the return type is set to be `future<>`. For one-way verbs, the use of return clause is prohibited and the signature of `send*` function always returns `future<>`.""" - def __init__(self, name, parameters, return_values, with_client_info, with_timeout, cancellable, one_way): + def __init__(self, name, parameters, return_values, with_client_info, with_timeout, cancellable, one_way, ip): super().__init__(name) self.params = parameters self.return_values = return_values @@ -500,9 +502,10 @@ class RpcVerb(ASTBase): self.with_timeout = with_timeout self.cancellable = cancellable self.one_way = one_way + self.ip = ip def __str__(self): - return f"" + return f"" def __repr__(self): return self.__str__() @@ -690,12 +693,13 @@ def rpc_verb_parse_action(tokens): with_timeout = not raw_attrs.empty() and 'with_timeout' in raw_attrs.attr_items cancellable = not raw_attrs.empty() and 'cancellable' in raw_attrs.attr_items with_client_info = not raw_attrs.empty() and 'with_client_info' in raw_attrs.attr_items + ip = not raw_attrs.empty() and 'ip' in raw_attrs.attr_items one_way = not raw_attrs.empty() and 'one_way' in raw_attrs.attr_items if one_way and 'return_values' in tokens: raise Exception(f"Invalid return type specification for one-way RPC verb '{name}'") if with_timeout and cancellable: raise Exception(f"Error in verb {name}: [[with_timeout]] cannot be used together with [[cancellable]] in the same verb") - return RpcVerb(name=name, parameters=params, return_values=tokens.get('return_values'), with_client_info=with_client_info, with_timeout=with_timeout, cancellable=cancellable, one_way=one_way) + return RpcVerb(name=name, parameters=params, return_values=tokens.get('return_values'), with_client_info=with_client_info, with_timeout=with_timeout, cancellable=cancellable, one_way=one_way, ip=ip) def namespace_parse_action(tokens): @@ -1614,9 +1618,10 @@ def generate_rpc_verbs_declarations(hout, module_name): fprintln(hout, reindent(4, f'''static void register_{name}(netw::messaging_service* ms, std::function<{verb.handler_function_return_values()} ({verb.handler_function_parameters_str()})>&&); static future<> unregister_{name}(netw::messaging_service* ms); -static {verb.send_function_return_type()} send_{name}({verb.send_function_signature_params_list(include_placeholder_names=False, dst_type="netw::msg_addr")}); static {verb.send_function_return_type()} send_{name}({verb.send_function_signature_params_list(include_placeholder_names=False, dst_type="locator::host_id")}); ''')) + if verb.ip: + fprintln(hout, reindent(4, f'''static {verb.send_function_return_type()} send_{name}({verb.send_function_signature_params_list(include_placeholder_names=False, dst_type="netw::msg_addr")});''')) fprintln(hout, reindent(4, 'static future<> unregister(netw::messaging_service* ms);')) fprintln(hout, '};\n') @@ -1635,13 +1640,14 @@ future<> {module_name}_rpc_verbs::unregister_{name}(netw::messaging_service* ms) return ms->unregister_handler({verb.messaging_verb_enum_case()}); }} -{verb.send_function_return_type()} {module_name}_rpc_verbs::send_{name}({verb.send_function_signature_params_list(include_placeholder_names=True, dst_type="netw::msg_addr")}) {{ - {verb.send_function_invocation()} -}} - {verb.send_function_return_type()} {module_name}_rpc_verbs::send_{name}({verb.send_function_signature_params_list(include_placeholder_names=True, dst_type="locator::host_id")}) {{ {verb.send_function_invocation()} }}''') + if verb.ip: + fprintln(cout, f''' +{verb.send_function_return_type()} {module_name}_rpc_verbs::send_{name}({verb.send_function_signature_params_list(include_placeholder_names=True, dst_type="netw::msg_addr")}) {{ + {verb.send_function_invocation()} +}}''') fprintln(cout, f''' future<> {module_name}_rpc_verbs::unregister(netw::messaging_service* ms) {{ diff --git a/idl/gossip.idl.hh b/idl/gossip.idl.hh index 89691f998b..f1d9a402a0 100644 --- a/idl/gossip.idl.hh +++ b/idl/gossip.idl.hh @@ -11,8 +11,8 @@ namespace gms { verb [[with_client_info, with_timeout]] gossip_echo (int64_t generation_number [[version 4.6.0]], bool notify_up [[version 6.1.0]]) verb [[one_way]] gossip_shutdown (gms::inet_address from, int64_t generation_number [[version 4.6.0]]) -verb [[with_client_info, one_way]] gossip_digest_syn (gms::gossip_digest_syn syn) -verb [[with_client_info, one_way]] gossip_digest_ack (gms::gossip_digest_ack ask) -verb [[with_client_info, one_way]] gossip_digest_ack2 (gms::gossip_digest_ack2 ask) -verb [[with_client_info, with_timeout]] gossip_get_endpoint_states (gms::gossip_get_endpoint_states_request req) -> gms::gossip_get_endpoint_states_response +verb [[with_client_info, one_way, ip]] gossip_digest_syn (gms::gossip_digest_syn syn) +verb [[with_client_info, one_way, ip]] gossip_digest_ack (gms::gossip_digest_ack ask) +verb [[with_client_info, one_way, ip]] gossip_digest_ack2 (gms::gossip_digest_ack2 ask) +verb [[with_client_info, with_timeout, ip]] gossip_get_endpoint_states (gms::gossip_get_endpoint_states_request req) -> gms::gossip_get_endpoint_states_response } diff --git a/idl/group0.idl.hh b/idl/group0.idl.hh index 97cacada52..0f750adff0 100644 --- a/idl/group0.idl.hh +++ b/idl/group0.idl.hh @@ -34,7 +34,7 @@ enum class group0_upgrade_state : uint8_t { }; verb [[with_client_info, cancellable]] get_group0_upgrade_state () -> service::group0_upgrade_state; -verb [[with_client_info, with_timeout]] group0_peer_exchange (std::vector peers) -> service::group0_peer_exchange; +verb [[with_client_info, with_timeout, ip]] group0_peer_exchange (std::vector peers) -> service::group0_peer_exchange; verb [[with_client_info, with_timeout]] group0_modify_config (raft::group_id gid, std::vector add, std::vector del); } // namespace raft diff --git a/idl/join_node.idl.hh b/idl/join_node.idl.hh index 839c8f767b..c1a9672bcc 100644 --- a/idl/join_node.idl.hh +++ b/idl/join_node.idl.hh @@ -63,8 +63,8 @@ struct join_node_response_params { struct join_node_response_result {}; -verb join_node_query (raft::server_id dst_id, service::join_node_query_params) -> service::join_node_query_result; -verb join_node_request (raft::server_id dst_id, service::join_node_request_params) -> service::join_node_request_result; +verb [[ip]] join_node_query (raft::server_id dst_id, service::join_node_query_params) -> service::join_node_query_result; +verb [[ip]] join_node_request (raft::server_id dst_id, service::join_node_request_params) -> service::join_node_request_result; verb join_node_response (raft::server_id dst_id, service::join_node_response_params) -> service::join_node_response_result; } diff --git a/service/raft/raft_rpc.cc b/service/raft/raft_rpc.cc index 4c4ccd16c5..2decb9ff76 100644 --- a/service/raft/raft_rpc.cc +++ b/service/raft/raft_rpc.cc @@ -62,7 +62,7 @@ template auto raft_rpc::two_way_rpc(sloc loc, raft::server_id id, Verb&& verb, Args&&... args) { - using Fut = decltype(verb(&_messaging, netw::msg_addr(gms::inet_address()), db::no_timeout, _group_id, _my_id, id, std::forward(args)...)); + using Fut = decltype(verb(&_messaging, locator::host_id{}, db::no_timeout, _group_id, _my_id, id, std::forward(args)...)); using Ret = typename Fut::value_type; if (!_failure_detector->is_alive(id)) { return make_exception_future(raft::destination_not_alive_error(id, loc));