Skip to content

Commit

Permalink
Revert changes to Channel
Browse files Browse the repository at this point in the history
  • Loading branch information
karthikravis committed May 15, 2019
1 parent 6be0b06 commit 772a74a
Show file tree
Hide file tree
Showing 30 changed files with 138 additions and 226 deletions.
1 change: 0 additions & 1 deletion BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,6 @@ GRPCXX_PUBLIC_HDRS = [
"include/grpcpp/alarm.h",
"include/grpcpp/alarm_impl.h",
"include/grpcpp/channel.h",
"include/grpcpp/channel_impl.h",
"include/grpcpp/client_context.h",
"include/grpcpp/completion_queue.h",
"include/grpcpp/create_channel.h",
Expand Down
1 change: 0 additions & 1 deletion BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -1022,7 +1022,6 @@ config("grpc_config") {
"include/grpcpp/alarm.h",
"include/grpcpp/alarm_impl.h",
"include/grpcpp/channel.h",
"include/grpcpp/channel_impl.h",
"include/grpcpp/client_context.h",
"include/grpcpp/completion_queue.h",
"include/grpcpp/create_channel.h",
Expand Down
3 changes: 0 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3148,7 +3148,6 @@ foreach(_hdr
include/grpcpp/alarm.h
include/grpcpp/alarm_impl.h
include/grpcpp/channel.h
include/grpcpp/channel_impl.h
include/grpcpp/client_context.h
include/grpcpp/completion_queue.h
include/grpcpp/create_channel.h
Expand Down Expand Up @@ -3763,7 +3762,6 @@ foreach(_hdr
include/grpcpp/alarm.h
include/grpcpp/alarm_impl.h
include/grpcpp/channel.h
include/grpcpp/channel_impl.h
include/grpcpp/client_context.h
include/grpcpp/completion_queue.h
include/grpcpp/create_channel.h
Expand Down Expand Up @@ -4750,7 +4748,6 @@ foreach(_hdr
include/grpcpp/alarm.h
include/grpcpp/alarm_impl.h
include/grpcpp/channel.h
include/grpcpp/channel_impl.h
include/grpcpp/client_context.h
include/grpcpp/completion_queue.h
include/grpcpp/create_channel.h
Expand Down
3 changes: 0 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5501,7 +5501,6 @@ PUBLIC_HEADERS_CXX += \
include/grpcpp/alarm.h \
include/grpcpp/alarm_impl.h \
include/grpcpp/channel.h \
include/grpcpp/channel_impl.h \
include/grpcpp/client_context.h \
include/grpcpp/completion_queue.h \
include/grpcpp/create_channel.h \
Expand Down Expand Up @@ -6124,7 +6123,6 @@ PUBLIC_HEADERS_CXX += \
include/grpcpp/alarm.h \
include/grpcpp/alarm_impl.h \
include/grpcpp/channel.h \
include/grpcpp/channel_impl.h \
include/grpcpp/client_context.h \
include/grpcpp/completion_queue.h \
include/grpcpp/create_channel.h \
Expand Down Expand Up @@ -7060,7 +7058,6 @@ PUBLIC_HEADERS_CXX += \
include/grpcpp/alarm.h \
include/grpcpp/alarm_impl.h \
include/grpcpp/channel.h \
include/grpcpp/channel_impl.h \
include/grpcpp/client_context.h \
include/grpcpp/completion_queue.h \
include/grpcpp/create_channel.h \
Expand Down
1 change: 0 additions & 1 deletion build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1350,7 +1350,6 @@ filegroups:
- include/grpcpp/alarm.h
- include/grpcpp/alarm_impl.h
- include/grpcpp/channel.h
- include/grpcpp/channel_impl.h
- include/grpcpp/client_context.h
- include/grpcpp/completion_queue.h
- include/grpcpp/create_channel.h
Expand Down
1 change: 0 additions & 1 deletion gRPC-C++.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ Pod::Spec.new do |s|
ss.source_files = 'include/grpcpp/alarm.h',
'include/grpcpp/alarm_impl.h',
'include/grpcpp/channel.h',
'include/grpcpp/channel_impl.h',
'include/grpcpp/client_context.h',
'include/grpcpp/completion_queue.h',
'include/grpcpp/create_channel.h',
Expand Down
94 changes: 87 additions & 7 deletions include/grpcpp/channel.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,24 @@
*
*/

#ifndef GRPCPP_CHANNEL_H
#define GRPCPP_CHANNEL_H
#ifndef GRPCPP_CHANNEL_IMPL_H
#define GRPCPP_CHANNEL_IMPL_H

#include <grpcpp/channel_impl.h>
#include <memory>
#include <mutex>

namespace grpc {
#include <grpc/grpc.h>
#include <grpcpp/impl/call.h>
#include <grpcpp/impl/codegen/channel_interface.h>
#include <grpcpp/impl/codegen/client_interceptor.h>
#include <grpcpp/impl/codegen/completion_queue.h>
#include <grpcpp/impl/codegen/config.h>
#include <grpcpp/impl/codegen/grpc_library.h>
#include <grpcpp/impl/codegen/sync.h>

struct grpc_channel;

typedef ::grpc_impl::Channel Channel;
namespace grpc {

namespace experimental {
/// Resets the channel's connection backoff.
Expand All @@ -32,6 +42,76 @@ namespace experimental {
void ChannelResetConnectionBackoff(Channel* channel);
} // namespace experimental

} // namespace grpc
/// Channels represent a connection to an endpoint. Created by \a CreateChannel.
class Channel final : public ChannelInterface,
public internal::CallHook,
public std::enable_shared_from_this<Channel>,
private GrpcLibraryCodegen {
public:
~Channel();

/// Get the current channel state. If the channel is in IDLE and
/// \a try_to_connect is set to true, try to connect.
grpc_connectivity_state GetState(bool try_to_connect) override;

/// Returns the LB policy name, or the empty string if not yet available.
grpc::string GetLoadBalancingPolicyName() const;

/// Returns the service config in JSON form, or the empty string if
/// not available.
grpc::string GetServiceConfigJSON() const;

private:
template <class InputMessage, class OutputMessage>
friend class internal::BlockingUnaryCallImpl;
friend void experimental::ChannelResetConnectionBackoff(Channel* channel);
friend std::shared_ptr<Channel> CreateChannelInternal(
const grpc::string& host, grpc_channel* c_channel,
std::vector<std::unique_ptr<
::grpc::experimental::ClientInterceptorFactoryInterface>>
interceptor_creators);
friend class internal::InterceptedChannel;
Channel(const grpc::string& host, grpc_channel* c_channel,
std::vector<std::unique_ptr<
experimental::ClientInterceptorFactoryInterface>>
interceptor_creators);

internal::Call CreateCall(const internal::RpcMethod& method,
ClientContext* context,
CompletionQueue* cq) override;
void PerformOpsOnCall(internal::CallOpSetInterface* ops,
internal::Call* call) override;
void* RegisterMethod(const char* method) override;

void NotifyOnStateChangeImpl(grpc_connectivity_state last_observed,
gpr_timespec deadline,
CompletionQueue* cq, void* tag) override;
bool WaitForStateChangeImpl(grpc_connectivity_state last_observed,
gpr_timespec deadline) override;

CompletionQueue* CallbackCQ() override;

internal::Call CreateCallInternal(
const internal::RpcMethod& method, ClientContext* context,
CompletionQueue* cq, size_t interceptor_pos) override;

const grpc::string host_;
grpc_channel* const c_channel_; // owned

// mu_ protects callback_cq_ (the per-channel callbackable completion queue)
grpc::internal::Mutex mu_;

// callback_cq_ references the callbackable completion queue associated
// with this channel (if any). It is set on the first call to CallbackCQ().
// It is _not owned_ by the channel; ownership belongs with its internal
// shutdown callback tag (invoked when the CQ is fully shutdown).
CompletionQueue* callback_cq_ = nullptr;

std::vector<
std::unique_ptr<experimental::ClientInterceptorFactoryInterface>>
interceptor_creators_;
};

} // namespace grpc_impl

#endif // GRPCPP_CHANNEL_H
#endif // GRPCPP_CHANNEL_IMPL_H
124 changes: 0 additions & 124 deletions include/grpcpp/channel_impl.h

This file was deleted.

5 changes: 1 addition & 4 deletions include/grpcpp/impl/codegen/client_callback.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,9 @@
#include <grpcpp/impl/codegen/core_codegen_interface.h>
#include <grpcpp/impl/codegen/status.h>

namespace grpc_impl {
class Channel;
}

namespace grpc {

class Channel;
class ClientContext;
class CompletionQueue;

Expand Down
8 changes: 4 additions & 4 deletions include/grpcpp/impl/codegen/client_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,10 @@ struct grpc_call;
namespace grpc_impl {

class CallCredentials;
class Channel;
} // namespace grpc_impl
namespace grpc {

class Channel;
class ChannelInterface;
class CompletionQueue;
class ClientContext;
Expand Down Expand Up @@ -397,7 +397,7 @@ class ClientContext {
friend class ::grpc::testing::InteropClientContextInspector;
friend class ::grpc::internal::CallOpClientRecvStatus;
friend class ::grpc::internal::CallOpRecvInitialMetadata;
friend class ::grpc_impl::Channel;
friend class Channel;
template <class R>
friend class ::grpc::ClientReader;
template <class W>
Expand Down Expand Up @@ -431,7 +431,7 @@ class ClientContext {

grpc_call* call() const { return call_; }
void set_call(grpc_call* call,
const std::shared_ptr<::grpc_impl::Channel>& channel);
const std::shared_ptr<Channel>& channel);

experimental::ClientRpcInfo* set_client_rpc_info(
const char* method, internal::RpcMethod::RpcType type,
Expand Down Expand Up @@ -464,7 +464,7 @@ class ClientContext {
bool wait_for_ready_explicitly_set_;
bool idempotent_;
bool cacheable_;
std::shared_ptr<::grpc_impl::Channel> channel_;
std::shared_ptr<Channel> channel_;
grpc::internal::Mutex mu_;
grpc_call* call_;
bool call_canceled_;
Expand Down
6 changes: 1 addition & 5 deletions include/grpcpp/impl/codegen/client_interceptor.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,10 @@
#include <grpcpp/impl/codegen/rpc_method.h>
#include <grpcpp/impl/codegen/string_ref.h>

namespace grpc_impl {

class Channel;
}

namespace grpc {

class ClientContext;
class Channel;

namespace internal {
class InterceptorBatchMethodsImpl;
Expand Down
Loading

0 comments on commit 772a74a

Please sign in to comment.