commit
dedbcf453b
156 changed files with 6032 additions and 1213 deletions
@ -0,0 +1,138 @@ |
|||||||
|
/*
|
||||||
|
* |
||||||
|
* Copyright 2019 gRPC authors. |
||||||
|
* |
||||||
|
* Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
|
||||||
|
* |
||||||
|
* Unless required by applicable law or agreed to in writing, software |
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, |
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||||
|
* See the License for the specific language governing permissions and |
||||||
|
* limitations under the License. |
||||||
|
* |
||||||
|
*/ |
||||||
|
|
||||||
|
#ifndef GRPCPP_IMPL_CODEGEN_SYNC_H |
||||||
|
#define GRPCPP_IMPL_CODEGEN_SYNC_H |
||||||
|
|
||||||
|
#include <grpc/impl/codegen/log.h> |
||||||
|
#include <grpc/impl/codegen/port_platform.h> |
||||||
|
#include <grpc/impl/codegen/sync.h> |
||||||
|
|
||||||
|
#include <grpcpp/impl/codegen/core_codegen_interface.h> |
||||||
|
|
||||||
|
// The core library is not accessible in C++ codegen headers, and vice versa.
|
||||||
|
// Thus, we need to have duplicate headers with similar functionality.
|
||||||
|
// Make sure any change to this file is also reflected in
|
||||||
|
// src/core/lib/gprpp/sync.h too.
|
||||||
|
//
|
||||||
|
// Whenever possible, prefer "src/core/lib/gprpp/sync.h" over this file,
|
||||||
|
// since in core we do not rely on g_core_codegen_interface and hence do not
|
||||||
|
// pay the costs of virtual function calls.
|
||||||
|
|
||||||
|
namespace grpc { |
||||||
|
namespace internal { |
||||||
|
|
||||||
|
class Mutex { |
||||||
|
public: |
||||||
|
Mutex() { g_core_codegen_interface->gpr_mu_init(&mu_); } |
||||||
|
~Mutex() { g_core_codegen_interface->gpr_mu_destroy(&mu_); } |
||||||
|
|
||||||
|
Mutex(const Mutex&) = delete; |
||||||
|
Mutex& operator=(const Mutex&) = delete; |
||||||
|
|
||||||
|
gpr_mu* get() { return &mu_; } |
||||||
|
const gpr_mu* get() const { return &mu_; } |
||||||
|
|
||||||
|
private: |
||||||
|
gpr_mu mu_; |
||||||
|
}; |
||||||
|
|
||||||
|
// MutexLock is a std::
|
||||||
|
class MutexLock { |
||||||
|
public: |
||||||
|
explicit MutexLock(Mutex* mu) : mu_(mu->get()) { |
||||||
|
g_core_codegen_interface->gpr_mu_lock(mu_); |
||||||
|
} |
||||||
|
explicit MutexLock(gpr_mu* mu) : mu_(mu) { |
||||||
|
g_core_codegen_interface->gpr_mu_lock(mu_); |
||||||
|
} |
||||||
|
~MutexLock() { g_core_codegen_interface->gpr_mu_unlock(mu_); } |
||||||
|
|
||||||
|
MutexLock(const MutexLock&) = delete; |
||||||
|
MutexLock& operator=(const MutexLock&) = delete; |
||||||
|
|
||||||
|
private: |
||||||
|
gpr_mu* const mu_; |
||||||
|
}; |
||||||
|
|
||||||
|
class ReleasableMutexLock { |
||||||
|
public: |
||||||
|
explicit ReleasableMutexLock(Mutex* mu) : mu_(mu->get()) { |
||||||
|
g_core_codegen_interface->gpr_mu_lock(mu_); |
||||||
|
} |
||||||
|
explicit ReleasableMutexLock(gpr_mu* mu) : mu_(mu) { |
||||||
|
g_core_codegen_interface->gpr_mu_lock(mu_); |
||||||
|
} |
||||||
|
~ReleasableMutexLock() { |
||||||
|
if (!released_) g_core_codegen_interface->gpr_mu_unlock(mu_); |
||||||
|
} |
||||||
|
|
||||||
|
ReleasableMutexLock(const ReleasableMutexLock&) = delete; |
||||||
|
ReleasableMutexLock& operator=(const ReleasableMutexLock&) = delete; |
||||||
|
|
||||||
|
void Lock() { |
||||||
|
GPR_DEBUG_ASSERT(released_); |
||||||
|
g_core_codegen_interface->gpr_mu_lock(mu_); |
||||||
|
released_ = false; |
||||||
|
} |
||||||
|
|
||||||
|
void Unlock() { |
||||||
|
GPR_DEBUG_ASSERT(!released_); |
||||||
|
released_ = true; |
||||||
|
g_core_codegen_interface->gpr_mu_unlock(mu_); |
||||||
|
} |
||||||
|
|
||||||
|
private: |
||||||
|
gpr_mu* const mu_; |
||||||
|
bool released_ = false; |
||||||
|
}; |
||||||
|
|
||||||
|
class CondVar { |
||||||
|
public: |
||||||
|
CondVar() { g_core_codegen_interface->gpr_cv_init(&cv_); } |
||||||
|
~CondVar() { g_core_codegen_interface->gpr_cv_destroy(&cv_); } |
||||||
|
|
||||||
|
CondVar(const CondVar&) = delete; |
||||||
|
CondVar& operator=(const CondVar&) = delete; |
||||||
|
|
||||||
|
void Signal() { g_core_codegen_interface->gpr_cv_signal(&cv_); } |
||||||
|
void Broadcast() { g_core_codegen_interface->gpr_cv_broadcast(&cv_); } |
||||||
|
|
||||||
|
int Wait(Mutex* mu) { |
||||||
|
return Wait(mu, |
||||||
|
g_core_codegen_interface->gpr_inf_future(GPR_CLOCK_REALTIME)); |
||||||
|
} |
||||||
|
int Wait(Mutex* mu, const gpr_timespec& deadline) { |
||||||
|
return g_core_codegen_interface->gpr_cv_wait(&cv_, mu->get(), deadline); |
||||||
|
} |
||||||
|
|
||||||
|
template <typename Predicate> |
||||||
|
void WaitUntil(Mutex* mu, Predicate pred) { |
||||||
|
while (!pred()) { |
||||||
|
Wait(mu, g_core_codegen_interface->gpr_inf_future(GPR_CLOCK_REALTIME)); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
private: |
||||||
|
gpr_cv cv_; |
||||||
|
}; |
||||||
|
|
||||||
|
} // namespace internal
|
||||||
|
} // namespace grpc
|
||||||
|
|
||||||
|
#endif // GRPCPP_IMPL_CODEGEN_SYNC_H
|
@ -0,0 +1,354 @@ |
|||||||
|
/*
|
||||||
|
* |
||||||
|
* Copyright 2015-2016 gRPC authors. |
||||||
|
* |
||||||
|
* Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
|
||||||
|
* |
||||||
|
* Unless required by applicable law or agreed to in writing, software |
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, |
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||||
|
* See the License for the specific language governing permissions and |
||||||
|
* limitations under the License. |
||||||
|
* |
||||||
|
*/ |
||||||
|
|
||||||
|
#ifndef GRPCPP_SERVER_BUILDER_IMPL_H |
||||||
|
#define GRPCPP_SERVER_BUILDER_IMPL_H |
||||||
|
|
||||||
|
#include <climits> |
||||||
|
#include <map> |
||||||
|
#include <memory> |
||||||
|
#include <vector> |
||||||
|
|
||||||
|
#include <grpc/compression.h> |
||||||
|
#include <grpc/support/cpu.h> |
||||||
|
#include <grpc/support/workaround_list.h> |
||||||
|
#include <grpcpp/impl/channel_argument_option.h> |
||||||
|
#include <grpcpp/impl/codegen/server_interceptor.h> |
||||||
|
#include <grpcpp/impl/server_builder_option.h> |
||||||
|
#include <grpcpp/impl/server_builder_plugin.h> |
||||||
|
#include <grpcpp/support/config.h> |
||||||
|
|
||||||
|
struct grpc_resource_quota; |
||||||
|
|
||||||
|
namespace grpc_impl { |
||||||
|
|
||||||
|
class ResourceQuota; |
||||||
|
class ServerCredentials; |
||||||
|
} // namespace grpc_impl
|
||||||
|
namespace grpc { |
||||||
|
|
||||||
|
class AsyncGenericService; |
||||||
|
class CompletionQueue; |
||||||
|
class Server; |
||||||
|
class ServerCompletionQueue; |
||||||
|
class Service; |
||||||
|
|
||||||
|
namespace testing { |
||||||
|
class ServerBuilderPluginTest; |
||||||
|
} // namespace testing
|
||||||
|
|
||||||
|
namespace experimental { |
||||||
|
class CallbackGenericService; |
||||||
|
} |
||||||
|
} // namespace grpc
|
||||||
|
namespace grpc_impl { |
||||||
|
|
||||||
|
/// A builder class for the creation and startup of \a grpc::Server instances.
|
||||||
|
class ServerBuilder { |
||||||
|
public: |
||||||
|
ServerBuilder(); |
||||||
|
virtual ~ServerBuilder(); |
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Primary API's
|
||||||
|
|
||||||
|
/// Return a running server which is ready for processing calls.
|
||||||
|
/// Before calling, one typically needs to ensure that:
|
||||||
|
/// 1. a service is registered - so that the server knows what to serve
|
||||||
|
/// (via RegisterService, or RegisterAsyncGenericService)
|
||||||
|
/// 2. a listening port has been added - so the server knows where to receive
|
||||||
|
/// traffic (via AddListeningPort)
|
||||||
|
/// 3. [for async api only] completion queues have been added via
|
||||||
|
/// AddCompletionQueue
|
||||||
|
virtual std::unique_ptr<grpc::Server> BuildAndStart(); |
||||||
|
|
||||||
|
/// Register a service. This call does not take ownership of the service.
|
||||||
|
/// The service must exist for the lifetime of the \a Server instance returned
|
||||||
|
/// by \a BuildAndStart().
|
||||||
|
/// Matches requests with any :authority
|
||||||
|
ServerBuilder& RegisterService(grpc::Service* service); |
||||||
|
|
||||||
|
/// Enlists an endpoint \a addr (port with an optional IP address) to
|
||||||
|
/// bind the \a grpc::Server object to be created to.
|
||||||
|
///
|
||||||
|
/// It can be invoked multiple times.
|
||||||
|
///
|
||||||
|
/// \param addr_uri The address to try to bind to the server in URI form. If
|
||||||
|
/// the scheme name is omitted, "dns:///" is assumed. To bind to any address,
|
||||||
|
/// please use IPv6 any, i.e., [::]:<port>, which also accepts IPv4
|
||||||
|
/// connections. Valid values include dns:///localhost:1234, /
|
||||||
|
/// 192.168.1.1:31416, dns:///[::1]:27182, etc.).
|
||||||
|
/// \param creds The credentials associated with the server.
|
||||||
|
/// \param selected_port[out] If not `nullptr`, gets populated with the port
|
||||||
|
/// number bound to the \a grpc::Server for the corresponding endpoint after
|
||||||
|
/// it is successfully bound by BuildAndStart(), 0 otherwise. AddListeningPort
|
||||||
|
/// does not modify this pointer.
|
||||||
|
ServerBuilder& AddListeningPort( |
||||||
|
const grpc::string& addr_uri, |
||||||
|
std::shared_ptr<grpc_impl::ServerCredentials> creds, |
||||||
|
int* selected_port = nullptr); |
||||||
|
|
||||||
|
/// Add a completion queue for handling asynchronous services.
|
||||||
|
///
|
||||||
|
/// Best performance is typically obtained by using one thread per polling
|
||||||
|
/// completion queue.
|
||||||
|
///
|
||||||
|
/// Caller is required to shutdown the server prior to shutting down the
|
||||||
|
/// returned completion queue. Caller is also required to drain the
|
||||||
|
/// completion queue after shutting it down. A typical usage scenario:
|
||||||
|
///
|
||||||
|
/// // While building the server:
|
||||||
|
/// ServerBuilder builder;
|
||||||
|
/// ...
|
||||||
|
/// cq_ = builder.AddCompletionQueue();
|
||||||
|
/// server_ = builder.BuildAndStart();
|
||||||
|
///
|
||||||
|
/// // While shutting down the server;
|
||||||
|
/// server_->Shutdown();
|
||||||
|
/// cq_->Shutdown(); // Always *after* the associated server's Shutdown()!
|
||||||
|
/// // Drain the cq_ that was created
|
||||||
|
/// void* ignored_tag;
|
||||||
|
/// bool ignored_ok;
|
||||||
|
/// while (cq_->Next(&ignored_tag, &ignored_ok)) { }
|
||||||
|
///
|
||||||
|
/// \param is_frequently_polled This is an optional parameter to inform gRPC
|
||||||
|
/// library about whether this completion queue would be frequently polled
|
||||||
|
/// (i.e. by calling \a Next() or \a AsyncNext()). The default value is
|
||||||
|
/// 'true' and is the recommended setting. Setting this to 'false' (i.e.
|
||||||
|
/// not polling the completion queue frequently) will have a significantly
|
||||||
|
/// negative performance impact and hence should not be used in production
|
||||||
|
/// use cases.
|
||||||
|
std::unique_ptr<grpc::ServerCompletionQueue> AddCompletionQueue( |
||||||
|
bool is_frequently_polled = true); |
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Less commonly used RegisterService variants
|
||||||
|
|
||||||
|
/// Register a service. This call does not take ownership of the service.
|
||||||
|
/// The service must exist for the lifetime of the \a Server instance
|
||||||
|
/// returned by \a BuildAndStart(). Only matches requests with :authority \a
|
||||||
|
/// host
|
||||||
|
ServerBuilder& RegisterService(const grpc::string& host, |
||||||
|
grpc::Service* service); |
||||||
|
|
||||||
|
/// Register a generic service.
|
||||||
|
/// Matches requests with any :authority
|
||||||
|
/// This is mostly useful for writing generic gRPC Proxies where the exact
|
||||||
|
/// serialization format is unknown
|
||||||
|
ServerBuilder& RegisterAsyncGenericService( |
||||||
|
grpc::AsyncGenericService* service); |
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Fine control knobs
|
||||||
|
|
||||||
|
/// Set max receive message size in bytes.
|
||||||
|
/// The default is GRPC_DEFAULT_MAX_RECV_MESSAGE_LENGTH.
|
||||||
|
ServerBuilder& SetMaxReceiveMessageSize(int max_receive_message_size) { |
||||||
|
max_receive_message_size_ = max_receive_message_size; |
||||||
|
return *this; |
||||||
|
} |
||||||
|
|
||||||
|
/// Set max send message size in bytes.
|
||||||
|
/// The default is GRPC_DEFAULT_MAX_SEND_MESSAGE_LENGTH.
|
||||||
|
ServerBuilder& SetMaxSendMessageSize(int max_send_message_size) { |
||||||
|
max_send_message_size_ = max_send_message_size; |
||||||
|
return *this; |
||||||
|
} |
||||||
|
|
||||||
|
/// \deprecated For backward compatibility.
|
||||||
|
ServerBuilder& SetMaxMessageSize(int max_message_size) { |
||||||
|
return SetMaxReceiveMessageSize(max_message_size); |
||||||
|
} |
||||||
|
|
||||||
|
/// Set the support status for compression algorithms. All algorithms are
|
||||||
|
/// enabled by default.
|
||||||
|
///
|
||||||
|
/// Incoming calls compressed with an unsupported algorithm will fail with
|
||||||
|
/// \a GRPC_STATUS_UNIMPLEMENTED.
|
||||||
|
ServerBuilder& SetCompressionAlgorithmSupportStatus( |
||||||
|
grpc_compression_algorithm algorithm, bool enabled); |
||||||
|
|
||||||
|
/// The default compression level to use for all channel calls in the
|
||||||
|
/// absence of a call-specific level.
|
||||||
|
ServerBuilder& SetDefaultCompressionLevel(grpc_compression_level level); |
||||||
|
|
||||||
|
/// The default compression algorithm to use for all channel calls in the
|
||||||
|
/// absence of a call-specific level. Note that it overrides any compression
|
||||||
|
/// level set by \a SetDefaultCompressionLevel.
|
||||||
|
ServerBuilder& SetDefaultCompressionAlgorithm( |
||||||
|
grpc_compression_algorithm algorithm); |
||||||
|
|
||||||
|
/// Set the attached buffer pool for this server
|
||||||
|
ServerBuilder& SetResourceQuota( |
||||||
|
const grpc_impl::ResourceQuota& resource_quota); |
||||||
|
|
||||||
|
ServerBuilder& SetOption(std::unique_ptr<grpc::ServerBuilderOption> option); |
||||||
|
|
||||||
|
/// Options for synchronous servers.
|
||||||
|
enum SyncServerOption { |
||||||
|
NUM_CQS, ///< Number of completion queues.
|
||||||
|
MIN_POLLERS, ///< Minimum number of polling threads.
|
||||||
|
MAX_POLLERS, ///< Maximum number of polling threads.
|
||||||
|
CQ_TIMEOUT_MSEC ///< Completion queue timeout in milliseconds.
|
||||||
|
}; |
||||||
|
|
||||||
|
/// Only useful if this is a Synchronous server.
|
||||||
|
ServerBuilder& SetSyncServerOption(SyncServerOption option, int value); |
||||||
|
|
||||||
|
/// Add a channel argument (an escape hatch to tuning core library parameters
|
||||||
|
/// directly)
|
||||||
|
template <class T> |
||||||
|
ServerBuilder& AddChannelArgument(const grpc::string& arg, const T& value) { |
||||||
|
return SetOption(grpc::MakeChannelArgumentOption(arg, value)); |
||||||
|
} |
||||||
|
|
||||||
|
/// For internal use only: Register a ServerBuilderPlugin factory function.
|
||||||
|
static void InternalAddPluginFactory( |
||||||
|
std::unique_ptr<grpc::ServerBuilderPlugin> (*CreatePlugin)()); |
||||||
|
|
||||||
|
/// Enable a server workaround. Do not use unless you know what the workaround
|
||||||
|
/// does. For explanation and detailed descriptions of workarounds, see
|
||||||
|
/// doc/workarounds.md.
|
||||||
|
ServerBuilder& EnableWorkaround(grpc_workaround_list id); |
||||||
|
|
||||||
|
/// NOTE: class experimental_type is not part of the public API of this class.
|
||||||
|
/// TODO(yashykt): Integrate into public API when this is no longer
|
||||||
|
/// experimental.
|
||||||
|
class experimental_type { |
||||||
|
public: |
||||||
|
explicit experimental_type(grpc_impl::ServerBuilder* builder) |
||||||
|
: builder_(builder) {} |
||||||
|
|
||||||
|
void SetInterceptorCreators( |
||||||
|
std::vector<std::unique_ptr< |
||||||
|
grpc::experimental::ServerInterceptorFactoryInterface>> |
||||||
|
interceptor_creators) { |
||||||
|
builder_->interceptor_creators_ = std::move(interceptor_creators); |
||||||
|
} |
||||||
|
|
||||||
|
/// Register a generic service that uses the callback API.
|
||||||
|
/// Matches requests with any :authority
|
||||||
|
/// This is mostly useful for writing generic gRPC Proxies where the exact
|
||||||
|
/// serialization format is unknown
|
||||||
|
ServerBuilder& RegisterCallbackGenericService( |
||||||
|
grpc::experimental::CallbackGenericService* service); |
||||||
|
|
||||||
|
private: |
||||||
|
ServerBuilder* builder_; |
||||||
|
}; |
||||||
|
|
||||||
|
/// NOTE: The function experimental() is not stable public API. It is a view
|
||||||
|
/// to the experimental components of this class. It may be changed or removed
|
||||||
|
/// at any time.
|
||||||
|
experimental_type experimental() { return experimental_type(this); } |
||||||
|
|
||||||
|
protected: |
||||||
|
/// Experimental, to be deprecated
|
||||||
|
struct Port { |
||||||
|
grpc::string addr; |
||||||
|
std::shared_ptr<grpc_impl::ServerCredentials> creds; |
||||||
|
int* selected_port; |
||||||
|
}; |
||||||
|
|
||||||
|
/// Experimental, to be deprecated
|
||||||
|
typedef std::unique_ptr<grpc::string> HostString; |
||||||
|
struct NamedService { |
||||||
|
explicit NamedService(grpc::Service* s) : service(s) {} |
||||||
|
NamedService(const grpc::string& h, grpc::Service* s) |
||||||
|
: host(new grpc::string(h)), service(s) {} |
||||||
|
HostString host; |
||||||
|
grpc::Service* service; |
||||||
|
}; |
||||||
|
|
||||||
|
/// Experimental, to be deprecated
|
||||||
|
std::vector<Port> ports() { return ports_; } |
||||||
|
|
||||||
|
/// Experimental, to be deprecated
|
||||||
|
std::vector<NamedService*> services() { |
||||||
|
std::vector<NamedService*> service_refs; |
||||||
|
for (auto& ptr : services_) { |
||||||
|
service_refs.push_back(ptr.get()); |
||||||
|
} |
||||||
|
return service_refs; |
||||||
|
} |
||||||
|
|
||||||
|
/// Experimental, to be deprecated
|
||||||
|
std::vector<grpc::ServerBuilderOption*> options() { |
||||||
|
std::vector<grpc::ServerBuilderOption*> option_refs; |
||||||
|
for (auto& ptr : options_) { |
||||||
|
option_refs.push_back(ptr.get()); |
||||||
|
} |
||||||
|
return option_refs; |
||||||
|
} |
||||||
|
|
||||||
|
private: |
||||||
|
friend class ::grpc::testing::ServerBuilderPluginTest; |
||||||
|
|
||||||
|
struct SyncServerSettings { |
||||||
|
SyncServerSettings() |
||||||
|
: num_cqs(1), min_pollers(1), max_pollers(2), cq_timeout_msec(10000) {} |
||||||
|
|
||||||
|
/// Number of server completion queues to create to listen to incoming RPCs.
|
||||||
|
int num_cqs; |
||||||
|
|
||||||
|
/// Minimum number of threads per completion queue that should be listening
|
||||||
|
/// to incoming RPCs.
|
||||||
|
int min_pollers; |
||||||
|
|
||||||
|
/// Maximum number of threads per completion queue that can be listening to
|
||||||
|
/// incoming RPCs.
|
||||||
|
int max_pollers; |
||||||
|
|
||||||
|
/// The timeout for server completion queue's AsyncNext call.
|
||||||
|
int cq_timeout_msec; |
||||||
|
}; |
||||||
|
|
||||||
|
int max_receive_message_size_; |
||||||
|
int max_send_message_size_; |
||||||
|
std::vector<std::unique_ptr<grpc::ServerBuilderOption>> options_; |
||||||
|
std::vector<std::unique_ptr<NamedService>> services_; |
||||||
|
std::vector<Port> ports_; |
||||||
|
|
||||||
|
SyncServerSettings sync_server_settings_; |
||||||
|
|
||||||
|
/// List of completion queues added via \a AddCompletionQueue method.
|
||||||
|
std::vector<grpc::ServerCompletionQueue*> cqs_; |
||||||
|
|
||||||
|
std::shared_ptr<grpc_impl::ServerCredentials> creds_; |
||||||
|
std::vector<std::unique_ptr<grpc::ServerBuilderPlugin>> plugins_; |
||||||
|
grpc_resource_quota* resource_quota_; |
||||||
|
grpc::AsyncGenericService* generic_service_{nullptr}; |
||||||
|
grpc::experimental::CallbackGenericService* callback_generic_service_{ |
||||||
|
nullptr}; |
||||||
|
struct { |
||||||
|
bool is_set; |
||||||
|
grpc_compression_level level; |
||||||
|
} maybe_default_compression_level_; |
||||||
|
struct { |
||||||
|
bool is_set; |
||||||
|
grpc_compression_algorithm algorithm; |
||||||
|
} maybe_default_compression_algorithm_; |
||||||
|
uint32_t enabled_compression_algorithms_bitset_; |
||||||
|
std::vector< |
||||||
|
std::unique_ptr<grpc::experimental::ServerInterceptorFactoryInterface>> |
||||||
|
interceptor_creators_; |
||||||
|
}; |
||||||
|
|
||||||
|
} // namespace grpc_impl
|
||||||
|
|
||||||
|
#endif // GRPCPP_SERVER_BUILDER_IMPL_H
|
@ -0,0 +1,360 @@ |
|||||||
|
/*
|
||||||
|
* |
||||||
|
* Copyright 2015 gRPC authors. |
||||||
|
* |
||||||
|
* Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
|
||||||
|
* |
||||||
|
* Unless required by applicable law or agreed to in writing, software |
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, |
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||||
|
* See the License for the specific language governing permissions and |
||||||
|
* limitations under the License. |
||||||
|
* |
||||||
|
*/ |
||||||
|
|
||||||
|
#ifndef GRPCPP_SERVER_IMPL_H |
||||||
|
#define GRPCPP_SERVER_IMPL_H |
||||||
|
|
||||||
|
#include <condition_variable> |
||||||
|
#include <list> |
||||||
|
#include <memory> |
||||||
|
#include <mutex> |
||||||
|
#include <vector> |
||||||
|
|
||||||
|
#include <grpc/compression.h> |
||||||
|
#include <grpc/support/atm.h> |
||||||
|
#include <grpcpp/completion_queue.h> |
||||||
|
#include <grpcpp/impl/call.h> |
||||||
|
#include <grpcpp/impl/codegen/client_interceptor.h> |
||||||
|
#include <grpcpp/impl/codegen/grpc_library.h> |
||||||
|
#include <grpcpp/impl/codegen/server_interface.h> |
||||||
|
#include <grpcpp/impl/rpc_service_method.h> |
||||||
|
#include <grpcpp/security/server_credentials.h> |
||||||
|
#include <grpcpp/support/channel_arguments.h> |
||||||
|
#include <grpcpp/support/config.h> |
||||||
|
#include <grpcpp/support/status.h> |
||||||
|
|
||||||
|
struct grpc_server; |
||||||
|
|
||||||
|
namespace grpc { |
||||||
|
|
||||||
|
class AsyncGenericService; |
||||||
|
class ServerContext; |
||||||
|
|
||||||
|
} // namespace grpc
|
||||||
|
|
||||||
|
namespace grpc_impl { |
||||||
|
|
||||||
|
class HealthCheckServiceInterface; |
||||||
|
class ServerInitializer; |
||||||
|
|
||||||
|
/// Represents a gRPC server.
|
||||||
|
///
|
||||||
|
/// Use a \a grpc::ServerBuilder to create, configure, and start
|
||||||
|
/// \a Server instances.
|
||||||
|
class Server : public grpc::ServerInterface, private grpc::GrpcLibraryCodegen { |
||||||
|
public: |
||||||
|
~Server(); |
||||||
|
|
||||||
|
/// Block until the server shuts down.
|
||||||
|
///
|
||||||
|
/// \warning The server must be either shutting down or some other thread must
|
||||||
|
/// call \a Shutdown for this function to ever return.
|
||||||
|
void Wait() override; |
||||||
|
|
||||||
|
/// Global callbacks are a set of hooks that are called when server
|
||||||
|
/// events occur. \a SetGlobalCallbacks method is used to register
|
||||||
|
/// the hooks with gRPC. Note that
|
||||||
|
/// the \a GlobalCallbacks instance will be shared among all
|
||||||
|
/// \a Server instances in an application and can be set exactly
|
||||||
|
/// once per application.
|
||||||
|
class GlobalCallbacks { |
||||||
|
public: |
||||||
|
virtual ~GlobalCallbacks() {} |
||||||
|
/// Called before server is created.
|
||||||
|
virtual void UpdateArguments(grpc::ChannelArguments* args) {} |
||||||
|
/// Called before application callback for each synchronous server request
|
||||||
|
virtual void PreSynchronousRequest(grpc::ServerContext* context) = 0; |
||||||
|
/// Called after application callback for each synchronous server request
|
||||||
|
virtual void PostSynchronousRequest(grpc::ServerContext* context) = 0; |
||||||
|
/// Called before server is started.
|
||||||
|
virtual void PreServerStart(Server* server) {} |
||||||
|
/// Called after a server port is added.
|
||||||
|
virtual void AddPort(Server* server, const grpc::string& addr, |
||||||
|
grpc::ServerCredentials* creds, int port) {} |
||||||
|
}; |
||||||
|
/// Set the global callback object. Can only be called once per application.
|
||||||
|
/// Does not take ownership of callbacks, and expects the pointed to object
|
||||||
|
/// to be alive until all server objects in the process have been destroyed.
|
||||||
|
/// The same \a GlobalCallbacks object will be used throughout the
|
||||||
|
/// application and is shared among all \a Server objects.
|
||||||
|
static void SetGlobalCallbacks(GlobalCallbacks* callbacks); |
||||||
|
|
||||||
|
/// Returns a \em raw pointer to the underlying \a grpc_server instance.
|
||||||
|
/// EXPERIMENTAL: for internal/test use only
|
||||||
|
grpc_server* c_server(); |
||||||
|
|
||||||
|
/// Returns the health check service.
|
||||||
|
grpc_impl::HealthCheckServiceInterface* GetHealthCheckService() const { |
||||||
|
return health_check_service_.get(); |
||||||
|
} |
||||||
|
|
||||||
|
/// Establish a channel for in-process communication
|
||||||
|
std::shared_ptr<grpc::Channel> InProcessChannel( |
||||||
|
const grpc::ChannelArguments& args); |
||||||
|
|
||||||
|
/// NOTE: class experimental_type is not part of the public API of this class.
|
||||||
|
/// TODO(yashykt): Integrate into public API when this is no longer
|
||||||
|
/// experimental.
|
||||||
|
class experimental_type { |
||||||
|
public: |
||||||
|
explicit experimental_type(Server* server) : server_(server) {} |
||||||
|
|
||||||
|
/// Establish a channel for in-process communication with client
|
||||||
|
/// interceptors
|
||||||
|
std::shared_ptr<grpc::Channel> InProcessChannelWithInterceptors( |
||||||
|
const grpc::ChannelArguments& args, |
||||||
|
std::vector<std::unique_ptr< |
||||||
|
grpc::experimental::ClientInterceptorFactoryInterface>> |
||||||
|
interceptor_creators); |
||||||
|
|
||||||
|
private: |
||||||
|
Server* server_; |
||||||
|
}; |
||||||
|
|
||||||
|
/// NOTE: The function experimental() is not stable public API. It is a view
|
||||||
|
/// to the experimental components of this class. It may be changed or removed
|
||||||
|
/// at any time.
|
||||||
|
experimental_type experimental() { return experimental_type(this); } |
||||||
|
|
||||||
|
protected: |
||||||
|
/// Register a service. This call does not take ownership of the service.
|
||||||
|
/// The service must exist for the lifetime of the Server instance.
|
||||||
|
bool RegisterService(const grpc::string* host, |
||||||
|
grpc::Service* service) override; |
||||||
|
|
||||||
|
/// Try binding the server to the given \a addr endpoint
|
||||||
|
/// (port, and optionally including IP address to bind to).
|
||||||
|
///
|
||||||
|
/// It can be invoked multiple times. Should be used before
|
||||||
|
/// starting the server.
|
||||||
|
///
|
||||||
|
/// \param addr The address to try to bind to the server (eg, localhost:1234,
|
||||||
|
/// 192.168.1.1:31416, [::1]:27182, etc.).
|
||||||
|
/// \param creds The credentials associated with the server.
|
||||||
|
///
|
||||||
|
/// \return bound port number on success, 0 on failure.
|
||||||
|
///
|
||||||
|
/// \warning It is an error to call this method on an already started server.
|
||||||
|
int AddListeningPort(const grpc::string& addr, |
||||||
|
grpc::ServerCredentials* creds) override; |
||||||
|
|
||||||
|
/// NOTE: This is *NOT* a public API. The server constructors are supposed to
|
||||||
|
/// be used by \a ServerBuilder class only. The constructor will be made
|
||||||
|
/// 'private' very soon.
|
||||||
|
///
|
||||||
|
/// Server constructors. To be used by \a ServerBuilder only.
|
||||||
|
///
|
||||||
|
/// \param max_message_size Maximum message length that the channel can
|
||||||
|
/// receive.
|
||||||
|
///
|
||||||
|
/// \param args The channel args
|
||||||
|
///
|
||||||
|
/// \param sync_server_cqs The completion queues to use if the server is a
|
||||||
|
/// synchronous server (or a hybrid server). The server polls for new RPCs on
|
||||||
|
/// these queues
|
||||||
|
///
|
||||||
|
/// \param min_pollers The minimum number of polling threads per server
|
||||||
|
/// completion queue (in param sync_server_cqs) to use for listening to
|
||||||
|
/// incoming requests (used only in case of sync server)
|
||||||
|
///
|
||||||
|
/// \param max_pollers The maximum number of polling threads per server
|
||||||
|
/// completion queue (in param sync_server_cqs) to use for listening to
|
||||||
|
/// incoming requests (used only in case of sync server)
|
||||||
|
///
|
||||||
|
/// \param sync_cq_timeout_msec The timeout to use when calling AsyncNext() on
|
||||||
|
/// server completion queues passed via sync_server_cqs param.
|
||||||
|
Server( |
||||||
|
int max_message_size, grpc::ChannelArguments* args, |
||||||
|
std::shared_ptr<std::vector<std::unique_ptr<grpc::ServerCompletionQueue>>> |
||||||
|
sync_server_cqs, |
||||||
|
int min_pollers, int max_pollers, int sync_cq_timeout_msec, |
||||||
|
grpc_resource_quota* server_rq = nullptr, |
||||||
|
std::vector<std::unique_ptr< |
||||||
|
grpc::experimental::ServerInterceptorFactoryInterface>> |
||||||
|
interceptor_creators = std::vector<std::unique_ptr< |
||||||
|
grpc::experimental::ServerInterceptorFactoryInterface>>()); |
||||||
|
|
||||||
|
/// Start the server.
|
||||||
|
///
|
||||||
|
/// \param cqs Completion queues for handling asynchronous services. The
|
||||||
|
/// caller is required to keep all completion queues live until the server is
|
||||||
|
/// destroyed.
|
||||||
|
/// \param num_cqs How many completion queues does \a cqs hold.
|
||||||
|
void Start(grpc::ServerCompletionQueue** cqs, size_t num_cqs) override; |
||||||
|
|
||||||
|
grpc_server* server() override { return server_; } |
||||||
|
|
||||||
|
private: |
||||||
|
std::vector< |
||||||
|
std::unique_ptr<grpc::experimental::ServerInterceptorFactoryInterface>>* |
||||||
|
interceptor_creators() override { |
||||||
|
return &interceptor_creators_; |
||||||
|
} |
||||||
|
|
||||||
|
friend class grpc::AsyncGenericService; |
||||||
|
friend class grpc_impl::ServerBuilder; |
||||||
|
friend class grpc_impl::ServerInitializer; |
||||||
|
|
||||||
|
class SyncRequest; |
||||||
|
class CallbackRequestBase; |
||||||
|
template <class ServerContextType> |
||||||
|
class CallbackRequest; |
||||||
|
class UnimplementedAsyncRequest; |
||||||
|
class UnimplementedAsyncResponse; |
||||||
|
|
||||||
|
/// SyncRequestThreadManager is an implementation of ThreadManager. This class
|
||||||
|
/// is responsible for polling for incoming RPCs and calling the RPC handlers.
|
||||||
|
/// This is only used in case of a Sync server (i.e a server exposing a sync
|
||||||
|
/// interface)
|
||||||
|
class SyncRequestThreadManager; |
||||||
|
|
||||||
|
/// Register a generic service. This call does not take ownership of the
|
||||||
|
/// service. The service must exist for the lifetime of the Server instance.
|
||||||
|
void RegisterAsyncGenericService(grpc::AsyncGenericService* service) override; |
||||||
|
|
||||||
|
/// NOTE: class experimental_registration_type is not part of the public API
|
||||||
|
/// of this class
|
||||||
|
/// TODO(vjpai): Move these contents to the public API of Server when
|
||||||
|
/// they are no longer experimental
|
||||||
|
class experimental_registration_type final |
||||||
|
: public experimental_registration_interface { |
||||||
|
public: |
||||||
|
explicit experimental_registration_type(Server* server) : server_(server) {} |
||||||
|
void RegisterCallbackGenericService( |
||||||
|
grpc::experimental::CallbackGenericService* service) override { |
||||||
|
server_->RegisterCallbackGenericService(service); |
||||||
|
} |
||||||
|
|
||||||
|
private: |
||||||
|
Server* server_; |
||||||
|
}; |
||||||
|
|
||||||
|
/// TODO(vjpai): Mark this override when experimental type above is deleted
|
||||||
|
void RegisterCallbackGenericService( |
||||||
|
grpc::experimental::CallbackGenericService* service); |
||||||
|
|
||||||
|
/// NOTE: The function experimental_registration() is not stable public API.
|
||||||
|
/// It is a view to the experimental components of this class. It may be
|
||||||
|
/// changed or removed at any time.
|
||||||
|
experimental_registration_interface* experimental_registration() override { |
||||||
|
return &experimental_registration_; |
||||||
|
} |
||||||
|
|
||||||
|
void PerformOpsOnCall(grpc::internal::CallOpSetInterface* ops, |
||||||
|
grpc::internal::Call* call) override; |
||||||
|
|
||||||
|
void ShutdownInternal(gpr_timespec deadline) override; |
||||||
|
|
||||||
|
int max_receive_message_size() const override { |
||||||
|
return max_receive_message_size_; |
||||||
|
} |
||||||
|
|
||||||
|
grpc::CompletionQueue* CallbackCQ() override; |
||||||
|
|
||||||
|
grpc_impl::ServerInitializer* initializer(); |
||||||
|
|
||||||
|
// A vector of interceptor factory objects.
|
||||||
|
// This should be destroyed after health_check_service_ and this requirement
|
||||||
|
// is satisfied by declaring interceptor_creators_ before
|
||||||
|
// health_check_service_. (C++ mandates that member objects be destroyed in
|
||||||
|
// the reverse order of initialization.)
|
||||||
|
std::vector< |
||||||
|
std::unique_ptr<grpc::experimental::ServerInterceptorFactoryInterface>> |
||||||
|
interceptor_creators_; |
||||||
|
|
||||||
|
const int max_receive_message_size_; |
||||||
|
|
||||||
|
/// The following completion queues are ONLY used in case of Sync API
|
||||||
|
/// i.e. if the server has any services with sync methods. The server uses
|
||||||
|
/// these completion queues to poll for new RPCs
|
||||||
|
std::shared_ptr<std::vector<std::unique_ptr<grpc::ServerCompletionQueue>>> |
||||||
|
sync_server_cqs_; |
||||||
|
|
||||||
|
/// List of \a ThreadManager instances (one for each cq in
|
||||||
|
/// the \a sync_server_cqs)
|
||||||
|
std::vector<std::unique_ptr<SyncRequestThreadManager>> sync_req_mgrs_; |
||||||
|
|
||||||
|
// Outstanding unmatched callback requests, indexed by method.
|
||||||
|
// NOTE: Using a gpr_atm rather than atomic_int because atomic_int isn't
|
||||||
|
// copyable or movable and thus will cause compilation errors. We
|
||||||
|
// actually only want to extend the vector before the threaded use
|
||||||
|
// starts, but this is still a limitation.
|
||||||
|
std::vector<gpr_atm> callback_unmatched_reqs_count_; |
||||||
|
|
||||||
|
// List of callback requests to start when server actually starts.
|
||||||
|
std::list<CallbackRequestBase*> callback_reqs_to_start_; |
||||||
|
|
||||||
|
// For registering experimental callback generic service; remove when that
|
||||||
|
// method longer experimental
|
||||||
|
experimental_registration_type experimental_registration_{this}; |
||||||
|
|
||||||
|
// Server status
|
||||||
|
grpc::internal::Mutex mu_; |
||||||
|
bool started_; |
||||||
|
bool shutdown_; |
||||||
|
bool shutdown_notified_; // Was notify called on the shutdown_cv_
|
||||||
|
|
||||||
|
grpc::internal::CondVar shutdown_cv_; |
||||||
|
|
||||||
|
// It is ok (but not required) to nest callback_reqs_mu_ under mu_ .
|
||||||
|
// Incrementing callback_reqs_outstanding_ is ok without a lock but it must be
|
||||||
|
// decremented under the lock in case it is the last request and enables the
|
||||||
|
// server shutdown. The increment is performance-critical since it happens
|
||||||
|
// during periods of increasing load; the decrement happens only when memory
|
||||||
|
// is maxed out, during server shutdown, or (possibly in a future version)
|
||||||
|
// during decreasing load, so it is less performance-critical.
|
||||||
|
grpc::internal::Mutex callback_reqs_mu_; |
||||||
|
grpc::internal::CondVar callback_reqs_done_cv_; |
||||||
|
std::atomic_int callback_reqs_outstanding_{0}; |
||||||
|
|
||||||
|
std::shared_ptr<GlobalCallbacks> global_callbacks_; |
||||||
|
|
||||||
|
std::vector<grpc::string> services_; |
||||||
|
bool has_async_generic_service_{false}; |
||||||
|
bool has_callback_generic_service_{false}; |
||||||
|
|
||||||
|
// Pointer to the wrapped grpc_server.
|
||||||
|
grpc_server* server_; |
||||||
|
|
||||||
|
std::unique_ptr<grpc_impl::ServerInitializer> server_initializer_; |
||||||
|
|
||||||
|
std::unique_ptr<grpc_impl::HealthCheckServiceInterface> health_check_service_; |
||||||
|
bool health_check_service_disabled_; |
||||||
|
|
||||||
|
// When appropriate, use a default callback generic service to handle
|
||||||
|
// unimplemented methods
|
||||||
|
std::unique_ptr<grpc::experimental::CallbackGenericService> |
||||||
|
unimplemented_service_; |
||||||
|
|
||||||
|
// A special handler for resource exhausted in sync case
|
||||||
|
std::unique_ptr<grpc::internal::MethodHandler> resource_exhausted_handler_; |
||||||
|
|
||||||
|
// Handler for callback generic service, if any
|
||||||
|
std::unique_ptr<grpc::internal::MethodHandler> generic_handler_; |
||||||
|
|
||||||
|
// callback_cq_ references the callbackable completion queue associated
|
||||||
|
// with this server (if any). It is set on the first call to CallbackCQ().
|
||||||
|
// It is _not owned_ by the server; ownership belongs with its internal
|
||||||
|
// shutdown callback tag (invoked when the CQ is fully shutdown).
|
||||||
|
// It is protected by mu_
|
||||||
|
grpc::CompletionQueue* callback_cq_ = nullptr; |
||||||
|
}; |
||||||
|
|
||||||
|
} // namespace grpc_impl
|
||||||
|
|
||||||
|
#endif // GRPCPP_SERVER_IMPL_H
|
@ -0,0 +1,105 @@ |
|||||||
|
/* This file was generated by upbc (the upb compiler) from the input
|
||||||
|
* file: |
||||||
|
* |
||||||
|
* envoy/api/v2/endpoint/load_report.proto |
||||||
|
* |
||||||
|
* Do not edit -- your changes will be discarded when the file is |
||||||
|
* regenerated. */ |
||||||
|
|
||||||
|
#include <stddef.h> |
||||||
|
#include "upb/msg.h" |
||||||
|
#include "envoy/api/v2/endpoint/load_report.upb.h" |
||||||
|
#include "envoy/api/v2/core/address.upb.h" |
||||||
|
#include "envoy/api/v2/core/base.upb.h" |
||||||
|
#include "google/protobuf/duration.upb.h" |
||||||
|
#include "validate/validate.upb.h" |
||||||
|
#include "gogoproto/gogo.upb.h" |
||||||
|
|
||||||
|
#include "upb/port_def.inc" |
||||||
|
|
||||||
|
static const upb_msglayout *const envoy_api_v2_endpoint_UpstreamLocalityStats_submsgs[3] = { |
||||||
|
&envoy_api_v2_core_Locality_msginit, |
||||||
|
&envoy_api_v2_endpoint_EndpointLoadMetricStats_msginit, |
||||||
|
&envoy_api_v2_endpoint_UpstreamEndpointStats_msginit, |
||||||
|
}; |
||||||
|
|
||||||
|
static const upb_msglayout_field envoy_api_v2_endpoint_UpstreamLocalityStats__fields[7] = { |
||||||
|
{1, UPB_SIZE(28, 32), 0, 0, 11, 1}, |
||||||
|
{2, UPB_SIZE(0, 0), 0, 0, 4, 1}, |
||||||
|
{3, UPB_SIZE(8, 8), 0, 0, 4, 1}, |
||||||
|
{4, UPB_SIZE(16, 16), 0, 0, 4, 1}, |
||||||
|
{5, UPB_SIZE(32, 40), 0, 1, 11, 3}, |
||||||
|
{6, UPB_SIZE(24, 24), 0, 0, 13, 1}, |
||||||
|
{7, UPB_SIZE(36, 48), 0, 2, 11, 3}, |
||||||
|
}; |
||||||
|
|
||||||
|
const upb_msglayout envoy_api_v2_endpoint_UpstreamLocalityStats_msginit = { |
||||||
|
&envoy_api_v2_endpoint_UpstreamLocalityStats_submsgs[0], |
||||||
|
&envoy_api_v2_endpoint_UpstreamLocalityStats__fields[0], |
||||||
|
UPB_SIZE(40, 56), 7, false, |
||||||
|
}; |
||||||
|
|
||||||
|
static const upb_msglayout *const envoy_api_v2_endpoint_UpstreamEndpointStats_submsgs[2] = { |
||||||
|
&envoy_api_v2_core_Address_msginit, |
||||||
|
&envoy_api_v2_endpoint_EndpointLoadMetricStats_msginit, |
||||||
|
}; |
||||||
|
|
||||||
|
static const upb_msglayout_field envoy_api_v2_endpoint_UpstreamEndpointStats__fields[5] = { |
||||||
|
{1, UPB_SIZE(24, 24), 0, 0, 11, 1}, |
||||||
|
{2, UPB_SIZE(0, 0), 0, 0, 4, 1}, |
||||||
|
{3, UPB_SIZE(8, 8), 0, 0, 4, 1}, |
||||||
|
{4, UPB_SIZE(16, 16), 0, 0, 4, 1}, |
||||||
|
{5, UPB_SIZE(28, 32), 0, 1, 11, 3}, |
||||||
|
}; |
||||||
|
|
||||||
|
const upb_msglayout envoy_api_v2_endpoint_UpstreamEndpointStats_msginit = { |
||||||
|
&envoy_api_v2_endpoint_UpstreamEndpointStats_submsgs[0], |
||||||
|
&envoy_api_v2_endpoint_UpstreamEndpointStats__fields[0], |
||||||
|
UPB_SIZE(32, 40), 5, false, |
||||||
|
}; |
||||||
|
|
||||||
|
static const upb_msglayout_field envoy_api_v2_endpoint_EndpointLoadMetricStats__fields[3] = { |
||||||
|
{1, UPB_SIZE(16, 16), 0, 0, 9, 1}, |
||||||
|
{2, UPB_SIZE(0, 0), 0, 0, 4, 1}, |
||||||
|
{3, UPB_SIZE(8, 8), 0, 0, 1, 1}, |
||||||
|
}; |
||||||
|
|
||||||
|
const upb_msglayout envoy_api_v2_endpoint_EndpointLoadMetricStats_msginit = { |
||||||
|
NULL, |
||||||
|
&envoy_api_v2_endpoint_EndpointLoadMetricStats__fields[0], |
||||||
|
UPB_SIZE(24, 32), 3, false, |
||||||
|
}; |
||||||
|
|
||||||
|
static const upb_msglayout *const envoy_api_v2_endpoint_ClusterStats_submsgs[3] = { |
||||||
|
&envoy_api_v2_endpoint_ClusterStats_DroppedRequests_msginit, |
||||||
|
&envoy_api_v2_endpoint_UpstreamLocalityStats_msginit, |
||||||
|
&google_protobuf_Duration_msginit, |
||||||
|
}; |
||||||
|
|
||||||
|
static const upb_msglayout_field envoy_api_v2_endpoint_ClusterStats__fields[5] = { |
||||||
|
{1, UPB_SIZE(8, 8), 0, 0, 9, 1}, |
||||||
|
{2, UPB_SIZE(20, 32), 0, 1, 11, 3}, |
||||||
|
{3, UPB_SIZE(0, 0), 0, 0, 4, 1}, |
||||||
|
{4, UPB_SIZE(16, 24), 0, 2, 11, 1}, |
||||||
|
{5, UPB_SIZE(24, 40), 0, 0, 11, 3}, |
||||||
|
}; |
||||||
|
|
||||||
|
const upb_msglayout envoy_api_v2_endpoint_ClusterStats_msginit = { |
||||||
|
&envoy_api_v2_endpoint_ClusterStats_submsgs[0], |
||||||
|
&envoy_api_v2_endpoint_ClusterStats__fields[0], |
||||||
|
UPB_SIZE(32, 48), 5, false, |
||||||
|
}; |
||||||
|
|
||||||
|
static const upb_msglayout_field envoy_api_v2_endpoint_ClusterStats_DroppedRequests__fields[2] = { |
||||||
|
{1, UPB_SIZE(8, 8), 0, 0, 9, 1}, |
||||||
|
{2, UPB_SIZE(0, 0), 0, 0, 4, 1}, |
||||||
|
}; |
||||||
|
|
||||||
|
const upb_msglayout envoy_api_v2_endpoint_ClusterStats_DroppedRequests_msginit = { |
||||||
|
NULL, |
||||||
|
&envoy_api_v2_endpoint_ClusterStats_DroppedRequests__fields[0], |
||||||
|
UPB_SIZE(16, 32), 2, false, |
||||||
|
}; |
||||||
|
|
||||||
|
#include "upb/port_undef.inc" |
||||||
|
|
@ -0,0 +1,299 @@ |
|||||||
|
/* This file was generated by upbc (the upb compiler) from the input
|
||||||
|
* file: |
||||||
|
* |
||||||
|
* envoy/api/v2/endpoint/load_report.proto |
||||||
|
* |
||||||
|
* Do not edit -- your changes will be discarded when the file is |
||||||
|
* regenerated. */ |
||||||
|
|
||||||
|
#ifndef ENVOY_API_V2_ENDPOINT_LOAD_REPORT_PROTO_UPB_H_ |
||||||
|
#define ENVOY_API_V2_ENDPOINT_LOAD_REPORT_PROTO_UPB_H_ |
||||||
|
|
||||||
|
#include "upb/generated_util.h" |
||||||
|
|
||||||
|
#include "upb/msg.h" |
||||||
|
|
||||||
|
#include "upb/decode.h" |
||||||
|
#include "upb/encode.h" |
||||||
|
#include "upb/port_def.inc" |
||||||
|
#ifdef __cplusplus |
||||||
|
extern "C" { |
||||||
|
#endif |
||||||
|
|
||||||
|
struct envoy_api_v2_endpoint_UpstreamLocalityStats; |
||||||
|
struct envoy_api_v2_endpoint_UpstreamEndpointStats; |
||||||
|
struct envoy_api_v2_endpoint_EndpointLoadMetricStats; |
||||||
|
struct envoy_api_v2_endpoint_ClusterStats; |
||||||
|
struct envoy_api_v2_endpoint_ClusterStats_DroppedRequests; |
||||||
|
typedef struct envoy_api_v2_endpoint_UpstreamLocalityStats envoy_api_v2_endpoint_UpstreamLocalityStats; |
||||||
|
typedef struct envoy_api_v2_endpoint_UpstreamEndpointStats envoy_api_v2_endpoint_UpstreamEndpointStats; |
||||||
|
typedef struct envoy_api_v2_endpoint_EndpointLoadMetricStats envoy_api_v2_endpoint_EndpointLoadMetricStats; |
||||||
|
typedef struct envoy_api_v2_endpoint_ClusterStats envoy_api_v2_endpoint_ClusterStats; |
||||||
|
typedef struct envoy_api_v2_endpoint_ClusterStats_DroppedRequests envoy_api_v2_endpoint_ClusterStats_DroppedRequests; |
||||||
|
extern const upb_msglayout envoy_api_v2_endpoint_UpstreamLocalityStats_msginit; |
||||||
|
extern const upb_msglayout envoy_api_v2_endpoint_UpstreamEndpointStats_msginit; |
||||||
|
extern const upb_msglayout envoy_api_v2_endpoint_EndpointLoadMetricStats_msginit; |
||||||
|
extern const upb_msglayout envoy_api_v2_endpoint_ClusterStats_msginit; |
||||||
|
extern const upb_msglayout envoy_api_v2_endpoint_ClusterStats_DroppedRequests_msginit; |
||||||
|
struct envoy_api_v2_core_Address; |
||||||
|
struct envoy_api_v2_core_Locality; |
||||||
|
struct google_protobuf_Duration; |
||||||
|
extern const upb_msglayout envoy_api_v2_core_Address_msginit; |
||||||
|
extern const upb_msglayout envoy_api_v2_core_Locality_msginit; |
||||||
|
extern const upb_msglayout google_protobuf_Duration_msginit; |
||||||
|
|
||||||
|
/* Enums */ |
||||||
|
|
||||||
|
|
||||||
|
/* envoy.api.v2.endpoint.UpstreamLocalityStats */ |
||||||
|
|
||||||
|
UPB_INLINE envoy_api_v2_endpoint_UpstreamLocalityStats *envoy_api_v2_endpoint_UpstreamLocalityStats_new(upb_arena *arena) { |
||||||
|
return (envoy_api_v2_endpoint_UpstreamLocalityStats *)upb_msg_new(&envoy_api_v2_endpoint_UpstreamLocalityStats_msginit, arena); |
||||||
|
} |
||||||
|
UPB_INLINE envoy_api_v2_endpoint_UpstreamLocalityStats *envoy_api_v2_endpoint_UpstreamLocalityStats_parsenew(upb_strview buf, upb_arena *arena) { |
||||||
|
envoy_api_v2_endpoint_UpstreamLocalityStats *ret = envoy_api_v2_endpoint_UpstreamLocalityStats_new(arena); |
||||||
|
return (ret && upb_decode(buf, ret, &envoy_api_v2_endpoint_UpstreamLocalityStats_msginit)) ? ret : NULL; |
||||||
|
} |
||||||
|
UPB_INLINE char *envoy_api_v2_endpoint_UpstreamLocalityStats_serialize(const envoy_api_v2_endpoint_UpstreamLocalityStats *msg, upb_arena *arena, size_t *len) { |
||||||
|
return upb_encode(msg, &envoy_api_v2_endpoint_UpstreamLocalityStats_msginit, arena, len); |
||||||
|
} |
||||||
|
|
||||||
|
UPB_INLINE const struct envoy_api_v2_core_Locality* envoy_api_v2_endpoint_UpstreamLocalityStats_locality(const envoy_api_v2_endpoint_UpstreamLocalityStats *msg) { return UPB_FIELD_AT(msg, const struct envoy_api_v2_core_Locality*, UPB_SIZE(28, 32)); } |
||||||
|
UPB_INLINE uint64_t envoy_api_v2_endpoint_UpstreamLocalityStats_total_successful_requests(const envoy_api_v2_endpoint_UpstreamLocalityStats *msg) { return UPB_FIELD_AT(msg, uint64_t, UPB_SIZE(0, 0)); } |
||||||
|
UPB_INLINE uint64_t envoy_api_v2_endpoint_UpstreamLocalityStats_total_requests_in_progress(const envoy_api_v2_endpoint_UpstreamLocalityStats *msg) { return UPB_FIELD_AT(msg, uint64_t, UPB_SIZE(8, 8)); } |
||||||
|
UPB_INLINE uint64_t envoy_api_v2_endpoint_UpstreamLocalityStats_total_error_requests(const envoy_api_v2_endpoint_UpstreamLocalityStats *msg) { return UPB_FIELD_AT(msg, uint64_t, UPB_SIZE(16, 16)); } |
||||||
|
UPB_INLINE const envoy_api_v2_endpoint_EndpointLoadMetricStats* const* envoy_api_v2_endpoint_UpstreamLocalityStats_load_metric_stats(const envoy_api_v2_endpoint_UpstreamLocalityStats *msg, size_t *len) { return (const envoy_api_v2_endpoint_EndpointLoadMetricStats* const*)_upb_array_accessor(msg, UPB_SIZE(32, 40), len); } |
||||||
|
UPB_INLINE uint32_t envoy_api_v2_endpoint_UpstreamLocalityStats_priority(const envoy_api_v2_endpoint_UpstreamLocalityStats *msg) { return UPB_FIELD_AT(msg, uint32_t, UPB_SIZE(24, 24)); } |
||||||
|
UPB_INLINE const envoy_api_v2_endpoint_UpstreamEndpointStats* const* envoy_api_v2_endpoint_UpstreamLocalityStats_upstream_endpoint_stats(const envoy_api_v2_endpoint_UpstreamLocalityStats *msg, size_t *len) { return (const envoy_api_v2_endpoint_UpstreamEndpointStats* const*)_upb_array_accessor(msg, UPB_SIZE(36, 48), len); } |
||||||
|
|
||||||
|
UPB_INLINE void envoy_api_v2_endpoint_UpstreamLocalityStats_set_locality(envoy_api_v2_endpoint_UpstreamLocalityStats *msg, struct envoy_api_v2_core_Locality* value) { |
||||||
|
UPB_FIELD_AT(msg, struct envoy_api_v2_core_Locality*, UPB_SIZE(28, 32)) = value; |
||||||
|
} |
||||||
|
UPB_INLINE struct envoy_api_v2_core_Locality* envoy_api_v2_endpoint_UpstreamLocalityStats_mutable_locality(envoy_api_v2_endpoint_UpstreamLocalityStats *msg, upb_arena *arena) { |
||||||
|
struct envoy_api_v2_core_Locality* sub = (struct envoy_api_v2_core_Locality*)envoy_api_v2_endpoint_UpstreamLocalityStats_locality(msg); |
||||||
|
if (sub == NULL) { |
||||||
|
sub = (struct envoy_api_v2_core_Locality*)upb_msg_new(&envoy_api_v2_core_Locality_msginit, arena); |
||||||
|
if (!sub) return NULL; |
||||||
|
envoy_api_v2_endpoint_UpstreamLocalityStats_set_locality(msg, sub); |
||||||
|
} |
||||||
|
return sub; |
||||||
|
} |
||||||
|
UPB_INLINE void envoy_api_v2_endpoint_UpstreamLocalityStats_set_total_successful_requests(envoy_api_v2_endpoint_UpstreamLocalityStats *msg, uint64_t value) { |
||||||
|
UPB_FIELD_AT(msg, uint64_t, UPB_SIZE(0, 0)) = value; |
||||||
|
} |
||||||
|
UPB_INLINE void envoy_api_v2_endpoint_UpstreamLocalityStats_set_total_requests_in_progress(envoy_api_v2_endpoint_UpstreamLocalityStats *msg, uint64_t value) { |
||||||
|
UPB_FIELD_AT(msg, uint64_t, UPB_SIZE(8, 8)) = value; |
||||||
|
} |
||||||
|
UPB_INLINE void envoy_api_v2_endpoint_UpstreamLocalityStats_set_total_error_requests(envoy_api_v2_endpoint_UpstreamLocalityStats *msg, uint64_t value) { |
||||||
|
UPB_FIELD_AT(msg, uint64_t, UPB_SIZE(16, 16)) = value; |
||||||
|
} |
||||||
|
UPB_INLINE envoy_api_v2_endpoint_EndpointLoadMetricStats** envoy_api_v2_endpoint_UpstreamLocalityStats_mutable_load_metric_stats(envoy_api_v2_endpoint_UpstreamLocalityStats *msg, size_t *len) { |
||||||
|
return (envoy_api_v2_endpoint_EndpointLoadMetricStats**)_upb_array_mutable_accessor(msg, UPB_SIZE(32, 40), len); |
||||||
|
} |
||||||
|
UPB_INLINE envoy_api_v2_endpoint_EndpointLoadMetricStats** envoy_api_v2_endpoint_UpstreamLocalityStats_resize_load_metric_stats(envoy_api_v2_endpoint_UpstreamLocalityStats *msg, size_t len, upb_arena *arena) { |
||||||
|
return (envoy_api_v2_endpoint_EndpointLoadMetricStats**)_upb_array_resize_accessor(msg, UPB_SIZE(32, 40), len, UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, arena); |
||||||
|
} |
||||||
|
UPB_INLINE struct envoy_api_v2_endpoint_EndpointLoadMetricStats* envoy_api_v2_endpoint_UpstreamLocalityStats_add_load_metric_stats(envoy_api_v2_endpoint_UpstreamLocalityStats *msg, upb_arena *arena) { |
||||||
|
struct envoy_api_v2_endpoint_EndpointLoadMetricStats* sub = (struct envoy_api_v2_endpoint_EndpointLoadMetricStats*)upb_msg_new(&envoy_api_v2_endpoint_EndpointLoadMetricStats_msginit, arena); |
||||||
|
bool ok = _upb_array_append_accessor( |
||||||
|
msg, UPB_SIZE(32, 40), UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, &sub, arena); |
||||||
|
if (!ok) return NULL; |
||||||
|
return sub; |
||||||
|
} |
||||||
|
UPB_INLINE void envoy_api_v2_endpoint_UpstreamLocalityStats_set_priority(envoy_api_v2_endpoint_UpstreamLocalityStats *msg, uint32_t value) { |
||||||
|
UPB_FIELD_AT(msg, uint32_t, UPB_SIZE(24, 24)) = value; |
||||||
|
} |
||||||
|
UPB_INLINE envoy_api_v2_endpoint_UpstreamEndpointStats** envoy_api_v2_endpoint_UpstreamLocalityStats_mutable_upstream_endpoint_stats(envoy_api_v2_endpoint_UpstreamLocalityStats *msg, size_t *len) { |
||||||
|
return (envoy_api_v2_endpoint_UpstreamEndpointStats**)_upb_array_mutable_accessor(msg, UPB_SIZE(36, 48), len); |
||||||
|
} |
||||||
|
UPB_INLINE envoy_api_v2_endpoint_UpstreamEndpointStats** envoy_api_v2_endpoint_UpstreamLocalityStats_resize_upstream_endpoint_stats(envoy_api_v2_endpoint_UpstreamLocalityStats *msg, size_t len, upb_arena *arena) { |
||||||
|
return (envoy_api_v2_endpoint_UpstreamEndpointStats**)_upb_array_resize_accessor(msg, UPB_SIZE(36, 48), len, UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, arena); |
||||||
|
} |
||||||
|
UPB_INLINE struct envoy_api_v2_endpoint_UpstreamEndpointStats* envoy_api_v2_endpoint_UpstreamLocalityStats_add_upstream_endpoint_stats(envoy_api_v2_endpoint_UpstreamLocalityStats *msg, upb_arena *arena) { |
||||||
|
struct envoy_api_v2_endpoint_UpstreamEndpointStats* sub = (struct envoy_api_v2_endpoint_UpstreamEndpointStats*)upb_msg_new(&envoy_api_v2_endpoint_UpstreamEndpointStats_msginit, arena); |
||||||
|
bool ok = _upb_array_append_accessor( |
||||||
|
msg, UPB_SIZE(36, 48), UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, &sub, arena); |
||||||
|
if (!ok) return NULL; |
||||||
|
return sub; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
/* envoy.api.v2.endpoint.UpstreamEndpointStats */ |
||||||
|
|
||||||
|
UPB_INLINE envoy_api_v2_endpoint_UpstreamEndpointStats *envoy_api_v2_endpoint_UpstreamEndpointStats_new(upb_arena *arena) { |
||||||
|
return (envoy_api_v2_endpoint_UpstreamEndpointStats *)upb_msg_new(&envoy_api_v2_endpoint_UpstreamEndpointStats_msginit, arena); |
||||||
|
} |
||||||
|
UPB_INLINE envoy_api_v2_endpoint_UpstreamEndpointStats *envoy_api_v2_endpoint_UpstreamEndpointStats_parsenew(upb_strview buf, upb_arena *arena) { |
||||||
|
envoy_api_v2_endpoint_UpstreamEndpointStats *ret = envoy_api_v2_endpoint_UpstreamEndpointStats_new(arena); |
||||||
|
return (ret && upb_decode(buf, ret, &envoy_api_v2_endpoint_UpstreamEndpointStats_msginit)) ? ret : NULL; |
||||||
|
} |
||||||
|
UPB_INLINE char *envoy_api_v2_endpoint_UpstreamEndpointStats_serialize(const envoy_api_v2_endpoint_UpstreamEndpointStats *msg, upb_arena *arena, size_t *len) { |
||||||
|
return upb_encode(msg, &envoy_api_v2_endpoint_UpstreamEndpointStats_msginit, arena, len); |
||||||
|
} |
||||||
|
|
||||||
|
UPB_INLINE const struct envoy_api_v2_core_Address* envoy_api_v2_endpoint_UpstreamEndpointStats_address(const envoy_api_v2_endpoint_UpstreamEndpointStats *msg) { return UPB_FIELD_AT(msg, const struct envoy_api_v2_core_Address*, UPB_SIZE(24, 24)); } |
||||||
|
UPB_INLINE uint64_t envoy_api_v2_endpoint_UpstreamEndpointStats_total_successful_requests(const envoy_api_v2_endpoint_UpstreamEndpointStats *msg) { return UPB_FIELD_AT(msg, uint64_t, UPB_SIZE(0, 0)); } |
||||||
|
UPB_INLINE uint64_t envoy_api_v2_endpoint_UpstreamEndpointStats_total_requests_in_progress(const envoy_api_v2_endpoint_UpstreamEndpointStats *msg) { return UPB_FIELD_AT(msg, uint64_t, UPB_SIZE(8, 8)); } |
||||||
|
UPB_INLINE uint64_t envoy_api_v2_endpoint_UpstreamEndpointStats_total_error_requests(const envoy_api_v2_endpoint_UpstreamEndpointStats *msg) { return UPB_FIELD_AT(msg, uint64_t, UPB_SIZE(16, 16)); } |
||||||
|
UPB_INLINE const envoy_api_v2_endpoint_EndpointLoadMetricStats* const* envoy_api_v2_endpoint_UpstreamEndpointStats_load_metric_stats(const envoy_api_v2_endpoint_UpstreamEndpointStats *msg, size_t *len) { return (const envoy_api_v2_endpoint_EndpointLoadMetricStats* const*)_upb_array_accessor(msg, UPB_SIZE(28, 32), len); } |
||||||
|
|
||||||
|
UPB_INLINE void envoy_api_v2_endpoint_UpstreamEndpointStats_set_address(envoy_api_v2_endpoint_UpstreamEndpointStats *msg, struct envoy_api_v2_core_Address* value) { |
||||||
|
UPB_FIELD_AT(msg, struct envoy_api_v2_core_Address*, UPB_SIZE(24, 24)) = value; |
||||||
|
} |
||||||
|
UPB_INLINE struct envoy_api_v2_core_Address* envoy_api_v2_endpoint_UpstreamEndpointStats_mutable_address(envoy_api_v2_endpoint_UpstreamEndpointStats *msg, upb_arena *arena) { |
||||||
|
struct envoy_api_v2_core_Address* sub = (struct envoy_api_v2_core_Address*)envoy_api_v2_endpoint_UpstreamEndpointStats_address(msg); |
||||||
|
if (sub == NULL) { |
||||||
|
sub = (struct envoy_api_v2_core_Address*)upb_msg_new(&envoy_api_v2_core_Address_msginit, arena); |
||||||
|
if (!sub) return NULL; |
||||||
|
envoy_api_v2_endpoint_UpstreamEndpointStats_set_address(msg, sub); |
||||||
|
} |
||||||
|
return sub; |
||||||
|
} |
||||||
|
UPB_INLINE void envoy_api_v2_endpoint_UpstreamEndpointStats_set_total_successful_requests(envoy_api_v2_endpoint_UpstreamEndpointStats *msg, uint64_t value) { |
||||||
|
UPB_FIELD_AT(msg, uint64_t, UPB_SIZE(0, 0)) = value; |
||||||
|
} |
||||||
|
UPB_INLINE void envoy_api_v2_endpoint_UpstreamEndpointStats_set_total_requests_in_progress(envoy_api_v2_endpoint_UpstreamEndpointStats *msg, uint64_t value) { |
||||||
|
UPB_FIELD_AT(msg, uint64_t, UPB_SIZE(8, 8)) = value; |
||||||
|
} |
||||||
|
UPB_INLINE void envoy_api_v2_endpoint_UpstreamEndpointStats_set_total_error_requests(envoy_api_v2_endpoint_UpstreamEndpointStats *msg, uint64_t value) { |
||||||
|
UPB_FIELD_AT(msg, uint64_t, UPB_SIZE(16, 16)) = value; |
||||||
|
} |
||||||
|
UPB_INLINE envoy_api_v2_endpoint_EndpointLoadMetricStats** envoy_api_v2_endpoint_UpstreamEndpointStats_mutable_load_metric_stats(envoy_api_v2_endpoint_UpstreamEndpointStats *msg, size_t *len) { |
||||||
|
return (envoy_api_v2_endpoint_EndpointLoadMetricStats**)_upb_array_mutable_accessor(msg, UPB_SIZE(28, 32), len); |
||||||
|
} |
||||||
|
UPB_INLINE envoy_api_v2_endpoint_EndpointLoadMetricStats** envoy_api_v2_endpoint_UpstreamEndpointStats_resize_load_metric_stats(envoy_api_v2_endpoint_UpstreamEndpointStats *msg, size_t len, upb_arena *arena) { |
||||||
|
return (envoy_api_v2_endpoint_EndpointLoadMetricStats**)_upb_array_resize_accessor(msg, UPB_SIZE(28, 32), len, UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, arena); |
||||||
|
} |
||||||
|
UPB_INLINE struct envoy_api_v2_endpoint_EndpointLoadMetricStats* envoy_api_v2_endpoint_UpstreamEndpointStats_add_load_metric_stats(envoy_api_v2_endpoint_UpstreamEndpointStats *msg, upb_arena *arena) { |
||||||
|
struct envoy_api_v2_endpoint_EndpointLoadMetricStats* sub = (struct envoy_api_v2_endpoint_EndpointLoadMetricStats*)upb_msg_new(&envoy_api_v2_endpoint_EndpointLoadMetricStats_msginit, arena); |
||||||
|
bool ok = _upb_array_append_accessor( |
||||||
|
msg, UPB_SIZE(28, 32), UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, &sub, arena); |
||||||
|
if (!ok) return NULL; |
||||||
|
return sub; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
/* envoy.api.v2.endpoint.EndpointLoadMetricStats */ |
||||||
|
|
||||||
|
UPB_INLINE envoy_api_v2_endpoint_EndpointLoadMetricStats *envoy_api_v2_endpoint_EndpointLoadMetricStats_new(upb_arena *arena) { |
||||||
|
return (envoy_api_v2_endpoint_EndpointLoadMetricStats *)upb_msg_new(&envoy_api_v2_endpoint_EndpointLoadMetricStats_msginit, arena); |
||||||
|
} |
||||||
|
UPB_INLINE envoy_api_v2_endpoint_EndpointLoadMetricStats *envoy_api_v2_endpoint_EndpointLoadMetricStats_parsenew(upb_strview buf, upb_arena *arena) { |
||||||
|
envoy_api_v2_endpoint_EndpointLoadMetricStats *ret = envoy_api_v2_endpoint_EndpointLoadMetricStats_new(arena); |
||||||
|
return (ret && upb_decode(buf, ret, &envoy_api_v2_endpoint_EndpointLoadMetricStats_msginit)) ? ret : NULL; |
||||||
|
} |
||||||
|
UPB_INLINE char *envoy_api_v2_endpoint_EndpointLoadMetricStats_serialize(const envoy_api_v2_endpoint_EndpointLoadMetricStats *msg, upb_arena *arena, size_t *len) { |
||||||
|
return upb_encode(msg, &envoy_api_v2_endpoint_EndpointLoadMetricStats_msginit, arena, len); |
||||||
|
} |
||||||
|
|
||||||
|
UPB_INLINE upb_strview envoy_api_v2_endpoint_EndpointLoadMetricStats_metric_name(const envoy_api_v2_endpoint_EndpointLoadMetricStats *msg) { return UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(16, 16)); } |
||||||
|
UPB_INLINE uint64_t envoy_api_v2_endpoint_EndpointLoadMetricStats_num_requests_finished_with_metric(const envoy_api_v2_endpoint_EndpointLoadMetricStats *msg) { return UPB_FIELD_AT(msg, uint64_t, UPB_SIZE(0, 0)); } |
||||||
|
UPB_INLINE double envoy_api_v2_endpoint_EndpointLoadMetricStats_total_metric_value(const envoy_api_v2_endpoint_EndpointLoadMetricStats *msg) { return UPB_FIELD_AT(msg, double, UPB_SIZE(8, 8)); } |
||||||
|
|
||||||
|
UPB_INLINE void envoy_api_v2_endpoint_EndpointLoadMetricStats_set_metric_name(envoy_api_v2_endpoint_EndpointLoadMetricStats *msg, upb_strview value) { |
||||||
|
UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(16, 16)) = value; |
||||||
|
} |
||||||
|
UPB_INLINE void envoy_api_v2_endpoint_EndpointLoadMetricStats_set_num_requests_finished_with_metric(envoy_api_v2_endpoint_EndpointLoadMetricStats *msg, uint64_t value) { |
||||||
|
UPB_FIELD_AT(msg, uint64_t, UPB_SIZE(0, 0)) = value; |
||||||
|
} |
||||||
|
UPB_INLINE void envoy_api_v2_endpoint_EndpointLoadMetricStats_set_total_metric_value(envoy_api_v2_endpoint_EndpointLoadMetricStats *msg, double value) { |
||||||
|
UPB_FIELD_AT(msg, double, UPB_SIZE(8, 8)) = value; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
/* envoy.api.v2.endpoint.ClusterStats */ |
||||||
|
|
||||||
|
UPB_INLINE envoy_api_v2_endpoint_ClusterStats *envoy_api_v2_endpoint_ClusterStats_new(upb_arena *arena) { |
||||||
|
return (envoy_api_v2_endpoint_ClusterStats *)upb_msg_new(&envoy_api_v2_endpoint_ClusterStats_msginit, arena); |
||||||
|
} |
||||||
|
UPB_INLINE envoy_api_v2_endpoint_ClusterStats *envoy_api_v2_endpoint_ClusterStats_parsenew(upb_strview buf, upb_arena *arena) { |
||||||
|
envoy_api_v2_endpoint_ClusterStats *ret = envoy_api_v2_endpoint_ClusterStats_new(arena); |
||||||
|
return (ret && upb_decode(buf, ret, &envoy_api_v2_endpoint_ClusterStats_msginit)) ? ret : NULL; |
||||||
|
} |
||||||
|
UPB_INLINE char *envoy_api_v2_endpoint_ClusterStats_serialize(const envoy_api_v2_endpoint_ClusterStats *msg, upb_arena *arena, size_t *len) { |
||||||
|
return upb_encode(msg, &envoy_api_v2_endpoint_ClusterStats_msginit, arena, len); |
||||||
|
} |
||||||
|
|
||||||
|
UPB_INLINE upb_strview envoy_api_v2_endpoint_ClusterStats_cluster_name(const envoy_api_v2_endpoint_ClusterStats *msg) { return UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(8, 8)); } |
||||||
|
UPB_INLINE const envoy_api_v2_endpoint_UpstreamLocalityStats* const* envoy_api_v2_endpoint_ClusterStats_upstream_locality_stats(const envoy_api_v2_endpoint_ClusterStats *msg, size_t *len) { return (const envoy_api_v2_endpoint_UpstreamLocalityStats* const*)_upb_array_accessor(msg, UPB_SIZE(20, 32), len); } |
||||||
|
UPB_INLINE uint64_t envoy_api_v2_endpoint_ClusterStats_total_dropped_requests(const envoy_api_v2_endpoint_ClusterStats *msg) { return UPB_FIELD_AT(msg, uint64_t, UPB_SIZE(0, 0)); } |
||||||
|
UPB_INLINE const struct google_protobuf_Duration* envoy_api_v2_endpoint_ClusterStats_load_report_interval(const envoy_api_v2_endpoint_ClusterStats *msg) { return UPB_FIELD_AT(msg, const struct google_protobuf_Duration*, UPB_SIZE(16, 24)); } |
||||||
|
UPB_INLINE const envoy_api_v2_endpoint_ClusterStats_DroppedRequests* const* envoy_api_v2_endpoint_ClusterStats_dropped_requests(const envoy_api_v2_endpoint_ClusterStats *msg, size_t *len) { return (const envoy_api_v2_endpoint_ClusterStats_DroppedRequests* const*)_upb_array_accessor(msg, UPB_SIZE(24, 40), len); } |
||||||
|
|
||||||
|
UPB_INLINE void envoy_api_v2_endpoint_ClusterStats_set_cluster_name(envoy_api_v2_endpoint_ClusterStats *msg, upb_strview value) { |
||||||
|
UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(8, 8)) = value; |
||||||
|
} |
||||||
|
UPB_INLINE envoy_api_v2_endpoint_UpstreamLocalityStats** envoy_api_v2_endpoint_ClusterStats_mutable_upstream_locality_stats(envoy_api_v2_endpoint_ClusterStats *msg, size_t *len) { |
||||||
|
return (envoy_api_v2_endpoint_UpstreamLocalityStats**)_upb_array_mutable_accessor(msg, UPB_SIZE(20, 32), len); |
||||||
|
} |
||||||
|
UPB_INLINE envoy_api_v2_endpoint_UpstreamLocalityStats** envoy_api_v2_endpoint_ClusterStats_resize_upstream_locality_stats(envoy_api_v2_endpoint_ClusterStats *msg, size_t len, upb_arena *arena) { |
||||||
|
return (envoy_api_v2_endpoint_UpstreamLocalityStats**)_upb_array_resize_accessor(msg, UPB_SIZE(20, 32), len, UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, arena); |
||||||
|
} |
||||||
|
UPB_INLINE struct envoy_api_v2_endpoint_UpstreamLocalityStats* envoy_api_v2_endpoint_ClusterStats_add_upstream_locality_stats(envoy_api_v2_endpoint_ClusterStats *msg, upb_arena *arena) { |
||||||
|
struct envoy_api_v2_endpoint_UpstreamLocalityStats* sub = (struct envoy_api_v2_endpoint_UpstreamLocalityStats*)upb_msg_new(&envoy_api_v2_endpoint_UpstreamLocalityStats_msginit, arena); |
||||||
|
bool ok = _upb_array_append_accessor( |
||||||
|
msg, UPB_SIZE(20, 32), UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, &sub, arena); |
||||||
|
if (!ok) return NULL; |
||||||
|
return sub; |
||||||
|
} |
||||||
|
UPB_INLINE void envoy_api_v2_endpoint_ClusterStats_set_total_dropped_requests(envoy_api_v2_endpoint_ClusterStats *msg, uint64_t value) { |
||||||
|
UPB_FIELD_AT(msg, uint64_t, UPB_SIZE(0, 0)) = value; |
||||||
|
} |
||||||
|
UPB_INLINE void envoy_api_v2_endpoint_ClusterStats_set_load_report_interval(envoy_api_v2_endpoint_ClusterStats *msg, struct google_protobuf_Duration* value) { |
||||||
|
UPB_FIELD_AT(msg, struct google_protobuf_Duration*, UPB_SIZE(16, 24)) = value; |
||||||
|
} |
||||||
|
UPB_INLINE struct google_protobuf_Duration* envoy_api_v2_endpoint_ClusterStats_mutable_load_report_interval(envoy_api_v2_endpoint_ClusterStats *msg, upb_arena *arena) { |
||||||
|
struct google_protobuf_Duration* sub = (struct google_protobuf_Duration*)envoy_api_v2_endpoint_ClusterStats_load_report_interval(msg); |
||||||
|
if (sub == NULL) { |
||||||
|
sub = (struct google_protobuf_Duration*)upb_msg_new(&google_protobuf_Duration_msginit, arena); |
||||||
|
if (!sub) return NULL; |
||||||
|
envoy_api_v2_endpoint_ClusterStats_set_load_report_interval(msg, sub); |
||||||
|
} |
||||||
|
return sub; |
||||||
|
} |
||||||
|
UPB_INLINE envoy_api_v2_endpoint_ClusterStats_DroppedRequests** envoy_api_v2_endpoint_ClusterStats_mutable_dropped_requests(envoy_api_v2_endpoint_ClusterStats *msg, size_t *len) { |
||||||
|
return (envoy_api_v2_endpoint_ClusterStats_DroppedRequests**)_upb_array_mutable_accessor(msg, UPB_SIZE(24, 40), len); |
||||||
|
} |
||||||
|
UPB_INLINE envoy_api_v2_endpoint_ClusterStats_DroppedRequests** envoy_api_v2_endpoint_ClusterStats_resize_dropped_requests(envoy_api_v2_endpoint_ClusterStats *msg, size_t len, upb_arena *arena) { |
||||||
|
return (envoy_api_v2_endpoint_ClusterStats_DroppedRequests**)_upb_array_resize_accessor(msg, UPB_SIZE(24, 40), len, UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, arena); |
||||||
|
} |
||||||
|
UPB_INLINE struct envoy_api_v2_endpoint_ClusterStats_DroppedRequests* envoy_api_v2_endpoint_ClusterStats_add_dropped_requests(envoy_api_v2_endpoint_ClusterStats *msg, upb_arena *arena) { |
||||||
|
struct envoy_api_v2_endpoint_ClusterStats_DroppedRequests* sub = (struct envoy_api_v2_endpoint_ClusterStats_DroppedRequests*)upb_msg_new(&envoy_api_v2_endpoint_ClusterStats_DroppedRequests_msginit, arena); |
||||||
|
bool ok = _upb_array_append_accessor( |
||||||
|
msg, UPB_SIZE(24, 40), UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, &sub, arena); |
||||||
|
if (!ok) return NULL; |
||||||
|
return sub; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
/* envoy.api.v2.endpoint.ClusterStats.DroppedRequests */ |
||||||
|
|
||||||
|
UPB_INLINE envoy_api_v2_endpoint_ClusterStats_DroppedRequests *envoy_api_v2_endpoint_ClusterStats_DroppedRequests_new(upb_arena *arena) { |
||||||
|
return (envoy_api_v2_endpoint_ClusterStats_DroppedRequests *)upb_msg_new(&envoy_api_v2_endpoint_ClusterStats_DroppedRequests_msginit, arena); |
||||||
|
} |
||||||
|
UPB_INLINE envoy_api_v2_endpoint_ClusterStats_DroppedRequests *envoy_api_v2_endpoint_ClusterStats_DroppedRequests_parsenew(upb_strview buf, upb_arena *arena) { |
||||||
|
envoy_api_v2_endpoint_ClusterStats_DroppedRequests *ret = envoy_api_v2_endpoint_ClusterStats_DroppedRequests_new(arena); |
||||||
|
return (ret && upb_decode(buf, ret, &envoy_api_v2_endpoint_ClusterStats_DroppedRequests_msginit)) ? ret : NULL; |
||||||
|
} |
||||||
|
UPB_INLINE char *envoy_api_v2_endpoint_ClusterStats_DroppedRequests_serialize(const envoy_api_v2_endpoint_ClusterStats_DroppedRequests *msg, upb_arena *arena, size_t *len) { |
||||||
|
return upb_encode(msg, &envoy_api_v2_endpoint_ClusterStats_DroppedRequests_msginit, arena, len); |
||||||
|
} |
||||||
|
|
||||||
|
UPB_INLINE upb_strview envoy_api_v2_endpoint_ClusterStats_DroppedRequests_category(const envoy_api_v2_endpoint_ClusterStats_DroppedRequests *msg) { return UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(8, 8)); } |
||||||
|
UPB_INLINE uint64_t envoy_api_v2_endpoint_ClusterStats_DroppedRequests_dropped_count(const envoy_api_v2_endpoint_ClusterStats_DroppedRequests *msg) { return UPB_FIELD_AT(msg, uint64_t, UPB_SIZE(0, 0)); } |
||||||
|
|
||||||
|
UPB_INLINE void envoy_api_v2_endpoint_ClusterStats_DroppedRequests_set_category(envoy_api_v2_endpoint_ClusterStats_DroppedRequests *msg, upb_strview value) { |
||||||
|
UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(8, 8)) = value; |
||||||
|
} |
||||||
|
UPB_INLINE void envoy_api_v2_endpoint_ClusterStats_DroppedRequests_set_dropped_count(envoy_api_v2_endpoint_ClusterStats_DroppedRequests *msg, uint64_t value) { |
||||||
|
UPB_FIELD_AT(msg, uint64_t, UPB_SIZE(0, 0)) = value; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
#ifdef __cplusplus |
||||||
|
} /* extern "C" */ |
||||||
|
#endif |
||||||
|
|
||||||
|
#include "upb/port_undef.inc" |
||||||
|
|
||||||
|
#endif /* ENVOY_API_V2_ENDPOINT_LOAD_REPORT_PROTO_UPB_H_ */ |
@ -0,0 +1,52 @@ |
|||||||
|
/* This file was generated by upbc (the upb compiler) from the input
|
||||||
|
* file: |
||||||
|
* |
||||||
|
* envoy/service/load_stats/v2/lrs.proto |
||||||
|
* |
||||||
|
* Do not edit -- your changes will be discarded when the file is |
||||||
|
* regenerated. */ |
||||||
|
|
||||||
|
#include <stddef.h> |
||||||
|
#include "upb/msg.h" |
||||||
|
#include "envoy/service/load_stats/v2/lrs.upb.h" |
||||||
|
#include "envoy/api/v2/core/base.upb.h" |
||||||
|
#include "envoy/api/v2/endpoint/load_report.upb.h" |
||||||
|
#include "google/protobuf/duration.upb.h" |
||||||
|
#include "validate/validate.upb.h" |
||||||
|
|
||||||
|
#include "upb/port_def.inc" |
||||||
|
|
||||||
|
static const upb_msglayout *const envoy_service_load_stats_v2_LoadStatsRequest_submsgs[2] = { |
||||||
|
&envoy_api_v2_core_Node_msginit, |
||||||
|
&envoy_api_v2_endpoint_ClusterStats_msginit, |
||||||
|
}; |
||||||
|
|
||||||
|
static const upb_msglayout_field envoy_service_load_stats_v2_LoadStatsRequest__fields[2] = { |
||||||
|
{1, UPB_SIZE(0, 0), 0, 0, 11, 1}, |
||||||
|
{2, UPB_SIZE(4, 8), 0, 1, 11, 3}, |
||||||
|
}; |
||||||
|
|
||||||
|
const upb_msglayout envoy_service_load_stats_v2_LoadStatsRequest_msginit = { |
||||||
|
&envoy_service_load_stats_v2_LoadStatsRequest_submsgs[0], |
||||||
|
&envoy_service_load_stats_v2_LoadStatsRequest__fields[0], |
||||||
|
UPB_SIZE(8, 16), 2, false, |
||||||
|
}; |
||||||
|
|
||||||
|
static const upb_msglayout *const envoy_service_load_stats_v2_LoadStatsResponse_submsgs[1] = { |
||||||
|
&google_protobuf_Duration_msginit, |
||||||
|
}; |
||||||
|
|
||||||
|
static const upb_msglayout_field envoy_service_load_stats_v2_LoadStatsResponse__fields[3] = { |
||||||
|
{1, UPB_SIZE(8, 16), 0, 0, 9, 3}, |
||||||
|
{2, UPB_SIZE(4, 8), 0, 0, 11, 1}, |
||||||
|
{3, UPB_SIZE(0, 0), 0, 0, 8, 1}, |
||||||
|
}; |
||||||
|
|
||||||
|
const upb_msglayout envoy_service_load_stats_v2_LoadStatsResponse_msginit = { |
||||||
|
&envoy_service_load_stats_v2_LoadStatsResponse_submsgs[0], |
||||||
|
&envoy_service_load_stats_v2_LoadStatsResponse__fields[0], |
||||||
|
UPB_SIZE(12, 24), 3, false, |
||||||
|
}; |
||||||
|
|
||||||
|
#include "upb/port_undef.inc" |
||||||
|
|
@ -0,0 +1,132 @@ |
|||||||
|
/* This file was generated by upbc (the upb compiler) from the input
|
||||||
|
* file: |
||||||
|
* |
||||||
|
* envoy/service/load_stats/v2/lrs.proto |
||||||
|
* |
||||||
|
* Do not edit -- your changes will be discarded when the file is |
||||||
|
* regenerated. */ |
||||||
|
|
||||||
|
#ifndef ENVOY_SERVICE_LOAD_STATS_V2_LRS_PROTO_UPB_H_ |
||||||
|
#define ENVOY_SERVICE_LOAD_STATS_V2_LRS_PROTO_UPB_H_ |
||||||
|
|
||||||
|
#include "upb/generated_util.h" |
||||||
|
|
||||||
|
#include "upb/msg.h" |
||||||
|
|
||||||
|
#include "upb/decode.h" |
||||||
|
#include "upb/encode.h" |
||||||
|
#include "upb/port_def.inc" |
||||||
|
#ifdef __cplusplus |
||||||
|
extern "C" { |
||||||
|
#endif |
||||||
|
|
||||||
|
struct envoy_service_load_stats_v2_LoadStatsRequest; |
||||||
|
struct envoy_service_load_stats_v2_LoadStatsResponse; |
||||||
|
typedef struct envoy_service_load_stats_v2_LoadStatsRequest envoy_service_load_stats_v2_LoadStatsRequest; |
||||||
|
typedef struct envoy_service_load_stats_v2_LoadStatsResponse envoy_service_load_stats_v2_LoadStatsResponse; |
||||||
|
extern const upb_msglayout envoy_service_load_stats_v2_LoadStatsRequest_msginit; |
||||||
|
extern const upb_msglayout envoy_service_load_stats_v2_LoadStatsResponse_msginit; |
||||||
|
struct envoy_api_v2_core_Node; |
||||||
|
struct envoy_api_v2_endpoint_ClusterStats; |
||||||
|
struct google_protobuf_Duration; |
||||||
|
extern const upb_msglayout envoy_api_v2_core_Node_msginit; |
||||||
|
extern const upb_msglayout envoy_api_v2_endpoint_ClusterStats_msginit; |
||||||
|
extern const upb_msglayout google_protobuf_Duration_msginit; |
||||||
|
|
||||||
|
/* Enums */ |
||||||
|
|
||||||
|
|
||||||
|
/* envoy.service.load_stats.v2.LoadStatsRequest */ |
||||||
|
|
||||||
|
UPB_INLINE envoy_service_load_stats_v2_LoadStatsRequest *envoy_service_load_stats_v2_LoadStatsRequest_new(upb_arena *arena) { |
||||||
|
return (envoy_service_load_stats_v2_LoadStatsRequest *)upb_msg_new(&envoy_service_load_stats_v2_LoadStatsRequest_msginit, arena); |
||||||
|
} |
||||||
|
UPB_INLINE envoy_service_load_stats_v2_LoadStatsRequest *envoy_service_load_stats_v2_LoadStatsRequest_parsenew(upb_strview buf, upb_arena *arena) { |
||||||
|
envoy_service_load_stats_v2_LoadStatsRequest *ret = envoy_service_load_stats_v2_LoadStatsRequest_new(arena); |
||||||
|
return (ret && upb_decode(buf, ret, &envoy_service_load_stats_v2_LoadStatsRequest_msginit)) ? ret : NULL; |
||||||
|
} |
||||||
|
UPB_INLINE char *envoy_service_load_stats_v2_LoadStatsRequest_serialize(const envoy_service_load_stats_v2_LoadStatsRequest *msg, upb_arena *arena, size_t *len) { |
||||||
|
return upb_encode(msg, &envoy_service_load_stats_v2_LoadStatsRequest_msginit, arena, len); |
||||||
|
} |
||||||
|
|
||||||
|
UPB_INLINE const struct envoy_api_v2_core_Node* envoy_service_load_stats_v2_LoadStatsRequest_node(const envoy_service_load_stats_v2_LoadStatsRequest *msg) { return UPB_FIELD_AT(msg, const struct envoy_api_v2_core_Node*, UPB_SIZE(0, 0)); } |
||||||
|
UPB_INLINE const struct envoy_api_v2_endpoint_ClusterStats* const* envoy_service_load_stats_v2_LoadStatsRequest_cluster_stats(const envoy_service_load_stats_v2_LoadStatsRequest *msg, size_t *len) { return (const struct envoy_api_v2_endpoint_ClusterStats* const*)_upb_array_accessor(msg, UPB_SIZE(4, 8), len); } |
||||||
|
|
||||||
|
UPB_INLINE void envoy_service_load_stats_v2_LoadStatsRequest_set_node(envoy_service_load_stats_v2_LoadStatsRequest *msg, struct envoy_api_v2_core_Node* value) { |
||||||
|
UPB_FIELD_AT(msg, struct envoy_api_v2_core_Node*, UPB_SIZE(0, 0)) = value; |
||||||
|
} |
||||||
|
UPB_INLINE struct envoy_api_v2_core_Node* envoy_service_load_stats_v2_LoadStatsRequest_mutable_node(envoy_service_load_stats_v2_LoadStatsRequest *msg, upb_arena *arena) { |
||||||
|
struct envoy_api_v2_core_Node* sub = (struct envoy_api_v2_core_Node*)envoy_service_load_stats_v2_LoadStatsRequest_node(msg); |
||||||
|
if (sub == NULL) { |
||||||
|
sub = (struct envoy_api_v2_core_Node*)upb_msg_new(&envoy_api_v2_core_Node_msginit, arena); |
||||||
|
if (!sub) return NULL; |
||||||
|
envoy_service_load_stats_v2_LoadStatsRequest_set_node(msg, sub); |
||||||
|
} |
||||||
|
return sub; |
||||||
|
} |
||||||
|
UPB_INLINE struct envoy_api_v2_endpoint_ClusterStats** envoy_service_load_stats_v2_LoadStatsRequest_mutable_cluster_stats(envoy_service_load_stats_v2_LoadStatsRequest *msg, size_t *len) { |
||||||
|
return (struct envoy_api_v2_endpoint_ClusterStats**)_upb_array_mutable_accessor(msg, UPB_SIZE(4, 8), len); |
||||||
|
} |
||||||
|
UPB_INLINE struct envoy_api_v2_endpoint_ClusterStats** envoy_service_load_stats_v2_LoadStatsRequest_resize_cluster_stats(envoy_service_load_stats_v2_LoadStatsRequest *msg, size_t len, upb_arena *arena) { |
||||||
|
return (struct envoy_api_v2_endpoint_ClusterStats**)_upb_array_resize_accessor(msg, UPB_SIZE(4, 8), len, UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, arena); |
||||||
|
} |
||||||
|
UPB_INLINE struct envoy_api_v2_endpoint_ClusterStats* envoy_service_load_stats_v2_LoadStatsRequest_add_cluster_stats(envoy_service_load_stats_v2_LoadStatsRequest *msg, upb_arena *arena) { |
||||||
|
struct envoy_api_v2_endpoint_ClusterStats* sub = (struct envoy_api_v2_endpoint_ClusterStats*)upb_msg_new(&envoy_api_v2_endpoint_ClusterStats_msginit, arena); |
||||||
|
bool ok = _upb_array_append_accessor( |
||||||
|
msg, UPB_SIZE(4, 8), UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, &sub, arena); |
||||||
|
if (!ok) return NULL; |
||||||
|
return sub; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
/* envoy.service.load_stats.v2.LoadStatsResponse */ |
||||||
|
|
||||||
|
UPB_INLINE envoy_service_load_stats_v2_LoadStatsResponse *envoy_service_load_stats_v2_LoadStatsResponse_new(upb_arena *arena) { |
||||||
|
return (envoy_service_load_stats_v2_LoadStatsResponse *)upb_msg_new(&envoy_service_load_stats_v2_LoadStatsResponse_msginit, arena); |
||||||
|
} |
||||||
|
UPB_INLINE envoy_service_load_stats_v2_LoadStatsResponse *envoy_service_load_stats_v2_LoadStatsResponse_parsenew(upb_strview buf, upb_arena *arena) { |
||||||
|
envoy_service_load_stats_v2_LoadStatsResponse *ret = envoy_service_load_stats_v2_LoadStatsResponse_new(arena); |
||||||
|
return (ret && upb_decode(buf, ret, &envoy_service_load_stats_v2_LoadStatsResponse_msginit)) ? ret : NULL; |
||||||
|
} |
||||||
|
UPB_INLINE char *envoy_service_load_stats_v2_LoadStatsResponse_serialize(const envoy_service_load_stats_v2_LoadStatsResponse *msg, upb_arena *arena, size_t *len) { |
||||||
|
return upb_encode(msg, &envoy_service_load_stats_v2_LoadStatsResponse_msginit, arena, len); |
||||||
|
} |
||||||
|
|
||||||
|
UPB_INLINE upb_strview const* envoy_service_load_stats_v2_LoadStatsResponse_clusters(const envoy_service_load_stats_v2_LoadStatsResponse *msg, size_t *len) { return (upb_strview const*)_upb_array_accessor(msg, UPB_SIZE(8, 16), len); } |
||||||
|
UPB_INLINE const struct google_protobuf_Duration* envoy_service_load_stats_v2_LoadStatsResponse_load_reporting_interval(const envoy_service_load_stats_v2_LoadStatsResponse *msg) { return UPB_FIELD_AT(msg, const struct google_protobuf_Duration*, UPB_SIZE(4, 8)); } |
||||||
|
UPB_INLINE bool envoy_service_load_stats_v2_LoadStatsResponse_report_endpoint_granularity(const envoy_service_load_stats_v2_LoadStatsResponse *msg) { return UPB_FIELD_AT(msg, bool, UPB_SIZE(0, 0)); } |
||||||
|
|
||||||
|
UPB_INLINE upb_strview* envoy_service_load_stats_v2_LoadStatsResponse_mutable_clusters(envoy_service_load_stats_v2_LoadStatsResponse *msg, size_t *len) { |
||||||
|
return (upb_strview*)_upb_array_mutable_accessor(msg, UPB_SIZE(8, 16), len); |
||||||
|
} |
||||||
|
UPB_INLINE upb_strview* envoy_service_load_stats_v2_LoadStatsResponse_resize_clusters(envoy_service_load_stats_v2_LoadStatsResponse *msg, size_t len, upb_arena *arena) { |
||||||
|
return (upb_strview*)_upb_array_resize_accessor(msg, UPB_SIZE(8, 16), len, UPB_SIZE(8, 16), UPB_TYPE_STRING, arena); |
||||||
|
} |
||||||
|
UPB_INLINE bool envoy_service_load_stats_v2_LoadStatsResponse_add_clusters(envoy_service_load_stats_v2_LoadStatsResponse *msg, upb_strview val, upb_arena *arena) { |
||||||
|
return _upb_array_append_accessor( |
||||||
|
msg, UPB_SIZE(8, 16), UPB_SIZE(8, 16), UPB_TYPE_STRING, &val, arena); |
||||||
|
} |
||||||
|
UPB_INLINE void envoy_service_load_stats_v2_LoadStatsResponse_set_load_reporting_interval(envoy_service_load_stats_v2_LoadStatsResponse *msg, struct google_protobuf_Duration* value) { |
||||||
|
UPB_FIELD_AT(msg, struct google_protobuf_Duration*, UPB_SIZE(4, 8)) = value; |
||||||
|
} |
||||||
|
UPB_INLINE struct google_protobuf_Duration* envoy_service_load_stats_v2_LoadStatsResponse_mutable_load_reporting_interval(envoy_service_load_stats_v2_LoadStatsResponse *msg, upb_arena *arena) { |
||||||
|
struct google_protobuf_Duration* sub = (struct google_protobuf_Duration*)envoy_service_load_stats_v2_LoadStatsResponse_load_reporting_interval(msg); |
||||||
|
if (sub == NULL) { |
||||||
|
sub = (struct google_protobuf_Duration*)upb_msg_new(&google_protobuf_Duration_msginit, arena); |
||||||
|
if (!sub) return NULL; |
||||||
|
envoy_service_load_stats_v2_LoadStatsResponse_set_load_reporting_interval(msg, sub); |
||||||
|
} |
||||||
|
return sub; |
||||||
|
} |
||||||
|
UPB_INLINE void envoy_service_load_stats_v2_LoadStatsResponse_set_report_endpoint_granularity(envoy_service_load_stats_v2_LoadStatsResponse *msg, bool value) { |
||||||
|
UPB_FIELD_AT(msg, bool, UPB_SIZE(0, 0)) = value; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
#ifdef __cplusplus |
||||||
|
} /* extern "C" */ |
||||||
|
#endif |
||||||
|
|
||||||
|
#include "upb/port_undef.inc" |
||||||
|
|
||||||
|
#endif /* ENVOY_SERVICE_LOAD_STATS_V2_LRS_PROTO_UPB_H_ */ |
@ -1,42 +0,0 @@ |
|||||||
/*
|
|
||||||
* |
|
||||||
* Copyright 2018 gRPC authors. |
|
||||||
* |
|
||||||
* Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
|
|
||||||
* |
|
||||||
* Unless required by applicable law or agreed to in writing, software |
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS, |
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
||||||
* See the License for the specific language governing permissions and |
|
||||||
* limitations under the License. |
|
||||||
* |
|
||||||
*/ |
|
||||||
|
|
||||||
#ifndef GRPC_CORE_LIB_GPRPP_MUTEX_LOCK_H |
|
||||||
#define GRPC_CORE_LIB_GPRPP_MUTEX_LOCK_H |
|
||||||
|
|
||||||
#include <grpc/support/port_platform.h> |
|
||||||
|
|
||||||
#include <grpc/support/sync.h> |
|
||||||
|
|
||||||
namespace grpc_core { |
|
||||||
|
|
||||||
class MutexLock { |
|
||||||
public: |
|
||||||
explicit MutexLock(gpr_mu* mu) : mu_(mu) { gpr_mu_lock(mu); } |
|
||||||
~MutexLock() { gpr_mu_unlock(mu_); } |
|
||||||
|
|
||||||
MutexLock(const MutexLock&) = delete; |
|
||||||
MutexLock& operator=(const MutexLock&) = delete; |
|
||||||
|
|
||||||
private: |
|
||||||
gpr_mu* const mu_; |
|
||||||
}; |
|
||||||
|
|
||||||
} // namespace grpc_core
|
|
||||||
|
|
||||||
#endif /* GRPC_CORE_LIB_GPRPP_MUTEX_LOCK_H */ |
|
@ -0,0 +1,126 @@ |
|||||||
|
/*
|
||||||
|
* |
||||||
|
* Copyright 2019 gRPC authors. |
||||||
|
* |
||||||
|
* Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
|
||||||
|
* |
||||||
|
* Unless required by applicable law or agreed to in writing, software |
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, |
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||||
|
* See the License for the specific language governing permissions and |
||||||
|
* limitations under the License. |
||||||
|
* |
||||||
|
*/ |
||||||
|
|
||||||
|
#ifndef GRPC_CORE_LIB_GPRPP_SYNC_H |
||||||
|
#define GRPC_CORE_LIB_GPRPP_SYNC_H |
||||||
|
|
||||||
|
#include <grpc/impl/codegen/port_platform.h> |
||||||
|
|
||||||
|
#include <grpc/impl/codegen/log.h> |
||||||
|
#include <grpc/impl/codegen/sync.h> |
||||||
|
#include <grpc/support/sync.h> |
||||||
|
#include <grpc/support/time.h> |
||||||
|
|
||||||
|
// The core library is not accessible in C++ codegen headers, and vice versa.
|
||||||
|
// Thus, we need to have duplicate headers with similar functionality.
|
||||||
|
// Make sure any change to this file is also reflected in
|
||||||
|
// include/grpcpp/impl/codegen/sync.h.
|
||||||
|
//
|
||||||
|
// Whenever possible, prefer using this file over <grpcpp/impl/codegen/sync.h>
|
||||||
|
// since this file doesn't rely on g_core_codegen_interface and hence does not
|
||||||
|
// pay the costs of virtual function calls.
|
||||||
|
|
||||||
|
namespace grpc_core { |
||||||
|
|
||||||
|
class Mutex { |
||||||
|
public: |
||||||
|
Mutex() { gpr_mu_init(&mu_); } |
||||||
|
~Mutex() { gpr_mu_destroy(&mu_); } |
||||||
|
|
||||||
|
Mutex(const Mutex&) = delete; |
||||||
|
Mutex& operator=(const Mutex&) = delete; |
||||||
|
|
||||||
|
gpr_mu* get() { return &mu_; } |
||||||
|
const gpr_mu* get() const { return &mu_; } |
||||||
|
|
||||||
|
private: |
||||||
|
gpr_mu mu_; |
||||||
|
}; |
||||||
|
|
||||||
|
// MutexLock is a std::
|
||||||
|
class MutexLock { |
||||||
|
public: |
||||||
|
explicit MutexLock(Mutex* mu) : mu_(mu->get()) { gpr_mu_lock(mu_); } |
||||||
|
explicit MutexLock(gpr_mu* mu) : mu_(mu) { gpr_mu_lock(mu_); } |
||||||
|
~MutexLock() { gpr_mu_unlock(mu_); } |
||||||
|
|
||||||
|
MutexLock(const MutexLock&) = delete; |
||||||
|
MutexLock& operator=(const MutexLock&) = delete; |
||||||
|
|
||||||
|
private: |
||||||
|
gpr_mu* const mu_; |
||||||
|
}; |
||||||
|
|
||||||
|
class ReleasableMutexLock { |
||||||
|
public: |
||||||
|
explicit ReleasableMutexLock(Mutex* mu) : mu_(mu->get()) { gpr_mu_lock(mu_); } |
||||||
|
explicit ReleasableMutexLock(gpr_mu* mu) : mu_(mu) { gpr_mu_lock(mu_); } |
||||||
|
~ReleasableMutexLock() { |
||||||
|
if (!released_) gpr_mu_unlock(mu_); |
||||||
|
} |
||||||
|
|
||||||
|
ReleasableMutexLock(const ReleasableMutexLock&) = delete; |
||||||
|
ReleasableMutexLock& operator=(const ReleasableMutexLock&) = delete; |
||||||
|
|
||||||
|
void Lock() { |
||||||
|
GPR_DEBUG_ASSERT(released_); |
||||||
|
gpr_mu_lock(mu_); |
||||||
|
released_ = false; |
||||||
|
} |
||||||
|
|
||||||
|
void Unlock() { |
||||||
|
GPR_DEBUG_ASSERT(!released_); |
||||||
|
released_ = true; |
||||||
|
gpr_mu_unlock(mu_); |
||||||
|
} |
||||||
|
|
||||||
|
private: |
||||||
|
gpr_mu* const mu_; |
||||||
|
bool released_ = false; |
||||||
|
}; |
||||||
|
|
||||||
|
class CondVar { |
||||||
|
public: |
||||||
|
CondVar() { gpr_cv_init(&cv_); } |
||||||
|
~CondVar() { gpr_cv_destroy(&cv_); } |
||||||
|
|
||||||
|
CondVar(const CondVar&) = delete; |
||||||
|
CondVar& operator=(const CondVar&) = delete; |
||||||
|
|
||||||
|
void Signal() { gpr_cv_signal(&cv_); } |
||||||
|
void Broadcast() { gpr_cv_broadcast(&cv_); } |
||||||
|
|
||||||
|
int Wait(Mutex* mu) { return Wait(mu, gpr_inf_future(GPR_CLOCK_REALTIME)); } |
||||||
|
int Wait(Mutex* mu, const gpr_timespec& deadline) { |
||||||
|
return gpr_cv_wait(&cv_, mu->get(), deadline); |
||||||
|
} |
||||||
|
|
||||||
|
template <typename Predicate> |
||||||
|
void WaitUntil(Mutex* mu, Predicate pred) { |
||||||
|
while (!pred()) { |
||||||
|
Wait(mu, gpr_inf_future(GPR_CLOCK_REALTIME)); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
private: |
||||||
|
gpr_cv cv_; |
||||||
|
}; |
||||||
|
|
||||||
|
} // namespace grpc_core
|
||||||
|
|
||||||
|
#endif /* GRPC_CORE_LIB_GPRPP_SYNC_H */ |
@ -0,0 +1,53 @@ |
|||||||
|
#region Copyright notice and license |
||||||
|
// Copyright 2019 The gRPC Authors |
||||||
|
// |
||||||
|
// Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 |
||||||
|
// |
||||||
|
// Unless required by applicable law or agreed to in writing, software |
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS, |
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||||
|
// See the License for the specific language governing permissions and |
||||||
|
// limitations under the License. |
||||||
|
#endregion |
||||||
|
|
||||||
|
using System; |
||||||
|
|
||||||
|
namespace Grpc.Core |
||||||
|
{ |
||||||
|
/// <summary> |
||||||
|
/// Specifies the location of the service bind method for a gRPC service. |
||||||
|
/// The bind method is typically generated code and is used to register a service's |
||||||
|
/// methods with the server on startup. |
||||||
|
/// |
||||||
|
/// The bind method signature takes a <see cref="ServiceBinderBase"/> and an optional |
||||||
|
/// instance of the service base class, e.g. <c>static void BindService(ServiceBinderBase, GreeterService)</c>. |
||||||
|
/// </summary> |
||||||
|
[AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = true)] |
||||||
|
public class BindServiceMethodAttribute : Attribute |
||||||
|
{ |
||||||
|
/// <summary> |
||||||
|
/// Initializes a new instance of the <see cref="BindServiceMethodAttribute"/> class. |
||||||
|
/// </summary> |
||||||
|
/// <param name="bindType">The type the service bind method is defined on.</param> |
||||||
|
/// <param name="bindMethodName">The name of the service bind method.</param> |
||||||
|
public BindServiceMethodAttribute(Type bindType, string bindMethodName) |
||||||
|
{ |
||||||
|
BindType = bindType; |
||||||
|
BindMethodName = bindMethodName; |
||||||
|
} |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// Gets the type the service bind method is defined on. |
||||||
|
/// </summary> |
||||||
|
public Type BindType { get; } |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// Gets the name of the service bind method. |
||||||
|
/// </summary> |
||||||
|
public string BindMethodName { get; } |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,90 @@ |
|||||||
|
#region Copyright notice and license |
||||||
|
|
||||||
|
// Copyright 2015 gRPC authors. |
||||||
|
// |
||||||
|
// Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 |
||||||
|
// |
||||||
|
// Unless required by applicable law or agreed to in writing, software |
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS, |
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||||
|
// See the License for the specific language governing permissions and |
||||||
|
// limitations under the License. |
||||||
|
|
||||||
|
#endregion |
||||||
|
|
||||||
|
using System.Collections.Generic; |
||||||
|
using System.Collections.ObjectModel; |
||||||
|
|
||||||
|
using Grpc.Core.Internal; |
||||||
|
using Grpc.Core.Utils; |
||||||
|
|
||||||
|
namespace Grpc.Core |
||||||
|
{ |
||||||
|
/// <summary> |
||||||
|
/// Client-side call credentials. Provide authorization with per-call granularity. |
||||||
|
/// </summary> |
||||||
|
public abstract class CallCredentials |
||||||
|
{ |
||||||
|
/// <summary> |
||||||
|
/// Composes multiple multiple <c>CallCredentials</c> objects into |
||||||
|
/// a single <c>CallCredentials</c> object. |
||||||
|
/// </summary> |
||||||
|
/// <param name="credentials">credentials to compose</param> |
||||||
|
/// <returns>The new <c>CompositeCallCredentials</c></returns> |
||||||
|
public static CallCredentials Compose(params CallCredentials[] credentials) |
||||||
|
{ |
||||||
|
return new CompositeCallCredentials(credentials); |
||||||
|
} |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// Creates a new instance of <c>CallCredentials</c> class from an |
||||||
|
/// interceptor that can attach metadata to outgoing calls. |
||||||
|
/// </summary> |
||||||
|
/// <param name="interceptor">authentication interceptor</param> |
||||||
|
public static CallCredentials FromInterceptor(AsyncAuthInterceptor interceptor) |
||||||
|
{ |
||||||
|
return new AsyncAuthInterceptorCredentials(interceptor); |
||||||
|
} |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// Populates this call credential instances. |
||||||
|
/// You never need to invoke this, part of internal implementation. |
||||||
|
/// </summary> |
||||||
|
public abstract void InternalPopulateConfiguration(CallCredentialsConfiguratorBase configurator, object state); |
||||||
|
|
||||||
|
private class CompositeCallCredentials : CallCredentials |
||||||
|
{ |
||||||
|
readonly IReadOnlyList<CallCredentials> credentials; |
||||||
|
|
||||||
|
public CompositeCallCredentials(CallCredentials[] credentials) |
||||||
|
{ |
||||||
|
GrpcPreconditions.CheckArgument(credentials.Length >= 2, "Composite credentials object can only be created from 2 or more credentials."); |
||||||
|
this.credentials = new List<CallCredentials>(credentials).AsReadOnly(); |
||||||
|
} |
||||||
|
|
||||||
|
public override void InternalPopulateConfiguration(CallCredentialsConfiguratorBase configurator, object state) |
||||||
|
{ |
||||||
|
configurator.SetCompositeCredentials(state, credentials); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
private class AsyncAuthInterceptorCredentials : CallCredentials |
||||||
|
{ |
||||||
|
readonly AsyncAuthInterceptor interceptor; |
||||||
|
|
||||||
|
public AsyncAuthInterceptorCredentials(AsyncAuthInterceptor interceptor) |
||||||
|
{ |
||||||
|
this.interceptor = GrpcPreconditions.CheckNotNull(interceptor); |
||||||
|
} |
||||||
|
|
||||||
|
public override void InternalPopulateConfiguration(CallCredentialsConfiguratorBase configurator, object state) |
||||||
|
{ |
||||||
|
configurator.SetAsyncAuthInterceptorCredentials(state, interceptor); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,39 @@ |
|||||||
|
#region Copyright notice and license |
||||||
|
|
||||||
|
// Copyright 2019 The gRPC Authors |
||||||
|
// |
||||||
|
// Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 |
||||||
|
// |
||||||
|
// Unless required by applicable law or agreed to in writing, software |
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS, |
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||||
|
// See the License for the specific language governing permissions and |
||||||
|
// limitations under the License. |
||||||
|
|
||||||
|
#endregion |
||||||
|
|
||||||
|
using System.Collections.Generic; |
||||||
|
|
||||||
|
namespace Grpc.Core |
||||||
|
{ |
||||||
|
/// <summary> |
||||||
|
/// Base class for objects that can consume configuration from <c>CallCredentials</c> objects. |
||||||
|
/// Note: experimental API that can change or be removed without any prior notice. |
||||||
|
/// </summary> |
||||||
|
public abstract class CallCredentialsConfiguratorBase |
||||||
|
{ |
||||||
|
/// <summary> |
||||||
|
/// Consumes configuration for composite call credentials. |
||||||
|
/// </summary> |
||||||
|
public abstract void SetCompositeCredentials(object state, IReadOnlyList<CallCredentials> credentials); |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// Consumes configuration for call credentials created from <c>AsyncAuthInterceptor</c> |
||||||
|
/// </summary> |
||||||
|
public abstract void SetAsyncAuthInterceptorCredentials(object state, AsyncAuthInterceptor interceptor); |
||||||
|
} |
||||||
|
} |
@ -1,129 +0,0 @@ |
|||||||
#region Copyright notice and license |
|
||||||
|
|
||||||
// Copyright 2015 gRPC authors. |
|
||||||
// |
|
||||||
// Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 |
|
||||||
// |
|
||||||
// Unless required by applicable law or agreed to in writing, software |
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS, |
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
||||||
// See the License for the specific language governing permissions and |
|
||||||
// limitations under the License. |
|
||||||
|
|
||||||
#endregion |
|
||||||
|
|
||||||
using System; |
|
||||||
using System.Collections.Generic; |
|
||||||
using System.Threading.Tasks; |
|
||||||
|
|
||||||
using Grpc.Core.Internal; |
|
||||||
using Grpc.Core.Utils; |
|
||||||
|
|
||||||
namespace Grpc.Core |
|
||||||
{ |
|
||||||
/// <summary> |
|
||||||
/// Client-side call credentials. Provide authorization with per-call granularity. |
|
||||||
/// </summary> |
|
||||||
public abstract class CallCredentials |
|
||||||
{ |
|
||||||
/// <summary> |
|
||||||
/// Composes multiple multiple <c>CallCredentials</c> objects into |
|
||||||
/// a single <c>CallCredentials</c> object. |
|
||||||
/// </summary> |
|
||||||
/// <param name="credentials">credentials to compose</param> |
|
||||||
/// <returns>The new <c>CompositeCallCredentials</c></returns> |
|
||||||
public static CallCredentials Compose(params CallCredentials[] credentials) |
|
||||||
{ |
|
||||||
return new CompositeCallCredentials(credentials); |
|
||||||
} |
|
||||||
|
|
||||||
/// <summary> |
|
||||||
/// Creates a new instance of <c>CallCredentials</c> class from an |
|
||||||
/// interceptor that can attach metadata to outgoing calls. |
|
||||||
/// </summary> |
|
||||||
/// <param name="interceptor">authentication interceptor</param> |
|
||||||
public static CallCredentials FromInterceptor(AsyncAuthInterceptor interceptor) |
|
||||||
{ |
|
||||||
return new MetadataCredentials(interceptor); |
|
||||||
} |
|
||||||
|
|
||||||
/// <summary> |
|
||||||
/// Creates native object for the credentials. |
|
||||||
/// </summary> |
|
||||||
/// <returns>The native credentials.</returns> |
|
||||||
internal abstract CallCredentialsSafeHandle ToNativeCredentials(); |
|
||||||
} |
|
||||||
|
|
||||||
/// <summary> |
|
||||||
/// Client-side credentials that delegate metadata based auth to an interceptor. |
|
||||||
/// The interceptor is automatically invoked for each remote call that uses <c>MetadataCredentials.</c> |
|
||||||
/// </summary> |
|
||||||
internal sealed class MetadataCredentials : CallCredentials |
|
||||||
{ |
|
||||||
readonly AsyncAuthInterceptor interceptor; |
|
||||||
|
|
||||||
/// <summary> |
|
||||||
/// Initializes a new instance of <c>MetadataCredentials</c> class. |
|
||||||
/// </summary> |
|
||||||
/// <param name="interceptor">authentication interceptor</param> |
|
||||||
public MetadataCredentials(AsyncAuthInterceptor interceptor) |
|
||||||
{ |
|
||||||
this.interceptor = GrpcPreconditions.CheckNotNull(interceptor); |
|
||||||
} |
|
||||||
|
|
||||||
internal override CallCredentialsSafeHandle ToNativeCredentials() |
|
||||||
{ |
|
||||||
NativeMetadataCredentialsPlugin plugin = new NativeMetadataCredentialsPlugin(interceptor); |
|
||||||
return plugin.Credentials; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
/// <summary> |
|
||||||
/// Credentials that allow composing multiple credentials objects into one <see cref="CallCredentials"/> object. |
|
||||||
/// </summary> |
|
||||||
internal sealed class CompositeCallCredentials : CallCredentials |
|
||||||
{ |
|
||||||
readonly List<CallCredentials> credentials; |
|
||||||
|
|
||||||
/// <summary> |
|
||||||
/// Initializes a new instance of <c>CompositeCallCredentials</c> class. |
|
||||||
/// The resulting credentials object will be composite of all the credentials specified as parameters. |
|
||||||
/// </summary> |
|
||||||
/// <param name="credentials">credentials to compose</param> |
|
||||||
public CompositeCallCredentials(params CallCredentials[] credentials) |
|
||||||
{ |
|
||||||
GrpcPreconditions.CheckArgument(credentials.Length >= 2, "Composite credentials object can only be created from 2 or more credentials."); |
|
||||||
this.credentials = new List<CallCredentials>(credentials); |
|
||||||
} |
|
||||||
|
|
||||||
internal override CallCredentialsSafeHandle ToNativeCredentials() |
|
||||||
{ |
|
||||||
return ToNativeRecursive(0); |
|
||||||
} |
|
||||||
|
|
||||||
// Recursive descent makes managing lifetime of intermediate CredentialSafeHandle instances easier. |
|
||||||
// In practice, we won't usually see composites from more than two credentials anyway. |
|
||||||
private CallCredentialsSafeHandle ToNativeRecursive(int startIndex) |
|
||||||
{ |
|
||||||
if (startIndex == credentials.Count - 1) |
|
||||||
{ |
|
||||||
return credentials[startIndex].ToNativeCredentials(); |
|
||||||
} |
|
||||||
|
|
||||||
using (var cred1 = credentials[startIndex].ToNativeCredentials()) |
|
||||||
using (var cred2 = ToNativeRecursive(startIndex + 1)) |
|
||||||
{ |
|
||||||
var nativeComposite = CallCredentialsSafeHandle.CreateComposite(cred1, cred2); |
|
||||||
if (nativeComposite.IsInvalid) |
|
||||||
{ |
|
||||||
throw new ArgumentException("Error creating native composite credentials. Likely, this is because you are trying to compose incompatible credentials."); |
|
||||||
} |
|
||||||
return nativeComposite; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
@ -0,0 +1,57 @@ |
|||||||
|
#region Copyright notice and license |
||||||
|
|
||||||
|
// Copyright 2019 The gRPC Authors |
||||||
|
// |
||||||
|
// Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 |
||||||
|
// |
||||||
|
// Unless required by applicable law or agreed to in writing, software |
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS, |
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||||
|
// See the License for the specific language governing permissions and |
||||||
|
// limitations under the License. |
||||||
|
|
||||||
|
#endregion |
||||||
|
|
||||||
|
using System; |
||||||
|
using Grpc.Core.Utils; |
||||||
|
|
||||||
|
namespace Grpc.Core.Internal |
||||||
|
{ |
||||||
|
internal static class CallOptionsExtensions |
||||||
|
{ |
||||||
|
/// <summary> |
||||||
|
/// Returns a new instance of <see cref="CallOptions"/> with |
||||||
|
/// all previously unset values set to their defaults and deadline and cancellation |
||||||
|
/// token propagated when appropriate. |
||||||
|
/// </summary> |
||||||
|
internal static CallOptions Normalize(this CallOptions options) |
||||||
|
{ |
||||||
|
var newOptions = options; |
||||||
|
// silently ignore the context propagation token if it wasn't produced by "us" |
||||||
|
var propagationTokenImpl = options.PropagationToken.AsImplOrNull(); |
||||||
|
if (propagationTokenImpl != null) |
||||||
|
{ |
||||||
|
if (propagationTokenImpl.Options.IsPropagateDeadline) |
||||||
|
{ |
||||||
|
GrpcPreconditions.CheckArgument(!newOptions.Deadline.HasValue, |
||||||
|
"Cannot propagate deadline from parent call. The deadline has already been set explicitly."); |
||||||
|
newOptions = newOptions.WithDeadline(propagationTokenImpl.ParentDeadline); |
||||||
|
} |
||||||
|
if (propagationTokenImpl.Options.IsPropagateCancellation) |
||||||
|
{ |
||||||
|
GrpcPreconditions.CheckArgument(!newOptions.CancellationToken.CanBeCanceled, |
||||||
|
"Cannot propagate cancellation token from parent call. The cancellation token has already been set to a non-default value."); |
||||||
|
newOptions = newOptions.WithCancellationToken(propagationTokenImpl.ParentCancellationToken); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
newOptions = newOptions.WithHeaders(newOptions.Headers ?? Metadata.Empty); |
||||||
|
newOptions = newOptions.WithDeadline(newOptions.Deadline ?? DateTime.MaxValue); |
||||||
|
return newOptions; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,85 @@ |
|||||||
|
#region Copyright notice and license |
||||||
|
|
||||||
|
// Copyright 2019 The gRPC Authors |
||||||
|
// |
||||||
|
// Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 |
||||||
|
// |
||||||
|
// Unless required by applicable law or agreed to in writing, software |
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS, |
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||||
|
// See the License for the specific language governing permissions and |
||||||
|
// limitations under the License. |
||||||
|
|
||||||
|
#endregion |
||||||
|
|
||||||
|
using System; |
||||||
|
using System.Collections.Generic; |
||||||
|
using Grpc.Core.Utils; |
||||||
|
|
||||||
|
namespace Grpc.Core.Internal |
||||||
|
{ |
||||||
|
/// <summary> |
||||||
|
/// Creates native call credential objects from instances of <c>CallCredentials</c>. |
||||||
|
/// </summary> |
||||||
|
internal class DefaultCallCredentialsConfigurator : CallCredentialsConfiguratorBase |
||||||
|
{ |
||||||
|
CallCredentialsSafeHandle nativeCredentials; |
||||||
|
|
||||||
|
public CallCredentialsSafeHandle NativeCredentials => nativeCredentials; |
||||||
|
|
||||||
|
public override void SetAsyncAuthInterceptorCredentials(object state, AsyncAuthInterceptor interceptor) |
||||||
|
{ |
||||||
|
GrpcPreconditions.CheckState(nativeCredentials == null); |
||||||
|
|
||||||
|
var plugin = new NativeMetadataCredentialsPlugin(interceptor); |
||||||
|
nativeCredentials = plugin.Credentials; |
||||||
|
} |
||||||
|
|
||||||
|
public override void SetCompositeCredentials(object state, IReadOnlyList<CallCredentials> credentials) |
||||||
|
{ |
||||||
|
GrpcPreconditions.CheckState(nativeCredentials == null); |
||||||
|
|
||||||
|
GrpcPreconditions.CheckArgument(credentials.Count >= 2); |
||||||
|
nativeCredentials = CompositeToNativeRecursive(credentials, 0); |
||||||
|
} |
||||||
|
|
||||||
|
// Recursive descent makes managing lifetime of intermediate CredentialSafeHandle instances easier. |
||||||
|
// In practice, we won't usually see composites from more than two credentials anyway. |
||||||
|
private CallCredentialsSafeHandle CompositeToNativeRecursive(IReadOnlyList<CallCredentials> credentials, int startIndex) |
||||||
|
{ |
||||||
|
if (startIndex == credentials.Count - 1) |
||||||
|
{ |
||||||
|
return credentials[startIndex].ToNativeCredentials(); |
||||||
|
} |
||||||
|
|
||||||
|
using (var cred1 = credentials[startIndex].ToNativeCredentials()) |
||||||
|
using (var cred2 = CompositeToNativeRecursive(credentials, startIndex + 1)) |
||||||
|
{ |
||||||
|
var nativeComposite = CallCredentialsSafeHandle.CreateComposite(cred1, cred2); |
||||||
|
if (nativeComposite.IsInvalid) |
||||||
|
{ |
||||||
|
throw new ArgumentException("Error creating native composite credentials. Likely, this is because you are trying to compose incompatible credentials."); |
||||||
|
} |
||||||
|
return nativeComposite; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
internal static class CallCredentialsExtensions |
||||||
|
{ |
||||||
|
/// <summary> |
||||||
|
/// Creates native object for the credentials. |
||||||
|
/// </summary> |
||||||
|
/// <returns>The native credentials.</returns> |
||||||
|
public static CallCredentialsSafeHandle ToNativeCredentials(this CallCredentials credentials) |
||||||
|
{ |
||||||
|
var configurator = new DefaultCallCredentialsConfigurator(); |
||||||
|
credentials.InternalPopulateConfiguration(configurator, credentials); |
||||||
|
return configurator.NativeCredentials; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,101 @@ |
|||||||
|
<?xml version="1.0" encoding="UTF-8"?> |
||||||
|
<Scheme |
||||||
|
LastUpgradeVersion = "1010" |
||||||
|
version = "1.3"> |
||||||
|
<BuildAction |
||||||
|
parallelizeBuildables = "YES" |
||||||
|
buildImplicitDependencies = "YES"> |
||||||
|
<BuildActionEntries> |
||||||
|
<BuildActionEntry |
||||||
|
buildForTesting = "YES" |
||||||
|
buildForRunning = "YES" |
||||||
|
buildForProfiling = "YES" |
||||||
|
buildForArchiving = "YES" |
||||||
|
buildForAnalyzing = "YES"> |
||||||
|
<BuildableReference |
||||||
|
BuildableIdentifier = "primary" |
||||||
|
BlueprintIdentifier = "5EDA907A220DF0BC0046D27A" |
||||||
|
BuildableName = "GrpcIosTest.app" |
||||||
|
BlueprintName = "GrpcIosTest" |
||||||
|
ReferencedContainer = "container:GrpcIosTest.xcodeproj"> |
||||||
|
</BuildableReference> |
||||||
|
</BuildActionEntry> |
||||||
|
</BuildActionEntries> |
||||||
|
</BuildAction> |
||||||
|
<TestAction |
||||||
|
buildConfiguration = "Debug" |
||||||
|
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" |
||||||
|
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" |
||||||
|
shouldUseLaunchSchemeArgsEnv = "YES"> |
||||||
|
<Testables> |
||||||
|
<TestableReference |
||||||
|
skipped = "NO"> |
||||||
|
<BuildableReference |
||||||
|
BuildableIdentifier = "primary" |
||||||
|
BlueprintIdentifier = "B0C18CA3222DEF140002B502" |
||||||
|
BuildableName = "GrpcIosTestUITests.xctest" |
||||||
|
BlueprintName = "GrpcIosTestUITests" |
||||||
|
ReferencedContainer = "container:GrpcIosTest.xcodeproj"> |
||||||
|
</BuildableReference> |
||||||
|
</TestableReference> |
||||||
|
</Testables> |
||||||
|
<MacroExpansion> |
||||||
|
<BuildableReference |
||||||
|
BuildableIdentifier = "primary" |
||||||
|
BlueprintIdentifier = "5EDA907A220DF0BC0046D27A" |
||||||
|
BuildableName = "GrpcIosTest.app" |
||||||
|
BlueprintName = "GrpcIosTest" |
||||||
|
ReferencedContainer = "container:GrpcIosTest.xcodeproj"> |
||||||
|
</BuildableReference> |
||||||
|
</MacroExpansion> |
||||||
|
<AdditionalOptions> |
||||||
|
</AdditionalOptions> |
||||||
|
</TestAction> |
||||||
|
<LaunchAction |
||||||
|
buildConfiguration = "Debug" |
||||||
|
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" |
||||||
|
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" |
||||||
|
launchStyle = "0" |
||||||
|
useCustomWorkingDirectory = "NO" |
||||||
|
ignoresPersistentStateOnLaunch = "NO" |
||||||
|
debugDocumentVersioning = "YES" |
||||||
|
debugServiceExtension = "internal" |
||||||
|
allowLocationSimulation = "YES"> |
||||||
|
<BuildableProductRunnable |
||||||
|
runnableDebuggingMode = "0"> |
||||||
|
<BuildableReference |
||||||
|
BuildableIdentifier = "primary" |
||||||
|
BlueprintIdentifier = "5EDA907A220DF0BC0046D27A" |
||||||
|
BuildableName = "GrpcIosTest.app" |
||||||
|
BlueprintName = "GrpcIosTest" |
||||||
|
ReferencedContainer = "container:GrpcIosTest.xcodeproj"> |
||||||
|
</BuildableReference> |
||||||
|
</BuildableProductRunnable> |
||||||
|
<AdditionalOptions> |
||||||
|
</AdditionalOptions> |
||||||
|
</LaunchAction> |
||||||
|
<ProfileAction |
||||||
|
buildConfiguration = "Release" |
||||||
|
shouldUseLaunchSchemeArgsEnv = "YES" |
||||||
|
savedToolIdentifier = "" |
||||||
|
useCustomWorkingDirectory = "NO" |
||||||
|
debugDocumentVersioning = "YES"> |
||||||
|
<BuildableProductRunnable |
||||||
|
runnableDebuggingMode = "0"> |
||||||
|
<BuildableReference |
||||||
|
BuildableIdentifier = "primary" |
||||||
|
BlueprintIdentifier = "5EDA907A220DF0BC0046D27A" |
||||||
|
BuildableName = "GrpcIosTest.app" |
||||||
|
BlueprintName = "GrpcIosTest" |
||||||
|
ReferencedContainer = "container:GrpcIosTest.xcodeproj"> |
||||||
|
</BuildableReference> |
||||||
|
</BuildableProductRunnable> |
||||||
|
</ProfileAction> |
||||||
|
<AnalyzeAction |
||||||
|
buildConfiguration = "Debug"> |
||||||
|
</AnalyzeAction> |
||||||
|
<ArchiveAction |
||||||
|
buildConfiguration = "Release" |
||||||
|
revealArchiveInOrganizer = "YES"> |
||||||
|
</ArchiveAction> |
||||||
|
</Scheme> |
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue