Home | History | Annotate | Download | only in surface
      1 /*
      2  *
      3  * Copyright 2015 gRPC authors.
      4  *
      5  * Licensed under the Apache License, Version 2.0 (the "License");
      6  * you may not use this file except in compliance with the License.
      7  * You may obtain a copy of the License at
      8  *
      9  *     http://www.apache.org/licenses/LICENSE-2.0
     10  *
     11  * Unless required by applicable law or agreed to in writing, software
     12  * distributed under the License is distributed on an "AS IS" BASIS,
     13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     14  * See the License for the specific language governing permissions and
     15  * limitations under the License.
     16  *
     17  */
     18 
     19 #ifndef GRPC_CORE_LIB_SURFACE_CHANNEL_H
     20 #define GRPC_CORE_LIB_SURFACE_CHANNEL_H
     21 
     22 #include <grpc/support/port_platform.h>
     23 
     24 #include "src/core/lib/channel/channel_stack.h"
     25 #include "src/core/lib/channel/channel_stack_builder.h"
     26 #include "src/core/lib/channel/channelz.h"
     27 #include "src/core/lib/surface/channel_stack_type.h"
     28 
     29 grpc_channel* grpc_channel_create(const char* target,
     30                                   const grpc_channel_args* args,
     31                                   grpc_channel_stack_type channel_stack_type,
     32                                   grpc_transport* optional_transport);
     33 
     34 grpc_channel* grpc_channel_create_with_builder(
     35     grpc_channel_stack_builder* builder,
     36     grpc_channel_stack_type channel_stack_type);
     37 
     38 /** Create a call given a grpc_channel, in order to call \a method.
     39     Progress is tied to activity on \a pollset_set. The returned call object is
     40     meant to be used with \a grpc_call_start_batch_and_execute, which relies on
     41     callbacks to signal completions. \a method and \a host need
     42     only live through the invocation of this function. If \a parent_call is
     43     non-NULL, it must be a server-side call. It will be used to propagate
     44     properties from the server call to this new client call, depending on the
     45     value of \a propagation_mask (see propagation_bits.h for possible values) */
     46 grpc_call* grpc_channel_create_pollset_set_call(
     47     grpc_channel* channel, grpc_call* parent_call, uint32_t propagation_mask,
     48     grpc_pollset_set* pollset_set, grpc_slice method, const grpc_slice* host,
     49     grpc_millis deadline, void* reserved);
     50 
     51 /** Get a (borrowed) pointer to this channels underlying channel stack */
     52 grpc_channel_stack* grpc_channel_get_channel_stack(grpc_channel* channel);
     53 
     54 grpc_core::channelz::ChannelNode* grpc_channel_get_channelz_node(
     55     grpc_channel* channel);
     56 
     57 /** Get a grpc_mdelem of grpc-status: X where X is the numeric value of
     58     status_code.
     59 
     60     The returned elem is owned by the caller. */
     61 grpc_mdelem grpc_channel_get_reffed_status_elem(grpc_channel* channel,
     62                                                 int status_code);
     63 
     64 size_t grpc_channel_get_call_size_estimate(grpc_channel* channel);
     65 void grpc_channel_update_call_size_estimate(grpc_channel* channel, size_t size);
     66 
     67 #ifndef NDEBUG
     68 void grpc_channel_internal_ref(grpc_channel* channel, const char* reason);
     69 void grpc_channel_internal_unref(grpc_channel* channel, const char* reason);
     70 #define GRPC_CHANNEL_INTERNAL_REF(channel, reason) \
     71   grpc_channel_internal_ref(channel, reason)
     72 #define GRPC_CHANNEL_INTERNAL_UNREF(channel, reason) \
     73   grpc_channel_internal_unref(channel, reason)
     74 #else
     75 void grpc_channel_internal_ref(grpc_channel* channel);
     76 void grpc_channel_internal_unref(grpc_channel* channel);
     77 #define GRPC_CHANNEL_INTERNAL_REF(channel, reason) \
     78   grpc_channel_internal_ref(channel)
     79 #define GRPC_CHANNEL_INTERNAL_UNREF(channel, reason) \
     80   grpc_channel_internal_unref(channel)
     81 #endif
     82 
     83 /** Return the channel's compression options. */
     84 grpc_compression_options grpc_channel_compression_options(
     85     const grpc_channel* channel);
     86 
     87 #endif /* GRPC_CORE_LIB_SURFACE_CHANNEL_H */
     88