mirror of https://github.com/grpc/grpc.git
parent
4dff4fc430
commit
e549843885
27 changed files with 165 additions and 475 deletions
@ -1,125 +0,0 @@ |
||||
/*
|
||||
* |
||||
* 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. |
||||
* |
||||
*/ |
||||
|
||||
/// An Alarm posts the user-provided tag to its associated completion queue or
|
||||
/// invokes the user-provided function on expiry or cancellation.
|
||||
#ifndef GRPCPP_ALARM_IMPL_H |
||||
#define GRPCPP_ALARM_IMPL_H |
||||
|
||||
#include <functional> |
||||
|
||||
#include <grpc/grpc.h> |
||||
#include <grpcpp/impl/codegen/completion_queue.h> |
||||
#include <grpcpp/impl/codegen/completion_queue_tag.h> |
||||
#include <grpcpp/impl/codegen/grpc_library.h> |
||||
#include <grpcpp/impl/codegen/time.h> |
||||
#include <grpcpp/impl/grpc_library.h> |
||||
|
||||
namespace grpc_impl { |
||||
|
||||
class Alarm : private ::grpc::GrpcLibraryCodegen { |
||||
public: |
||||
/// Create an unset completion queue alarm
|
||||
Alarm(); |
||||
|
||||
/// Destroy the given completion queue alarm, cancelling it in the process.
|
||||
~Alarm(); |
||||
|
||||
/// DEPRECATED: Create and set a completion queue alarm instance associated to
|
||||
/// \a cq.
|
||||
/// This form is deprecated because it is inherently racy.
|
||||
/// \internal We rely on the presence of \a cq for grpc initialization. If \a
|
||||
/// cq were ever to be removed, a reference to a static
|
||||
/// internal::GrpcLibraryInitializer instance would need to be introduced
|
||||
/// here. \endinternal.
|
||||
template <typename T> |
||||
Alarm(::grpc::CompletionQueue* cq, const T& deadline, void* tag) : Alarm() { |
||||
SetInternal(cq, ::grpc::TimePoint<T>(deadline).raw_time(), tag); |
||||
} |
||||
|
||||
/// Trigger an alarm instance on completion queue \a cq at the specified time.
|
||||
/// Once the alarm expires (at \a deadline) or it's cancelled (see \a Cancel),
|
||||
/// an event with tag \a tag will be added to \a cq. If the alarm expired, the
|
||||
/// event's success bit will be true, false otherwise (ie, upon cancellation).
|
||||
template <typename T> |
||||
void Set(::grpc::CompletionQueue* cq, const T& deadline, void* tag) { |
||||
SetInternal(cq, ::grpc::TimePoint<T>(deadline).raw_time(), tag); |
||||
} |
||||
|
||||
/// Alarms aren't copyable.
|
||||
Alarm(const Alarm&) = delete; |
||||
Alarm& operator=(const Alarm&) = delete; |
||||
|
||||
/// Alarms are movable.
|
||||
Alarm(Alarm&& rhs) : alarm_(rhs.alarm_) { rhs.alarm_ = nullptr; } |
||||
Alarm& operator=(Alarm&& rhs) { |
||||
alarm_ = rhs.alarm_; |
||||
rhs.alarm_ = nullptr; |
||||
return *this; |
||||
} |
||||
|
||||
/// Cancel a completion queue alarm. Calling this function over an alarm that
|
||||
/// has already fired has no effect.
|
||||
void Cancel(); |
||||
|
||||
#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL |
||||
/// Set an alarm to invoke callback \a f. The argument to the callback
|
||||
/// states whether the alarm expired at \a deadline (true) or was cancelled
|
||||
/// (false)
|
||||
template <typename T> |
||||
void Set(const T& deadline, std::function<void(bool)> f) { |
||||
SetInternal(::grpc::TimePoint<T>(deadline).raw_time(), std::move(f)); |
||||
} |
||||
#endif |
||||
|
||||
/// NOTE: class experimental_type is not part of the public API of this class
|
||||
/// TODO(vjpai): Move these contents to the public API of Alarm when
|
||||
/// they are no longer experimental
|
||||
class experimental_type { |
||||
public: |
||||
explicit experimental_type(Alarm* alarm) : alarm_(alarm) {} |
||||
|
||||
/// Set an alarm to invoke callback \a f. The argument to the callback
|
||||
/// states whether the alarm expired at \a deadline (true) or was cancelled
|
||||
/// (false)
|
||||
template <typename T> |
||||
void Set(const T& deadline, std::function<void(bool)> f) { |
||||
alarm_->SetInternal(::grpc::TimePoint<T>(deadline).raw_time(), |
||||
std::move(f)); |
||||
} |
||||
|
||||
private: |
||||
Alarm* alarm_; |
||||
}; |
||||
|
||||
/// 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); } |
||||
|
||||
private: |
||||
void SetInternal(::grpc::CompletionQueue* cq, gpr_timespec deadline, |
||||
void* tag); |
||||
void SetInternal(gpr_timespec deadline, std::function<void(bool)> f); |
||||
|
||||
::grpc::internal::CompletionQueueTag* alarm_; |
||||
}; |
||||
|
||||
} // namespace grpc_impl
|
||||
|
||||
#endif // GRPCPP_ALARM_IMPL_H
|
@ -1,70 +0,0 @@ |
||||
/*
|
||||
* |
||||
* Copyright 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_CREATE_CHANNEL_POSIX_IMPL_H |
||||
#define GRPCPP_CREATE_CHANNEL_POSIX_IMPL_H |
||||
|
||||
#include <memory> |
||||
|
||||
#include <grpc/support/port_platform.h> |
||||
#include <grpcpp/channel.h> |
||||
#include <grpcpp/support/channel_arguments.h> |
||||
|
||||
namespace grpc_impl { |
||||
|
||||
#ifdef GPR_SUPPORT_CHANNELS_FROM_FD |
||||
|
||||
/// Create a new \a Channel communicating over the given file descriptor.
|
||||
///
|
||||
/// \param target The name of the target.
|
||||
/// \param fd The file descriptor representing a socket.
|
||||
std::shared_ptr<grpc::Channel> CreateInsecureChannelFromFd( |
||||
const std::string& target, int fd); |
||||
|
||||
/// Create a new \a Channel communicating over given file descriptor with custom
|
||||
/// channel arguments.
|
||||
///
|
||||
/// \param target The name of the target.
|
||||
/// \param fd The file descriptor representing a socket.
|
||||
/// \param args Options for channel creation.
|
||||
std::shared_ptr<grpc::Channel> CreateCustomInsecureChannelFromFd( |
||||
const std::string& target, int fd, const grpc::ChannelArguments& args); |
||||
|
||||
namespace experimental { |
||||
|
||||
/// Create a new \a Channel communicating over given file descriptor with custom
|
||||
/// channel arguments.
|
||||
///
|
||||
/// \param target The name of the target.
|
||||
/// \param fd The file descriptor representing a socket.
|
||||
/// \param args Options for channel creation.
|
||||
/// \param interceptor_creators Vector of interceptor factory objects.
|
||||
std::shared_ptr<grpc::Channel> |
||||
CreateCustomInsecureChannelWithInterceptorsFromFd( |
||||
const std::string& target, int fd, const grpc::ChannelArguments& args, |
||||
std::unique_ptr<std::vector< |
||||
std::unique_ptr<grpc::experimental::ClientInterceptorFactoryInterface>>> |
||||
interceptor_creators); |
||||
|
||||
} // namespace experimental
|
||||
|
||||
#endif // GPR_SUPPORT_CHANNELS_FROM_FD
|
||||
|
||||
} // namespace grpc_impl
|
||||
|
||||
#endif // GRPCPP_CREATE_CHANNEL_POSIX_IMPL_H
|
@ -1,43 +0,0 @@ |
||||
/*
|
||||
* |
||||
* 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_IMPL_SERVER_BUILDER_OPTION_IMPL_H |
||||
#define GRPCPP_IMPL_SERVER_BUILDER_OPTION_IMPL_H |
||||
|
||||
#include <map> |
||||
#include <memory> |
||||
|
||||
#include <grpcpp/impl/server_builder_plugin.h> |
||||
#include <grpcpp/support/channel_arguments.h> |
||||
|
||||
namespace grpc_impl { |
||||
|
||||
/// Interface to pass an option to a \a ServerBuilder.
|
||||
class ServerBuilderOption { |
||||
public: |
||||
virtual ~ServerBuilderOption() {} |
||||
/// Alter the \a ChannelArguments used to create the gRPC server.
|
||||
virtual void UpdateArguments(grpc::ChannelArguments* args) = 0; |
||||
/// Alter the ServerBuilderPlugin map that will be added into ServerBuilder.
|
||||
virtual void UpdatePlugins( |
||||
std::vector<std::unique_ptr<grpc::ServerBuilderPlugin>>* plugins) = 0; |
||||
}; |
||||
|
||||
} // namespace grpc_impl
|
||||
|
||||
#endif // GRPCPP_IMPL_SERVER_BUILDER_OPTION_IMPL_H
|
@ -1,57 +0,0 @@ |
||||
/*
|
||||
* |
||||
* Copyright 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_IMPL_SERVER_INITIALIZER_IMPL_H |
||||
#define GRPCPP_IMPL_SERVER_INITIALIZER_IMPL_H |
||||
|
||||
#include <memory> |
||||
#include <vector> |
||||
|
||||
#include <grpcpp/server.h> |
||||
|
||||
namespace grpc { |
||||
|
||||
class Service; |
||||
} // namespace grpc
|
||||
namespace grpc_impl { |
||||
class Server; |
||||
|
||||
class ServerInitializer { |
||||
public: |
||||
ServerInitializer(grpc::Server* server) : server_(server) {} |
||||
|
||||
bool RegisterService(std::shared_ptr<grpc::Service> service) { |
||||
if (!server_->RegisterService(nullptr, service.get())) { |
||||
return false; |
||||
} |
||||
default_services_.push_back(service); |
||||
return true; |
||||
} |
||||
|
||||
const std::vector<std::string>* GetServiceList() { |
||||
return &server_->services_; |
||||
} |
||||
|
||||
private: |
||||
grpc::Server* server_; |
||||
std::vector<std::shared_ptr<grpc::Service> > default_services_; |
||||
}; |
||||
|
||||
} // namespace grpc_impl
|
||||
|
||||
#endif // GRPCPP_IMPL_SERVER_INITIALIZER_IMPL_H
|
@ -1,68 +0,0 @@ |
||||
/*
|
||||
* |
||||
* Copyright 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_RESOURCE_QUOTA_IMPL_H |
||||
#define GRPCPP_RESOURCE_QUOTA_IMPL_H |
||||
|
||||
struct grpc_resource_quota; |
||||
|
||||
#include <grpcpp/impl/codegen/config.h> |
||||
#include <grpcpp/impl/codegen/grpc_library.h> |
||||
|
||||
namespace grpc_impl { |
||||
|
||||
/// ResourceQuota represents a bound on memory and thread usage by the gRPC
|
||||
/// library. A ResourceQuota can be attached to a server (via \a ServerBuilder),
|
||||
/// or a client channel (via \a ChannelArguments).
|
||||
/// gRPC will attempt to keep memory and threads used by all attached entities
|
||||
/// below the ResourceQuota bound.
|
||||
class ResourceQuota final : private ::grpc::GrpcLibraryCodegen { |
||||
public: |
||||
/// \param name - a unique name for this ResourceQuota.
|
||||
explicit ResourceQuota(const std::string& name); |
||||
ResourceQuota(); |
||||
~ResourceQuota(); |
||||
|
||||
/// Resize this \a ResourceQuota to a new size. If \a new_size is smaller
|
||||
/// than the current size of the pool, memory usage will be monotonically
|
||||
/// decreased until it falls under \a new_size.
|
||||
/// No time bound is given for this to occur however.
|
||||
ResourceQuota& Resize(size_t new_size); |
||||
|
||||
/// Set the max number of threads that can be allocated from this
|
||||
/// ResourceQuota object.
|
||||
///
|
||||
/// If the new_max_threads value is smaller than the current value, no new
|
||||
/// threads are allocated until the number of active threads fall below
|
||||
/// new_max_threads. There is no time bound on when this may happen i.e none
|
||||
/// of the current threads are forcefully destroyed and all threads run their
|
||||
/// normal course.
|
||||
ResourceQuota& SetMaxThreads(int new_max_threads); |
||||
|
||||
grpc_resource_quota* c_resource_quota() const { return impl_; } |
||||
|
||||
private: |
||||
ResourceQuota(const ResourceQuota& rhs); |
||||
ResourceQuota& operator=(const ResourceQuota& rhs); |
||||
|
||||
grpc_resource_quota* const impl_; |
||||
}; |
||||
|
||||
} // namespace grpc_impl
|
||||
|
||||
#endif // GRPCPP_RESOURCE_QUOTA_IMPL_H
|
@ -1,33 +0,0 @@ |
||||
/*
|
||||
* |
||||
* 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_SECURITY_CRONET_CREDENTIALS_IMPL_H |
||||
#define GRPCPP_SECURITY_CRONET_CREDENTIALS_IMPL_H |
||||
|
||||
#include <memory> |
||||
|
||||
namespace grpc_impl { |
||||
|
||||
class ChannelCredentials; |
||||
|
||||
/// Credentials for a channel using Cronet.
|
||||
std::shared_ptr<ChannelCredentials> CronetChannelCredentials(void* engine); |
||||
|
||||
} // namespace grpc_impl
|
||||
|
||||
#endif // GRPCPP_SECURITY_CRONET_CREDENTIALS_IMPL_H
|
Loading…
Reference in new issue