Coverage Report

Created: 2026-11-11 06:15

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/trafficserver/include/mgmt/rpc/jsonrpc/JsonRPC.h
Line
Count
Source
1
/**
2
  @par License
3
4
  Licensed to the Apache Software Foundation (ASF) under one
5
  or more contributor license agreements.  See the NOTICE file
6
  distributed with this work for additional information
7
  regarding copyright ownership.  The ASF licenses this file
8
  to you under the Apache License, Version 2.0 (the
9
  "License"); you may not use this file except in compliance
10
  with the License.  You may obtain a copy of the License at
11
12
  http://www.apache.org/licenses/LICENSE-2.0
13
14
  Unless required by applicable law or agreed to in writing, software
15
  distributed under the License is distributed on an "AS IS" BASIS,
16
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
  See the License for the specific language governing permissions and
18
  limitations under the License.
19
*/
20
#pragma once
21
22
#include "mgmt/rpc/jsonrpc/JsonRPCManager.h"
23
#include "mgmt/rpc/handlers/common/ErrorUtils.h"
24
25
namespace rpc
26
{
27
/// Generic and global JSONRPC service provider info object. It's recommended to use this object when registering your new handler
28
/// into the rpc system IF the implementor wants the handler to be listed as ATS's handler.
29
extern RPCRegistryInfo core_ats_rpc_service_provider_handle;
30
// -----------------------------------------------------------------------------
31
/// Set of convenience API function. Users can avoid having to name the whole rps::JsonRPCManager::instance() to use the object.
32
33
/// @see JsonRPCManager::add_method_handler for details
34
template <typename Func>
35
inline bool
36
add_method_handler(std::string_view name, Func &&call, const RPCRegistryInfo *info, TSRPCHandlerOptions const &opt)
37
0
{
38
0
  return JsonRPCManager::instance().add_method_handler(name, std::forward<Func>(call), info, opt);
39
0
}
Unexecuted instantiation: bool rpc::add_method_handler<swoc::_1_5_15::Rv<YAML::Node> (*)(std::__1::basic_string_view<char, std::__1::char_traits<char> >, YAML::Node const&)>(std::__1::basic_string_view<char, std::__1::char_traits<char> >, swoc::_1_5_15::Rv<YAML::Node> (*&&)(std::__1::basic_string_view<char, std::__1::char_traits<char> >, YAML::Node const&), rpc::RPCRegistryInfo const*, TSRPCHandlerOptions const&)
Unexecuted instantiation: FileManager.cc:bool rpc::add_method_handler<FileManager::FileManager()::$_0>(std::__1::basic_string_view<char, std::__1::char_traits<char> >, FileManager::FileManager()::$_0&&, rpc::RPCRegistryInfo const*, TSRPCHandlerOptions const&)
40
41
/// As a plugin you should use  @c TSRPCRegisterMethodHandlerfor to register your function to handle RPC messages.
42
template <typename Func>
43
inline bool
44
add_method_handler_from_plugin(const std::string &name, Func &&call, const RPCRegistryInfo *info, TSRPCHandlerOptions const &opt)
45
{
46
  return JsonRPCManager::instance().add_method_handler_from_plugin(name, std::forward<Func>(call), info, opt);
47
}
48
49
/// @see JsonRPCManager::add_notification_handler for details
50
/// @note Plugins must use @c TSRPCRegisterNotificationHandler to register.
51
template <typename Func>
52
inline bool
53
add_notification_handler(std::string_view name, Func &&call, const RPCRegistryInfo *info, TSRPCHandlerOptions const &opt)
54
{
55
  return JsonRPCManager::instance().add_notification_handler(name, std::forward<Func>(call), info, opt);
56
}
57
58
} // namespace rpc