GRPC Core
18.0.0
|
#include <grpc/support/port_platform.h>
#include "src/core/lib/surface/server.h"
#include <limits.h>
#include <stdlib.h>
#include <string.h>
#include <algorithm>
#include <atomic>
#include <iterator>
#include <list>
#include <queue>
#include <utility>
#include <vector>
#include "absl/memory/memory.h"
#include "absl/types/optional.h"
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include <grpc/support/string_util.h>
#include "src/core/lib/channel/channel_args.h"
#include "src/core/lib/channel/channelz.h"
#include "src/core/lib/channel/connected_channel.h"
#include "src/core/lib/debug/stats.h"
#include "src/core/lib/gpr/spinlock.h"
#include "src/core/lib/gprpp/mpscq.h"
#include "src/core/lib/iomgr/executor.h"
#include "src/core/lib/iomgr/iomgr.h"
#include "src/core/lib/slice/slice_internal.h"
#include "src/core/lib/surface/api_trace.h"
#include "src/core/lib/surface/call.h"
#include "src/core/lib/surface/channel.h"
#include "src/core/lib/surface/completion_queue.h"
#include "src/core/lib/surface/init.h"
#include "src/core/lib/transport/metadata.h"
#include "src/core/lib/transport/static_metadata.h"
Namespaces | |
grpc_core | |
Round Robin Policy. | |
Functions | |
grpc_server * | grpc_server_create (const grpc_channel_args *args, void *reserved) |
Create a server. More... | |
void | grpc_server_register_completion_queue (grpc_server *server, grpc_completion_queue *cq, void *reserved) |
Register a completion queue with the server. More... | |
void * | grpc_server_register_method (grpc_server *server, const char *method, const char *host, grpc_server_register_method_payload_handling payload_handling, uint32_t flags) |
Registers a method in the server. More... | |
void | grpc_server_start (grpc_server *server) |
Start a server - tells all listeners to start listening. More... | |
void | grpc_server_shutdown_and_notify (grpc_server *server, grpc_completion_queue *cq, void *tag) |
Begin shutting down a server. More... | |
void | grpc_server_cancel_all_calls (grpc_server *server) |
Cancel all in-progress calls. More... | |
void | grpc_server_destroy (grpc_server *server) |
Destroy a server. More... | |
grpc_call_error | grpc_server_request_call (grpc_server *server, grpc_call **call, grpc_call_details *details, grpc_metadata_array *request_metadata, grpc_completion_queue *cq_bound_to_call, grpc_completion_queue *cq_for_notification, void *tag) |
Request notification of a new call. More... | |
grpc_call_error | grpc_server_request_registered_call (grpc_server *server, void *registered_method, grpc_call **call, gpr_timespec *deadline, grpc_metadata_array *request_metadata, grpc_byte_buffer **optional_payload, grpc_completion_queue *cq_bound_to_call, grpc_completion_queue *cq_for_notification, void *tag_new) |
Request notification of a new pre-registered call. More... | |
void | grpc_server_set_config_fetcher (grpc_server *server, grpc_server_config_fetcher *server_config_fetcher) |
EXPERIMENTAL. More... | |
void | grpc_server_config_fetcher_destroy (grpc_server_config_fetcher *server_config_fetcher) |
EXPERIMENTAL. More... | |
Variables | |
TraceFlag | grpc_core::grpc_server_channel_trace (false, "server_channel") |
void grpc_server_cancel_all_calls | ( | grpc_server * | server | ) |
Cancel all in-progress calls.
Only usable after shutdown.
void grpc_server_config_fetcher_destroy | ( | grpc_server_config_fetcher * | config_fetcher | ) |
EXPERIMENTAL.
Destroys a config fetcher.
grpc_server* grpc_server_create | ( | const grpc_channel_args * | args, |
void * | reserved | ||
) |
Create a server.
Additional configuration for each incoming channel can be specified with args. If no additional configuration is needed, args can be NULL. The user data in 'args' need only live through the invocation of this function. However, if any args of the 'pointer' type are passed, then the referenced vtable must be maintained by the caller until grpc_server_destroy terminates. See grpc_channel_args definition for more on this.
void grpc_server_destroy | ( | grpc_server * | server | ) |
Destroy a server.
Shutdown must have completed beforehand (i.e. all tags generated by grpc_server_shutdown_and_notify must have been received, and at least one call to grpc_server_shutdown_and_notify must have been made).
void grpc_server_register_completion_queue | ( | grpc_server * | server, |
grpc_completion_queue * | cq, | ||
void * | reserved | ||
) |
Register a completion queue with the server.
Must be done for any notification completion queue that is passed to grpc_server_request_*_call and to grpc_server_shutdown_and_notify. Must be performed prior to grpc_server_start.
void* grpc_server_register_method | ( | grpc_server * | server, |
const char * | method, | ||
const char * | host, | ||
grpc_server_register_method_payload_handling | payload_handling, | ||
uint32_t | flags | ||
) |
Registers a method in the server.
Methods to this (host, method) pair will not be reported by grpc_server_request_call, but instead be reported by grpc_server_request_registered_call when passed the appropriate registered_method (as returned by this function). Must be called before grpc_server_start. Returns NULL on failure.
grpc_call_error grpc_server_request_call | ( | grpc_server * | server, |
grpc_call ** | call, | ||
grpc_call_details * | details, | ||
grpc_metadata_array * | request_metadata, | ||
grpc_completion_queue * | cq_bound_to_call, | ||
grpc_completion_queue * | cq_for_notification, | ||
void * | tag_new | ||
) |
Request notification of a new call.
Once a call is received, a notification tagged with tag_new is added to cq_for_notification. call, details and request_metadata are updated with the appropriate call information. cq_bound_to_call is bound to call, and batch operation notifications for that call will be posted to cq_bound_to_call. Note that cq_for_notification must have been registered to the server via grpc_server_register_completion_queue.
grpc_call_error grpc_server_request_registered_call | ( | grpc_server * | server, |
void * | registered_method, | ||
grpc_call ** | call, | ||
gpr_timespec * | deadline, | ||
grpc_metadata_array * | request_metadata, | ||
grpc_byte_buffer ** | optional_payload, | ||
grpc_completion_queue * | cq_bound_to_call, | ||
grpc_completion_queue * | cq_for_notification, | ||
void * | tag_new | ||
) |
Request notification of a new pre-registered call.
'cq_for_notification' must have been registered to the server via grpc_server_register_completion_queue.
void grpc_server_set_config_fetcher | ( | grpc_server * | server, |
grpc_server_config_fetcher * | config_fetcher | ||
) |
EXPERIMENTAL.
Sets the server's config fetcher. Takes ownership. Must be called before adding ports
void grpc_server_shutdown_and_notify | ( | grpc_server * | server, |
grpc_completion_queue * | cq, | ||
void * | tag | ||
) |
Begin shutting down a server.
After completion, no new calls or connections will be admitted. Existing calls will be allowed to complete. Send a GRPC_OP_COMPLETE event when there are no more calls being serviced. Shutdown is idempotent, and all tags will be notified at once if multiple grpc_server_shutdown_and_notify calls are made. 'cq' must have been registered to this server via grpc_server_register_completion_queue.
void grpc_server_start | ( | grpc_server * | server | ) |
Start a server - tells all listeners to start listening.
grpc_closure closure |
grpc_slice slice |