diff options
author | Mark D. Roth <roth@google.com> | 2018-10-15 13:12:26 -0700 |
---|---|---|
committer | Mark D. Roth <roth@google.com> | 2018-10-15 13:12:26 -0700 |
commit | f4e65787b6a28345162811a7f1d1caafcf289a33 (patch) | |
tree | 74e3b66283d3592273c2fc7f5d07dd6615cdb374 /include/grpcpp/impl/codegen | |
parent | 0b085a1f05813f54d4164c95fe9431c11f416af3 (diff) | |
parent | 945b6dbf7b14dc849c4cf377f52d27e635a971aa (diff) |
Merge remote-tracking branch 'upstream/master' into health_checking_service
Diffstat (limited to 'include/grpcpp/impl/codegen')
-rw-r--r-- | include/grpcpp/impl/codegen/client_context.h | 2 | ||||
-rw-r--r-- | include/grpcpp/impl/codegen/client_interceptor.h | 44 | ||||
-rw-r--r-- | include/grpcpp/impl/codegen/interceptor.h | 67 |
3 files changed, 112 insertions, 1 deletions
diff --git a/include/grpcpp/impl/codegen/client_context.h b/include/grpcpp/impl/codegen/client_context.h index 46635a541a..24f5c431ce 100644 --- a/include/grpcpp/impl/codegen/client_context.h +++ b/include/grpcpp/impl/codegen/client_context.h @@ -224,7 +224,7 @@ class ClientContext { /// \warning This method should only be called before invoking the rpc. /// /// \param deadline the deadline for the client call. Units are determined by - /// the type used. + /// the type used. The deadline is an absolute (not relative) time. template <typename T> void set_deadline(const T& deadline) { TimePoint<T> deadline_tp(deadline); diff --git a/include/grpcpp/impl/codegen/client_interceptor.h b/include/grpcpp/impl/codegen/client_interceptor.h new file mode 100644 index 0000000000..f460c5ac0c --- /dev/null +++ b/include/grpcpp/impl/codegen/client_interceptor.h @@ -0,0 +1,44 @@ +/* + * + * 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 GRPCPP_IMPL_CODEGEN_CLIENT_INTERCEPTOR_H +#define GRPCPP_IMPL_CODEGEN_CLIENT_INTERCEPTOR_H + +#include <grpcpp/impl/codegen/interceptor.h> + +namespace grpc { +namespace experimental { +class ClientInterceptor { + public: + virtual ~ClientInterceptor() {} + + virtual void Intercept(InterceptorBatchMethods* methods) = 0; +}; + +class ClientRpcInfo {}; + +class ClientInterceptorFactoryInterface { + public: + virtual ~ClientInterceptorFactoryInterface() {} + virtual ClientInterceptor* CreateClientInterceptor(ClientRpcInfo* info) = 0; +}; + +} // namespace experimental +} // namespace grpc + +#endif // GRPCPP_IMPL_CODEGEN_CLIENT_INTERCEPTOR_H diff --git a/include/grpcpp/impl/codegen/interceptor.h b/include/grpcpp/impl/codegen/interceptor.h new file mode 100644 index 0000000000..6402a3a946 --- /dev/null +++ b/include/grpcpp/impl/codegen/interceptor.h @@ -0,0 +1,67 @@ +/* + * + * 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 GRPCPP_IMPL_CODEGEN_INTERCEPTOR_H +#define GRPCPP_IMPL_CODEGEN_INTERCEPTOR_H + +namespace grpc { +namespace experimental { +class InterceptedMessage { + public: + template <class M> + bool Extract(M* msg); // returns false if definitely invalid extraction + template <class M> + M* MutableExtract(); + uint64_t length(); // length on wire +}; + +enum class InterceptionHookPoints { + /* The first two in this list are for clients and servers */ + PRE_SEND_INITIAL_METADATA, + PRE_SEND_MESSAGE, + PRE_SEND_STATUS /* server only */, + /* The following three are for hijacked clients only and can only be + registered by the global interceptor */ + PRE_RECV_INITIAL_METADATA, + PRE_RECV_MESSAGE, + PRE_RECV_STATUS, + /* The following two are for all clients and servers */ + POST_RECV_INITIAL_METADATA, + POST_RECV_MESSAGE, + POST_RECV_STATUS /* client only */, + POST_RECV_CLOSE /* server only */, + NUM_INTERCEPTION_HOOKS +}; + +class InterceptorBatchMethods { + public: + virtual ~InterceptorBatchMethods(); + // Queries to check whether the current batch has an interception hook point + // of type \a type + virtual bool QueryInterceptionHookPoint(InterceptionHookPoints type) = 0; + // Calling this will signal that the interceptor is done intercepting the + // current batch of the RPC + virtual void Proceed() = 0; + // Calling this indicates that the interceptor has hijacked the RPC (only + // valid if the batch contains send_initial_metadata on the client side) + virtual void Hijack() = 0; +}; +} // namespace experimental +} // namespace grpc + +#endif // GRPCPP_IMPL_CODEGEN_INTERCEPTOR_H |