commit
a4d2d0c798
903 changed files with 60585 additions and 17311 deletions
@ -0,0 +1,77 @@ |
||||
# gRPC command line tool |
||||
|
||||
## Overview |
||||
|
||||
This document describes the command line tool that comes with gRPC repository. It is desireable to have command line |
||||
tools written in other languages to roughly follow the same syntax and flags. |
||||
|
||||
At this point, the tool needs to be built from source, and it should be moved out to grpc-tools repository as a stand |
||||
alone application once it is mature enough. |
||||
|
||||
## Core functionality |
||||
|
||||
The command line tool can do the following things: |
||||
|
||||
- Send unary rpc. |
||||
- Attach metadata and display received metadata. |
||||
- Handle common authentication to server. |
||||
- Find the request/response types from a given proto file. |
||||
- Read proto request in text form. |
||||
- Read request in wire form (for protobuf messages, this means serialized binary form). |
||||
- Display proto response in text form. |
||||
- Write response in wire form to a file. |
||||
|
||||
The command line tool should support the following things: |
||||
|
||||
- List server services and methods through server reflection. |
||||
- Infer request/response types from server reflection result. |
||||
- Fine-grained auth control (such as, use this oauth token to talk to the server). |
||||
- Send streaming rpc. |
||||
|
||||
## Code location |
||||
|
||||
To use the tool, you need to get the grpc repository and in the grpc directory execute |
||||
|
||||
``` |
||||
$ make grpc_cli |
||||
``` |
||||
|
||||
The main file can be found at |
||||
https://github.com/grpc/grpc/blob/master/test/cpp/util/grpc_cli.cc |
||||
|
||||
## Usage |
||||
|
||||
### Basic usage |
||||
|
||||
Send a rpc to a helloworld server at `localhost:50051`: |
||||
|
||||
``` |
||||
$ bins/opt/grpc_cli call localhost:50051 SayHello examples/protos/helloworld.proto \ |
||||
"name: 'world'" --enable_ssl=false |
||||
``` |
||||
|
||||
On success, the tool will print out |
||||
|
||||
``` |
||||
Rpc succeeded with OK status |
||||
Response: |
||||
message: "Hello world" |
||||
``` |
||||
|
||||
The `localhost:50051` part indicates the server you are connecting to. `SayHello` is (part of) the |
||||
gRPC method string. Then there is the path to the proto file containing the service definition, |
||||
if it is not under current directory, you can use `--proto_path` to specify a new search root. |
||||
`"name: 'world'"` is the text format of the request proto message. |
||||
We are not using ssl here by `--enable_ssl=false`. For information on more |
||||
flags, look at the comments of `grpc_cli.cc`. |
||||
|
||||
### Send non-proto rpc |
||||
|
||||
For using gRPC with protocols other than probobuf, you will need the exact method name string |
||||
and a file containing the raw bytes to be sent on the wire |
||||
|
||||
``` |
||||
$ bins/opt/grpc_cli call localhost:50051 /helloworld.Greeter/SayHello --input_binary_file=input.bin \ |
||||
--output_binary_file=output.bin |
||||
``` |
||||
On success, you will need to read or decode the response from the `output.bin` file. |
@ -0,0 +1,91 @@ |
||||
GRPC C++ STYLE GUIDE |
||||
===================== |
||||
|
||||
Background |
||||
---------- |
||||
|
||||
Here we document style rules for C++ usage in the gRPC C++ bindings |
||||
and tests. |
||||
|
||||
General |
||||
------- |
||||
|
||||
- The majority of gRPC's C++ requirements are drawn from the [Google C++ style |
||||
guide] (https://google.github.io/styleguide/cppguide.html) |
||||
- However, gRPC has some additional requirements to maintain |
||||
[portability] (#portability) |
||||
- As in C, layout rules are defined by clang-format, and all code |
||||
should be passed through clang-format. A (docker-based) script to do |
||||
so is included in [tools/distrib/clang\_format\_code.sh] |
||||
(../tools/distrib/clang_format_code.sh). |
||||
|
||||
<a name="portability"></a> |
||||
Portability Restrictions |
||||
------------------- |
||||
|
||||
gRPC supports a large number of compilers, ranging from those that are |
||||
missing many key C++11 features to those that have quite detailed |
||||
analysis. As a result, gRPC compiles with a high level of warnings and |
||||
treat all warnings as errors. gRPC also forbids the use of some common |
||||
C++11 constructs. Here are some guidelines, to be extended as needed: |
||||
- Do not use range-based for. Expressions of the form |
||||
```c |
||||
for (auto& i: vec) { |
||||
// code |
||||
} |
||||
``` |
||||
|
||||
are not allowed and should be replaced with code such as |
||||
```c |
||||
for (auto it = vec.begin; it != vec.end(); it++) { |
||||
auto& i = *it; |
||||
// code |
||||
} |
||||
``` |
||||
|
||||
- Do not use lambda of any kind (no capture, explicit capture, or |
||||
default capture). Other C++ functional features such as |
||||
`std::function` or `std::bind` are allowed |
||||
- Do not use brace-list initializers. |
||||
- Do not compare a pointer to `nullptr` . This is because gcc 4.4 |
||||
does not support `nullptr` directly and gRPC implements a subset of |
||||
its features in [include/grpc++/impl/codegen/config.h] |
||||
(../include/grpc++/impl/codegen/config.h). Instead, pointers should |
||||
be checked for validity using their implicit conversion to `bool`. |
||||
In other words, use `if (p)` rather than `if (p != nullptr)` |
||||
- Do not initialize global/static pointer variables to `nullptr`. Just let |
||||
the compiler implicitly initialize them to `nullptr` (which it will |
||||
definitely do). The reason is that `nullptr` is an actual object in |
||||
our implementation rather than just a constant pointer value, so |
||||
static/global constructors will be called in a potentially |
||||
undesirable sequence. |
||||
- Do not use `final` or `override` as these are not supported by some |
||||
compilers. Instead use `GRPC_FINAL` and `GRPC_OVERRIDE` . These |
||||
compile down to the traditional C++ forms for compilers that support |
||||
them but are just elided if the compiler does not support those features. |
||||
- In the [include] (../../../tree/master/include/grpc++) and [src] |
||||
(../../../tree/master/src/cpp) directory trees, you should also not |
||||
use certain STL objects like `std::mutex`, `std::lock_guard`, |
||||
`std::unique_lock`, `std::nullptr`, `std::thread` . Instead, use |
||||
`grpc::mutex`, `grpc::lock_guard`, etc., which are gRPC |
||||
implementations of the prominent features of these objects that are |
||||
not always available. You can use the `std` versions of those in [test] |
||||
(../../../tree/master/test/cpp) |
||||
- Similarly, in the same directories, do not use `std::chrono` unless |
||||
it is guarded by `#ifndef GRPC_CXX0X_NO_CHRONO` . For platforms that |
||||
lack`std::chrono,` there is a C-language timer called gpr_timespec that can |
||||
be used instead. |
||||
- `std::unique_ptr` must be used with extreme care in any kind of |
||||
collection. For example `vector<std::unique_ptr>` does not work in |
||||
gcc 4.4 if the vector is constructed to its full size at |
||||
initialization but does work if elements are added to the vector |
||||
using functions like `push_back`. `map` and other pair-based |
||||
collections do not work with `unique_ptr` under gcc 4.4. The issue |
||||
is that many of these collection implementations assume a copy |
||||
constructor |
||||
to be available. |
||||
- Don't use `std::this_thread` . Use `gpr_sleep_until` for sleeping a thread. |
||||
- [Some adjacent character combinations cause problems] |
||||
(https://en.wikipedia.org/wiki/Digraphs_and_trigraphs#C). If declaring a |
||||
template against some class relative to the global namespace, |
||||
`<::name` will be non-portable. Separate the `<` from the `:` and use `< ::name`. |
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,57 @@ |
||||
/*
|
||||
* |
||||
* Copyright 2016, Google Inc. |
||||
* All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or without |
||||
* modification, are permitted provided that the following conditions are |
||||
* met: |
||||
* |
||||
* * Redistributions of source code must retain the above copyright |
||||
* notice, this list of conditions and the following disclaimer. |
||||
* * Redistributions in binary form must reproduce the above |
||||
* copyright notice, this list of conditions and the following disclaimer |
||||
* in the documentation and/or other materials provided with the |
||||
* distribution. |
||||
* * Neither the name of Google Inc. nor the names of its |
||||
* contributors may be used to endorse or promote products derived from |
||||
* this software without specific prior written permission. |
||||
* |
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||
* |
||||
*/ |
||||
|
||||
#ifndef GRPCXX_CREATE_CHANNEL_POSIX_H |
||||
#define GRPCXX_CREATE_CHANNEL_POSIX_H |
||||
|
||||
#include <memory> |
||||
|
||||
#include <grpc++/channel.h> |
||||
#include <grpc/support/port_platform.h> |
||||
|
||||
namespace grpc { |
||||
|
||||
#ifdef GPR_SUPPORT_CHANNELS_FROM_FD |
||||
|
||||
/// Create a new \a Channel communicating over given file descriptor
|
||||
///
|
||||
/// \param target The name of the target.
|
||||
/// \param fd The file descriptor representing a socket.
|
||||
std::shared_ptr<Channel> CreateInsecureChannelFromFd(const grpc::string& target, |
||||
int fd); |
||||
|
||||
#endif // GPR_SUPPORT_CHANNELS_FROM_FD
|
||||
|
||||
} // namespace grpc
|
||||
|
||||
#endif // GRPCXX_CREATE_CHANNEL_POSIX_H
|
@ -0,0 +1,69 @@ |
||||
/*
|
||||
* |
||||
* Copyright 2015, Google Inc. |
||||
* All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or without |
||||
* modification, are permitted provided that the following conditions are |
||||
* met: |
||||
* |
||||
* * Redistributions of source code must retain the above copyright |
||||
* notice, this list of conditions and the following disclaimer. |
||||
* * Redistributions in binary form must reproduce the above |
||||
* copyright notice, this list of conditions and the following disclaimer |
||||
* in the documentation and/or other materials provided with the |
||||
* distribution. |
||||
* * Neither the name of Google Inc. nor the names of its |
||||
* contributors may be used to endorse or promote products derived from |
||||
* this software without specific prior written permission. |
||||
* |
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||
* |
||||
*/ |
||||
|
||||
#ifndef GRPCXX_EXT_PROTO_SERVER_REFLECTION_PLUGIN_H |
||||
#define GRPCXX_EXT_PROTO_SERVER_REFLECTION_PLUGIN_H |
||||
|
||||
#include <grpc++/impl/server_builder_plugin.h> |
||||
#include <grpc++/support/config.h> |
||||
|
||||
namespace grpc { |
||||
class ServerInitializer; |
||||
class ProtoServerReflection; |
||||
} // namespace grpc
|
||||
|
||||
namespace grpc { |
||||
namespace reflection { |
||||
|
||||
class ProtoServerReflectionPlugin : public ::grpc::ServerBuilderPlugin { |
||||
public: |
||||
ProtoServerReflectionPlugin(); |
||||
::grpc::string name() GRPC_OVERRIDE; |
||||
void InitServer(::grpc::ServerInitializer* si) GRPC_OVERRIDE; |
||||
void Finish(::grpc::ServerInitializer* si) GRPC_OVERRIDE; |
||||
void ChangeArguments(const ::grpc::string& name, void* value) GRPC_OVERRIDE; |
||||
bool has_async_methods() const GRPC_OVERRIDE; |
||||
bool has_sync_methods() const GRPC_OVERRIDE; |
||||
|
||||
private: |
||||
std::shared_ptr<grpc::ProtoServerReflection> reflection_service_; |
||||
}; |
||||
|
||||
// Add proto reflection plugin to ServerBuilder. This function should be called
|
||||
// at the static initialization time.
|
||||
void InitProtoReflectionServerBuilderPlugin(); |
||||
|
||||
} // namespace reflection
|
||||
} // namespace grpc
|
||||
|
||||
#endif // GRPCXX_EXT_PROTO_SERVER_REFLECTION_PLUGIN_H
|
@ -0,0 +1,184 @@ |
||||
/*
|
||||
* |
||||
* Copyright 2015, Google Inc. |
||||
* All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or without |
||||
* modification, are permitted provided that the following conditions are |
||||
* met: |
||||
* |
||||
* * Redistributions of source code must retain the above copyright |
||||
* notice, this list of conditions and the following disclaimer. |
||||
* * Redistributions in binary form must reproduce the above |
||||
* copyright notice, this list of conditions and the following disclaimer |
||||
* in the documentation and/or other materials provided with the |
||||
* distribution. |
||||
* * Neither the name of Google Inc. nor the names of its |
||||
* contributors may be used to endorse or promote products derived from |
||||
* this software without specific prior written permission. |
||||
* |
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||
* |
||||
*/ |
||||
|
||||
|
||||
// Generated by the gRPC protobuf plugin.
|
||||
// If you make any local change, they will be lost.
|
||||
// source: reflection.proto
|
||||
// Original file comments:
|
||||
// Copyright 2016, Google Inc.
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Service exported by server reflection
|
||||
//
|
||||
#ifndef GRPC_reflection_2eproto__INCLUDED |
||||
#define GRPC_reflection_2eproto__INCLUDED |
||||
|
||||
#include <grpc++/ext/reflection.pb.h> |
||||
|
||||
#include <grpc++/impl/codegen/async_stream.h> |
||||
#include <grpc++/impl/codegen/async_unary_call.h> |
||||
#include <grpc++/impl/codegen/proto_utils.h> |
||||
#include <grpc++/impl/codegen/rpc_method.h> |
||||
#include <grpc++/impl/codegen/service_type.h> |
||||
#include <grpc++/impl/codegen/status.h> |
||||
#include <grpc++/impl/codegen/stub_options.h> |
||||
#include <grpc++/impl/codegen/sync_stream.h> |
||||
|
||||
namespace grpc { |
||||
class CompletionQueue; |
||||
class Channel; |
||||
class RpcService; |
||||
class ServerCompletionQueue; |
||||
class ServerContext; |
||||
} // namespace grpc
|
||||
|
||||
namespace grpc { |
||||
namespace reflection { |
||||
namespace v1alpha { |
||||
|
||||
class ServerReflection GRPC_FINAL { |
||||
public: |
||||
class StubInterface { |
||||
public: |
||||
virtual ~StubInterface() {} |
||||
// The reflection service is structured as a bidirectional stream, ensuring
|
||||
// all related requests go to a single server.
|
||||
std::unique_ptr< ::grpc::ClientReaderWriterInterface< ::grpc::reflection::v1alpha::ServerReflectionRequest, ::grpc::reflection::v1alpha::ServerReflectionResponse>> ServerReflectionInfo(::grpc::ClientContext* context) { |
||||
return std::unique_ptr< ::grpc::ClientReaderWriterInterface< ::grpc::reflection::v1alpha::ServerReflectionRequest, ::grpc::reflection::v1alpha::ServerReflectionResponse>>(ServerReflectionInfoRaw(context)); |
||||
} |
||||
std::unique_ptr< ::grpc::ClientAsyncReaderWriterInterface< ::grpc::reflection::v1alpha::ServerReflectionRequest, ::grpc::reflection::v1alpha::ServerReflectionResponse>> AsyncServerReflectionInfo(::grpc::ClientContext* context, ::grpc::CompletionQueue* cq, void* tag) { |
||||
return std::unique_ptr< ::grpc::ClientAsyncReaderWriterInterface< ::grpc::reflection::v1alpha::ServerReflectionRequest, ::grpc::reflection::v1alpha::ServerReflectionResponse>>(AsyncServerReflectionInfoRaw(context, cq, tag)); |
||||
} |
||||
private: |
||||
virtual ::grpc::ClientReaderWriterInterface< ::grpc::reflection::v1alpha::ServerReflectionRequest, ::grpc::reflection::v1alpha::ServerReflectionResponse>* ServerReflectionInfoRaw(::grpc::ClientContext* context) = 0; |
||||
virtual ::grpc::ClientAsyncReaderWriterInterface< ::grpc::reflection::v1alpha::ServerReflectionRequest, ::grpc::reflection::v1alpha::ServerReflectionResponse>* AsyncServerReflectionInfoRaw(::grpc::ClientContext* context, ::grpc::CompletionQueue* cq, void* tag) = 0; |
||||
}; |
||||
class Stub GRPC_FINAL : public StubInterface { |
||||
public: |
||||
Stub(const std::shared_ptr< ::grpc::ChannelInterface>& channel); |
||||
std::unique_ptr< ::grpc::ClientReaderWriter< ::grpc::reflection::v1alpha::ServerReflectionRequest, ::grpc::reflection::v1alpha::ServerReflectionResponse>> ServerReflectionInfo(::grpc::ClientContext* context) { |
||||
return std::unique_ptr< ::grpc::ClientReaderWriter< ::grpc::reflection::v1alpha::ServerReflectionRequest, ::grpc::reflection::v1alpha::ServerReflectionResponse>>(ServerReflectionInfoRaw(context)); |
||||
} |
||||
std::unique_ptr< ::grpc::ClientAsyncReaderWriter< ::grpc::reflection::v1alpha::ServerReflectionRequest, ::grpc::reflection::v1alpha::ServerReflectionResponse>> AsyncServerReflectionInfo(::grpc::ClientContext* context, ::grpc::CompletionQueue* cq, void* tag) { |
||||
return std::unique_ptr< ::grpc::ClientAsyncReaderWriter< ::grpc::reflection::v1alpha::ServerReflectionRequest, ::grpc::reflection::v1alpha::ServerReflectionResponse>>(AsyncServerReflectionInfoRaw(context, cq, tag)); |
||||
} |
||||
|
||||
private: |
||||
std::shared_ptr< ::grpc::ChannelInterface> channel_; |
||||
::grpc::ClientReaderWriter< ::grpc::reflection::v1alpha::ServerReflectionRequest, ::grpc::reflection::v1alpha::ServerReflectionResponse>* ServerReflectionInfoRaw(::grpc::ClientContext* context) GRPC_OVERRIDE; |
||||
::grpc::ClientAsyncReaderWriter< ::grpc::reflection::v1alpha::ServerReflectionRequest, ::grpc::reflection::v1alpha::ServerReflectionResponse>* AsyncServerReflectionInfoRaw(::grpc::ClientContext* context, ::grpc::CompletionQueue* cq, void* tag) GRPC_OVERRIDE; |
||||
const ::grpc::RpcMethod rpcmethod_ServerReflectionInfo_; |
||||
}; |
||||
static std::unique_ptr<Stub> NewStub(const std::shared_ptr< ::grpc::ChannelInterface>& channel, const ::grpc::StubOptions& options = ::grpc::StubOptions()); |
||||
|
||||
class Service : public ::grpc::Service { |
||||
public: |
||||
Service(); |
||||
virtual ~Service(); |
||||
// The reflection service is structured as a bidirectional stream, ensuring
|
||||
// all related requests go to a single server.
|
||||
virtual ::grpc::Status ServerReflectionInfo(::grpc::ServerContext* context, ::grpc::ServerReaderWriter< ::grpc::reflection::v1alpha::ServerReflectionResponse, ::grpc::reflection::v1alpha::ServerReflectionRequest>* stream); |
||||
}; |
||||
template <class BaseClass> |
||||
class WithAsyncMethod_ServerReflectionInfo : public BaseClass { |
||||
private: |
||||
void BaseClassMustBeDerivedFromService(const Service *service) {} |
||||
public: |
||||
WithAsyncMethod_ServerReflectionInfo() { |
||||
::grpc::Service::MarkMethodAsync(0); |
||||
} |
||||
~WithAsyncMethod_ServerReflectionInfo() GRPC_OVERRIDE { |
||||
BaseClassMustBeDerivedFromService(this); |
||||
} |
||||
// disable synchronous version of this method
|
||||
::grpc::Status ServerReflectionInfo(::grpc::ServerContext* context, ::grpc::ServerReaderWriter< ::grpc::reflection::v1alpha::ServerReflectionResponse, ::grpc::reflection::v1alpha::ServerReflectionRequest>* stream) GRPC_FINAL GRPC_OVERRIDE { |
||||
abort(); |
||||
return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); |
||||
} |
||||
void RequestServerReflectionInfo(::grpc::ServerContext* context, ::grpc::ServerAsyncReaderWriter< ::grpc::reflection::v1alpha::ServerReflectionResponse, ::grpc::reflection::v1alpha::ServerReflectionRequest>* stream, ::grpc::CompletionQueue* new_call_cq, ::grpc::ServerCompletionQueue* notification_cq, void *tag) { |
||||
::grpc::Service::RequestAsyncBidiStreaming(0, context, stream, new_call_cq, notification_cq, tag); |
||||
} |
||||
}; |
||||
typedef WithAsyncMethod_ServerReflectionInfo<Service > AsyncService; |
||||
template <class BaseClass> |
||||
class WithGenericMethod_ServerReflectionInfo : public BaseClass { |
||||
private: |
||||
void BaseClassMustBeDerivedFromService(const Service *service) {} |
||||
public: |
||||
WithGenericMethod_ServerReflectionInfo() { |
||||
::grpc::Service::MarkMethodGeneric(0); |
||||
} |
||||
~WithGenericMethod_ServerReflectionInfo() GRPC_OVERRIDE { |
||||
BaseClassMustBeDerivedFromService(this); |
||||
} |
||||
// disable synchronous version of this method
|
||||
::grpc::Status ServerReflectionInfo(::grpc::ServerContext* context, ::grpc::ServerReaderWriter< ::grpc::reflection::v1alpha::ServerReflectionResponse, ::grpc::reflection::v1alpha::ServerReflectionRequest>* stream) GRPC_FINAL GRPC_OVERRIDE { |
||||
abort(); |
||||
return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); |
||||
} |
||||
}; |
||||
}; |
||||
|
||||
} // namespace v1alpha
|
||||
} // namespace reflection
|
||||
} // namespace grpc
|
||||
|
||||
|
||||
#endif // GRPC_reflection_2eproto__INCLUDED
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,56 @@ |
||||
/*
|
||||
* |
||||
* Copyright 2016, Google Inc. |
||||
* All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or without |
||||
* modification, are permitted provided that the following conditions are |
||||
* met: |
||||
* |
||||
* * Redistributions of source code must retain the above copyright |
||||
* notice, this list of conditions and the following disclaimer. |
||||
* * Redistributions in binary form must reproduce the above |
||||
* copyright notice, this list of conditions and the following disclaimer |
||||
* in the documentation and/or other materials provided with the |
||||
* distribution. |
||||
* * Neither the name of Google Inc. nor the names of its |
||||
* contributors may be used to endorse or promote products derived from |
||||
* this software without specific prior written permission. |
||||
* |
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||
* |
||||
*/ |
||||
|
||||
#ifndef GRPCXX_SERVER_POSIX_H |
||||
#define GRPCXX_SERVER_POSIX_H |
||||
|
||||
#include <memory> |
||||
|
||||
#include <grpc++/server.h> |
||||
#include <grpc/support/port_platform.h> |
||||
|
||||
namespace grpc { |
||||
|
||||
#ifdef GPR_SUPPORT_CHANNELS_FROM_FD |
||||
|
||||
/// Adds new client to a \a Server communicating over given file descriptor
|
||||
///
|
||||
/// \param server The server to add a client to.
|
||||
/// \param fd The file descriptor representing a socket.
|
||||
void AddInsecureChannelFromFd(Server* server, int fd); |
||||
|
||||
#endif // GPR_SUPPORT_CHANNELS_FROM_FD
|
||||
|
||||
} // namespace grpc
|
||||
|
||||
#endif // GRPCXX_SERVER_POSIX_H
|
@ -0,0 +1,70 @@ |
||||
/*
|
||||
* |
||||
* Copyright 2016, Google Inc. |
||||
* All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or without |
||||
* modification, are permitted provided that the following conditions are |
||||
* met: |
||||
* |
||||
* * Redistributions of source code must retain the above copyright |
||||
* notice, this list of conditions and the following disclaimer. |
||||
* * Redistributions in binary form must reproduce the above |
||||
* copyright notice, this list of conditions and the following disclaimer |
||||
* in the documentation and/or other materials provided with the |
||||
* distribution. |
||||
* * Neither the name of Google Inc. nor the names of its |
||||
* contributors may be used to endorse or promote products derived from |
||||
* this software without specific prior written permission. |
||||
* |
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||
* |
||||
*/ |
||||
|
||||
#ifndef GRPC_GRPC_POSIX_H |
||||
#define GRPC_GRPC_POSIX_H |
||||
|
||||
#include <grpc/impl/codegen/grpc_types.h> |
||||
#include <grpc/support/port_platform.h> |
||||
|
||||
#include <stddef.h> |
||||
|
||||
#ifdef __cplusplus |
||||
extern "C" { |
||||
#endif |
||||
|
||||
/*! \mainpage GRPC Core POSIX
|
||||
* |
||||
* The GRPC Core POSIX library provides some POSIX-specific low-level |
||||
* functionality on top of GRPC Core. |
||||
*/ |
||||
|
||||
/** Create a client channel to 'target' using file descriptor 'fd'. The 'target'
|
||||
argument will be used to indicate the name for this channel. See the comment |
||||
for grpc_insecure_channel_create for description of 'args' argument. */ |
||||
GRPCAPI grpc_channel *grpc_insecure_channel_create_from_fd( |
||||
const char *target, int fd, const grpc_channel_args *args); |
||||
|
||||
/** Add the connected communication channel based on file descriptor 'fd' to the
|
||||
'server'. The 'fd' must be an open file descriptor corresponding to a |
||||
connected socket. The 'cq' is a completion queue that will be getting events |
||||
from that descriptor. */ |
||||
GRPCAPI void grpc_server_add_insecure_channel_from_fd(grpc_server *server, |
||||
grpc_completion_queue *cq, |
||||
int fd); |
||||
|
||||
#ifdef __cplusplus |
||||
} |
||||
#endif |
||||
|
||||
#endif /* GRPC_GRPC_POSIX_H */ |
@ -0,0 +1,6 @@ |
||||
Files generated for use by Census stats and trace recording subsystem. |
||||
|
||||
#Files |
||||
* census.pb.{h,c} - Generated from src/core/ext/census/census.proto, using the |
||||
script `tools/codegen/core/gen_nano_proto.sh src/proto/census/census.proto |
||||
$PWD/src/core/ext/census/gen src/core/ext/census/gen` |
@ -0,0 +1,179 @@ |
||||
/*
|
||||
* |
||||
* Copyright 2016, Google Inc. |
||||
* All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or without |
||||
* modification, are permitted provided that the following conditions are |
||||
* met: |
||||
* |
||||
* * Redistributions of source code must retain the above copyright |
||||
* notice, this list of conditions and the following disclaimer. |
||||
* * Redistributions in binary form must reproduce the above |
||||
* copyright notice, this list of conditions and the following disclaimer |
||||
* in the documentation and/or other materials provided with the |
||||
* distribution. |
||||
* * Neither the name of Google Inc. nor the names of its |
||||
* contributors may be used to endorse or promote products derived from |
||||
* this software without specific prior written permission. |
||||
* |
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||
* |
||||
*/ |
||||
/* Automatically generated nanopb constant definitions */ |
||||
/* Generated by nanopb-0.3.5-dev */ |
||||
|
||||
#include "src/core/ext/census/gen/census.pb.h" |
||||
|
||||
#if PB_PROTO_HEADER_VERSION != 30 |
||||
#error Regenerate this file with the current version of nanopb generator. |
||||
#endif |
||||
|
||||
|
||||
|
||||
const pb_field_t google_census_Duration_fields[3] = { |
||||
PB_FIELD( 1, INT64 , OPTIONAL, STATIC , FIRST, google_census_Duration, seconds, seconds, 0), |
||||
PB_FIELD( 2, INT32 , OPTIONAL, STATIC , OTHER, google_census_Duration, nanos, seconds, 0), |
||||
PB_LAST_FIELD |
||||
}; |
||||
|
||||
const pb_field_t google_census_Timestamp_fields[3] = { |
||||
PB_FIELD( 1, INT64 , OPTIONAL, STATIC , FIRST, google_census_Timestamp, seconds, seconds, 0), |
||||
PB_FIELD( 2, INT32 , OPTIONAL, STATIC , OTHER, google_census_Timestamp, nanos, seconds, 0), |
||||
PB_LAST_FIELD |
||||
}; |
||||
|
||||
const pb_field_t google_census_Metric_fields[5] = { |
||||
PB_FIELD( 1, STRING , OPTIONAL, CALLBACK, FIRST, google_census_Metric, name, name, 0), |
||||
PB_FIELD( 2, STRING , OPTIONAL, CALLBACK, OTHER, google_census_Metric, description, name, 0), |
||||
PB_FIELD( 3, MESSAGE , OPTIONAL, STATIC , OTHER, google_census_Metric, unit, description, &google_census_Metric_MeasurementUnit_fields), |
||||
PB_FIELD( 4, INT32 , OPTIONAL, STATIC , OTHER, google_census_Metric, id, unit, 0), |
||||
PB_LAST_FIELD |
||||
}; |
||||
|
||||
const pb_field_t google_census_Metric_BasicUnit_fields[2] = { |
||||
PB_FIELD( 1, UENUM , OPTIONAL, STATIC , FIRST, google_census_Metric_BasicUnit, type, type, 0), |
||||
PB_LAST_FIELD |
||||
}; |
||||
|
||||
const pb_field_t google_census_Metric_MeasurementUnit_fields[4] = { |
||||
PB_FIELD( 1, INT32 , OPTIONAL, STATIC , FIRST, google_census_Metric_MeasurementUnit, prefix, prefix, 0), |
||||
PB_FIELD( 2, MESSAGE , REPEATED, CALLBACK, OTHER, google_census_Metric_MeasurementUnit, numerator, prefix, &google_census_Metric_BasicUnit_fields), |
||||
PB_FIELD( 3, MESSAGE , REPEATED, CALLBACK, OTHER, google_census_Metric_MeasurementUnit, denominator, numerator, &google_census_Metric_BasicUnit_fields), |
||||
PB_LAST_FIELD |
||||
}; |
||||
|
||||
const pb_field_t google_census_AggregationDescriptor_fields[3] = { |
||||
PB_ONEOF_FIELD(options, 1, MESSAGE , ONEOF, STATIC , FIRST, google_census_AggregationDescriptor, bucket_boundaries, bucket_boundaries, &google_census_AggregationDescriptor_BucketBoundaries_fields), |
||||
PB_ONEOF_FIELD(options, 2, MESSAGE , ONEOF, STATIC , FIRST, google_census_AggregationDescriptor, interval_boundaries, interval_boundaries, &google_census_AggregationDescriptor_IntervalBoundaries_fields), |
||||
PB_LAST_FIELD |
||||
}; |
||||
|
||||
const pb_field_t google_census_AggregationDescriptor_BucketBoundaries_fields[2] = { |
||||
PB_FIELD( 1, DOUBLE , REPEATED, CALLBACK, FIRST, google_census_AggregationDescriptor_BucketBoundaries, bounds, bounds, 0), |
||||
PB_LAST_FIELD |
||||
}; |
||||
|
||||
const pb_field_t google_census_AggregationDescriptor_IntervalBoundaries_fields[2] = { |
||||
PB_FIELD( 1, DOUBLE , REPEATED, CALLBACK, FIRST, google_census_AggregationDescriptor_IntervalBoundaries, window_size, window_size, 0), |
||||
PB_LAST_FIELD |
||||
}; |
||||
|
||||
const pb_field_t google_census_Distribution_fields[5] = { |
||||
PB_FIELD( 1, INT64 , OPTIONAL, STATIC , FIRST, google_census_Distribution, count, count, 0), |
||||
PB_FIELD( 2, DOUBLE , OPTIONAL, STATIC , OTHER, google_census_Distribution, mean, count, 0), |
||||
PB_FIELD( 3, MESSAGE , OPTIONAL, STATIC , OTHER, google_census_Distribution, range, mean, &google_census_Distribution_Range_fields), |
||||
PB_FIELD( 4, INT64 , REPEATED, CALLBACK, OTHER, google_census_Distribution, bucket_count, range, 0), |
||||
PB_LAST_FIELD |
||||
}; |
||||
|
||||
const pb_field_t google_census_Distribution_Range_fields[3] = { |
||||
PB_FIELD( 1, DOUBLE , OPTIONAL, STATIC , FIRST, google_census_Distribution_Range, min, min, 0), |
||||
PB_FIELD( 2, DOUBLE , OPTIONAL, STATIC , OTHER, google_census_Distribution_Range, max, min, 0), |
||||
PB_LAST_FIELD |
||||
}; |
||||
|
||||
const pb_field_t google_census_IntervalStats_fields[2] = { |
||||
PB_FIELD( 1, MESSAGE , REPEATED, CALLBACK, FIRST, google_census_IntervalStats, window, window, &google_census_IntervalStats_Window_fields), |
||||
PB_LAST_FIELD |
||||
}; |
||||
|
||||
const pb_field_t google_census_IntervalStats_Window_fields[4] = { |
||||
PB_FIELD( 1, MESSAGE , OPTIONAL, STATIC , FIRST, google_census_IntervalStats_Window, window_size, window_size, &google_census_Duration_fields), |
||||
PB_FIELD( 2, INT64 , OPTIONAL, STATIC , OTHER, google_census_IntervalStats_Window, count, window_size, 0), |
||||
PB_FIELD( 3, DOUBLE , OPTIONAL, STATIC , OTHER, google_census_IntervalStats_Window, mean, count, 0), |
||||
PB_LAST_FIELD |
||||
}; |
||||
|
||||
const pb_field_t google_census_Tag_fields[3] = { |
||||
PB_FIELD( 1, STRING , OPTIONAL, STATIC , FIRST, google_census_Tag, key, key, 0), |
||||
PB_FIELD( 2, STRING , OPTIONAL, STATIC , OTHER, google_census_Tag, value, key, 0), |
||||
PB_LAST_FIELD |
||||
}; |
||||
|
||||
const pb_field_t google_census_View_fields[6] = { |
||||
PB_FIELD( 1, STRING , OPTIONAL, CALLBACK, FIRST, google_census_View, name, name, 0), |
||||
PB_FIELD( 2, STRING , OPTIONAL, CALLBACK, OTHER, google_census_View, description, name, 0), |
||||
PB_FIELD( 3, INT32 , OPTIONAL, STATIC , OTHER, google_census_View, metric_id, description, 0), |
||||
PB_FIELD( 4, MESSAGE , OPTIONAL, STATIC , OTHER, google_census_View, aggregation, metric_id, &google_census_AggregationDescriptor_fields), |
||||
PB_FIELD( 5, STRING , REPEATED, CALLBACK, OTHER, google_census_View, tag_key, aggregation, 0), |
||||
PB_LAST_FIELD |
||||
}; |
||||
|
||||
const pb_field_t google_census_Aggregation_fields[6] = { |
||||
PB_FIELD( 1, STRING , OPTIONAL, CALLBACK, FIRST, google_census_Aggregation, name, name, 0), |
||||
PB_FIELD( 2, STRING , OPTIONAL, CALLBACK, OTHER, google_census_Aggregation, description, name, 0), |
||||
PB_ONEOF_FIELD(data, 3, MESSAGE , ONEOF, STATIC , OTHER, google_census_Aggregation, distribution, description, &google_census_Distribution_fields), |
||||
PB_ONEOF_FIELD(data, 4, MESSAGE , ONEOF, STATIC , OTHER, google_census_Aggregation, interval_stats, description, &google_census_IntervalStats_fields), |
||||
PB_FIELD( 5, MESSAGE , REPEATED, CALLBACK, OTHER, google_census_Aggregation, tag, data.interval_stats, &google_census_Tag_fields), |
||||
PB_LAST_FIELD |
||||
}; |
||||
|
||||
const pb_field_t google_census_ViewAggregations_fields[4] = { |
||||
PB_FIELD( 1, MESSAGE , REPEATED, CALLBACK, FIRST, google_census_ViewAggregations, aggregation, aggregation, &google_census_Aggregation_fields), |
||||
PB_FIELD( 2, MESSAGE , OPTIONAL, STATIC , OTHER, google_census_ViewAggregations, start, aggregation, &google_census_Timestamp_fields), |
||||
PB_FIELD( 3, MESSAGE , OPTIONAL, STATIC , OTHER, google_census_ViewAggregations, end, start, &google_census_Timestamp_fields), |
||||
PB_LAST_FIELD |
||||
}; |
||||
|
||||
|
||||
/* Check that field information fits in pb_field_t */ |
||||
#if !defined(PB_FIELD_32BIT) |
||||
/* If you get an error here, it means that you need to define PB_FIELD_32BIT
|
||||
* compile-time option. You can do that in pb.h or on compiler command line. |
||||
*
|
||||
* The reason you need to do this is that some of your messages contain tag |
||||
* numbers or field sizes that are larger than what can fit in 8 or 16 bit |
||||
* field descriptors. |
||||
*/ |
||||
PB_STATIC_ASSERT((pb_membersize(google_census_Metric, unit) < 65536 && pb_membersize(google_census_Metric_MeasurementUnit, numerator) < 65536 && pb_membersize(google_census_Metric_MeasurementUnit, denominator) < 65536 && pb_membersize(google_census_AggregationDescriptor, options.bucket_boundaries) < 65536 && pb_membersize(google_census_AggregationDescriptor, options.interval_boundaries) < 65536 && pb_membersize(google_census_Metric, unit) < 65536 && pb_membersize(google_census_Metric_MeasurementUnit, numerator) < 65536 && pb_membersize(google_census_Metric_MeasurementUnit, denominator) < 65536 && pb_membersize(google_census_AggregationDescriptor, options.bucket_boundaries) < 65536 && pb_membersize(google_census_AggregationDescriptor, options.interval_boundaries) < 65536 && pb_membersize(google_census_Distribution, range) < 65536 && pb_membersize(google_census_IntervalStats, window) < 65536 && pb_membersize(google_census_IntervalStats_Window, window_size) < 65536 && pb_membersize(google_census_View, aggregation) < 65536 && pb_membersize(google_census_Aggregation, data.distribution) < 65536 && pb_membersize(google_census_Aggregation, data.interval_stats) < 65536 && pb_membersize(google_census_Metric, unit) < 65536 && pb_membersize(google_census_Metric_MeasurementUnit, numerator) < 65536 && pb_membersize(google_census_Metric_MeasurementUnit, denominator) < 65536 && pb_membersize(google_census_AggregationDescriptor, options.bucket_boundaries) < 65536 && pb_membersize(google_census_AggregationDescriptor, options.interval_boundaries) < 65536 && pb_membersize(google_census_Metric, unit) < 65536 && pb_membersize(google_census_Metric_MeasurementUnit, numerator) < 65536 && pb_membersize(google_census_Metric_MeasurementUnit, denominator) < 65536 && pb_membersize(google_census_AggregationDescriptor, options.bucket_boundaries) < 65536 && pb_membersize(google_census_AggregationDescriptor, options.interval_boundaries) < 65536 && pb_membersize(google_census_Distribution, range) < 65536 && pb_membersize(google_census_IntervalStats, window) < 65536 && pb_membersize(google_census_IntervalStats_Window, window_size) < 65536 && pb_membersize(google_census_View, aggregation) < 65536 && pb_membersize(google_census_Aggregation, data.distribution) < 65536 && pb_membersize(google_census_Aggregation, data.interval_stats) < 65536 && pb_membersize(google_census_Aggregation, tag) < 65536 && pb_membersize(google_census_ViewAggregations, aggregation) < 65536 && pb_membersize(google_census_ViewAggregations, start) < 65536 && pb_membersize(google_census_ViewAggregations, end) < 65536), YOU_MUST_DEFINE_PB_FIELD_32BIT_FOR_MESSAGES_google_census_Duration_google_census_Timestamp_google_census_Metric_google_census_Metric_BasicUnit_google_census_Metric_MeasurementUnit_google_census_AggregationDescriptor_google_census_AggregationDescriptor_BucketBoundaries_google_census_AggregationDescriptor_IntervalBoundaries_google_census_Distribution_google_census_Distribution_Range_google_census_IntervalStats_google_census_IntervalStats_Window_google_census_Tag_google_census_View_google_census_Aggregation_google_census_ViewAggregations) |
||||
#endif |
||||
|
||||
#if !defined(PB_FIELD_16BIT) && !defined(PB_FIELD_32BIT) |
||||
/* If you get an error here, it means that you need to define PB_FIELD_16BIT
|
||||
* compile-time option. You can do that in pb.h or on compiler command line. |
||||
*
|
||||
* The reason you need to do this is that some of your messages contain tag |
||||
* numbers or field sizes that are larger than what can fit in the default |
||||
* 8 bit descriptors. |
||||
*/ |
||||
PB_STATIC_ASSERT((pb_membersize(google_census_Metric, unit) < 256 && pb_membersize(google_census_Metric_MeasurementUnit, numerator) < 256 && pb_membersize(google_census_Metric_MeasurementUnit, denominator) < 256 && pb_membersize(google_census_AggregationDescriptor, options.bucket_boundaries) < 256 && pb_membersize(google_census_AggregationDescriptor, options.interval_boundaries) < 256 && pb_membersize(google_census_Metric, unit) < 256 && pb_membersize(google_census_Metric_MeasurementUnit, numerator) < 256 && pb_membersize(google_census_Metric_MeasurementUnit, denominator) < 256 && pb_membersize(google_census_AggregationDescriptor, options.bucket_boundaries) < 256 && pb_membersize(google_census_AggregationDescriptor, options.interval_boundaries) < 256 && pb_membersize(google_census_Distribution, range) < 256 && pb_membersize(google_census_IntervalStats, window) < 256 && pb_membersize(google_census_IntervalStats_Window, window_size) < 256 && pb_membersize(google_census_View, aggregation) < 256 && pb_membersize(google_census_Aggregation, data.distribution) < 256 && pb_membersize(google_census_Aggregation, data.interval_stats) < 256 && pb_membersize(google_census_Metric, unit) < 256 && pb_membersize(google_census_Metric_MeasurementUnit, numerator) < 256 && pb_membersize(google_census_Metric_MeasurementUnit, denominator) < 256 && pb_membersize(google_census_AggregationDescriptor, options.bucket_boundaries) < 256 && pb_membersize(google_census_AggregationDescriptor, options.interval_boundaries) < 256 && pb_membersize(google_census_Metric, unit) < 256 && pb_membersize(google_census_Metric_MeasurementUnit, numerator) < 256 && pb_membersize(google_census_Metric_MeasurementUnit, denominator) < 256 && pb_membersize(google_census_AggregationDescriptor, options.bucket_boundaries) < 256 && pb_membersize(google_census_AggregationDescriptor, options.interval_boundaries) < 256 && pb_membersize(google_census_Distribution, range) < 256 && pb_membersize(google_census_IntervalStats, window) < 256 && pb_membersize(google_census_IntervalStats_Window, window_size) < 256 && pb_membersize(google_census_View, aggregation) < 256 && pb_membersize(google_census_Aggregation, data.distribution) < 256 && pb_membersize(google_census_Aggregation, data.interval_stats) < 256 && pb_membersize(google_census_Aggregation, tag) < 256 && pb_membersize(google_census_ViewAggregations, aggregation) < 256 && pb_membersize(google_census_ViewAggregations, start) < 256 && pb_membersize(google_census_ViewAggregations, end) < 256), YOU_MUST_DEFINE_PB_FIELD_16BIT_FOR_MESSAGES_google_census_Duration_google_census_Timestamp_google_census_Metric_google_census_Metric_BasicUnit_google_census_Metric_MeasurementUnit_google_census_AggregationDescriptor_google_census_AggregationDescriptor_BucketBoundaries_google_census_AggregationDescriptor_IntervalBoundaries_google_census_Distribution_google_census_Distribution_Range_google_census_IntervalStats_google_census_IntervalStats_Window_google_census_Tag_google_census_View_google_census_Aggregation_google_census_ViewAggregations) |
||||
#endif |
||||
|
||||
|
||||
/* On some platforms (such as AVR), double is really float.
|
||||
* These are not directly supported by nanopb, but see example_avr_double. |
||||
* To get rid of this error, remove any double fields from your .proto. |
||||
*/ |
||||
PB_STATIC_ASSERT(sizeof(double) == 8, DOUBLE_MUST_BE_8_BYTES) |
||||
|
@ -0,0 +1,294 @@ |
||||
/*
|
||||
* |
||||
* Copyright 2016, Google Inc. |
||||
* All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or without |
||||
* modification, are permitted provided that the following conditions are |
||||
* met: |
||||
* |
||||
* * Redistributions of source code must retain the above copyright |
||||
* notice, this list of conditions and the following disclaimer. |
||||
* * Redistributions in binary form must reproduce the above |
||||
* copyright notice, this list of conditions and the following disclaimer |
||||
* in the documentation and/or other materials provided with the |
||||
* distribution. |
||||
* * Neither the name of Google Inc. nor the names of its |
||||
* contributors may be used to endorse or promote products derived from |
||||
* this software without specific prior written permission. |
||||
* |
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||
* |
||||
*/ |
||||
/* Automatically generated nanopb header */ |
||||
/* Generated by nanopb-0.3.5-dev */ |
||||
|
||||
#ifndef GRPC_CORE_EXT_CENSUS_GEN_CENSUS_PB_H |
||||
#define GRPC_CORE_EXT_CENSUS_GEN_CENSUS_PB_H |
||||
#include "third_party/nanopb/pb.h" |
||||
#if PB_PROTO_HEADER_VERSION != 30 |
||||
#error Regenerate this file with the current version of nanopb generator. |
||||
#endif |
||||
|
||||
#ifdef __cplusplus |
||||
extern "C" { |
||||
#endif |
||||
|
||||
/* Enum definitions */ |
||||
typedef enum _google_census_Metric_BasicUnit_Measure { |
||||
google_census_Metric_BasicUnit_Measure_UNKNOWN = 0, |
||||
google_census_Metric_BasicUnit_Measure_BITS = 1, |
||||
google_census_Metric_BasicUnit_Measure_BYTES = 2, |
||||
google_census_Metric_BasicUnit_Measure_SECS = 3, |
||||
google_census_Metric_BasicUnit_Measure_CORES = 4, |
||||
google_census_Metric_BasicUnit_Measure_MAX_UNITS = 5 |
||||
} google_census_Metric_BasicUnit_Measure; |
||||
|
||||
/* Struct definitions */ |
||||
typedef struct _google_census_AggregationDescriptor_BucketBoundaries { |
||||
pb_callback_t bounds; |
||||
} google_census_AggregationDescriptor_BucketBoundaries; |
||||
|
||||
typedef struct _google_census_AggregationDescriptor_IntervalBoundaries { |
||||
pb_callback_t window_size; |
||||
} google_census_AggregationDescriptor_IntervalBoundaries; |
||||
|
||||
typedef struct _google_census_IntervalStats { |
||||
pb_callback_t window; |
||||
} google_census_IntervalStats; |
||||
|
||||
typedef struct _google_census_AggregationDescriptor { |
||||
pb_size_t which_options; |
||||
union { |
||||
google_census_AggregationDescriptor_BucketBoundaries bucket_boundaries; |
||||
google_census_AggregationDescriptor_IntervalBoundaries interval_boundaries; |
||||
} options; |
||||
} google_census_AggregationDescriptor; |
||||
|
||||
typedef struct _google_census_Distribution_Range { |
||||
bool has_min; |
||||
double min; |
||||
bool has_max; |
||||
double max; |
||||
} google_census_Distribution_Range; |
||||
|
||||
typedef struct _google_census_Duration { |
||||
bool has_seconds; |
||||
int64_t seconds; |
||||
bool has_nanos; |
||||
int32_t nanos; |
||||
} google_census_Duration; |
||||
|
||||
typedef struct _google_census_Metric_BasicUnit { |
||||
bool has_type; |
||||
google_census_Metric_BasicUnit_Measure type; |
||||
} google_census_Metric_BasicUnit; |
||||
|
||||
typedef struct _google_census_Metric_MeasurementUnit { |
||||
bool has_prefix; |
||||
int32_t prefix; |
||||
pb_callback_t numerator; |
||||
pb_callback_t denominator; |
||||
} google_census_Metric_MeasurementUnit; |
||||
|
||||
typedef struct _google_census_Tag { |
||||
bool has_key; |
||||
char key[255]; |
||||
bool has_value; |
||||
char value[255]; |
||||
} google_census_Tag; |
||||
|
||||
typedef struct _google_census_Timestamp { |
||||
bool has_seconds; |
||||
int64_t seconds; |
||||
bool has_nanos; |
||||
int32_t nanos; |
||||
} google_census_Timestamp; |
||||
|
||||
typedef struct _google_census_Distribution { |
||||
bool has_count; |
||||
int64_t count; |
||||
bool has_mean; |
||||
double mean; |
||||
bool has_range; |
||||
google_census_Distribution_Range range; |
||||
pb_callback_t bucket_count; |
||||
} google_census_Distribution; |
||||
|
||||
typedef struct _google_census_IntervalStats_Window { |
||||
bool has_window_size; |
||||
google_census_Duration window_size; |
||||
bool has_count; |
||||
int64_t count; |
||||
bool has_mean; |
||||
double mean; |
||||
} google_census_IntervalStats_Window; |
||||
|
||||
typedef struct _google_census_Metric { |
||||
pb_callback_t name; |
||||
pb_callback_t description; |
||||
bool has_unit; |
||||
google_census_Metric_MeasurementUnit unit; |
||||
bool has_id; |
||||
int32_t id; |
||||
} google_census_Metric; |
||||
|
||||
typedef struct _google_census_View { |
||||
pb_callback_t name; |
||||
pb_callback_t description; |
||||
bool has_metric_id; |
||||
int32_t metric_id; |
||||
bool has_aggregation; |
||||
google_census_AggregationDescriptor aggregation; |
||||
pb_callback_t tag_key; |
||||
} google_census_View; |
||||
|
||||
typedef struct _google_census_ViewAggregations { |
||||
pb_callback_t aggregation; |
||||
bool has_start; |
||||
google_census_Timestamp start; |
||||
bool has_end; |
||||
google_census_Timestamp end; |
||||
} google_census_ViewAggregations; |
||||
|
||||
typedef struct _google_census_Aggregation { |
||||
pb_callback_t name; |
||||
pb_callback_t description; |
||||
pb_size_t which_data; |
||||
union { |
||||
google_census_Distribution distribution; |
||||
google_census_IntervalStats interval_stats; |
||||
} data; |
||||
pb_callback_t tag; |
||||
} google_census_Aggregation; |
||||
|
||||
/* Default values for struct fields */ |
||||
|
||||
/* Initializer values for message structs */ |
||||
#define google_census_Duration_init_default {false, 0, false, 0} |
||||
#define google_census_Timestamp_init_default {false, 0, false, 0} |
||||
#define google_census_Metric_init_default {{{NULL}, NULL}, {{NULL}, NULL}, false, google_census_Metric_MeasurementUnit_init_default, false, 0} |
||||
#define google_census_Metric_BasicUnit_init_default {false, (google_census_Metric_BasicUnit_Measure)0} |
||||
#define google_census_Metric_MeasurementUnit_init_default {false, 0, {{NULL}, NULL}, {{NULL}, NULL}} |
||||
#define google_census_AggregationDescriptor_init_default {0, {google_census_AggregationDescriptor_BucketBoundaries_init_default}} |
||||
#define google_census_AggregationDescriptor_BucketBoundaries_init_default {{{NULL}, NULL}} |
||||
#define google_census_AggregationDescriptor_IntervalBoundaries_init_default {{{NULL}, NULL}} |
||||
#define google_census_Distribution_init_default {false, 0, false, 0, false, google_census_Distribution_Range_init_default, {{NULL}, NULL}} |
||||
#define google_census_Distribution_Range_init_default {false, 0, false, 0} |
||||
#define google_census_IntervalStats_init_default {{{NULL}, NULL}} |
||||
#define google_census_IntervalStats_Window_init_default {false, google_census_Duration_init_default, false, 0, false, 0} |
||||
#define google_census_Tag_init_default {false, "", false, ""} |
||||
#define google_census_View_init_default {{{NULL}, NULL}, {{NULL}, NULL}, false, 0, false, google_census_AggregationDescriptor_init_default, {{NULL}, NULL}} |
||||
#define google_census_Aggregation_init_default {{{NULL}, NULL}, {{NULL}, NULL}, 0, {google_census_Distribution_init_default}, {{NULL}, NULL}} |
||||
#define google_census_ViewAggregations_init_default {{{NULL}, NULL}, false, google_census_Timestamp_init_default, false, google_census_Timestamp_init_default} |
||||
#define google_census_Duration_init_zero {false, 0, false, 0} |
||||
#define google_census_Timestamp_init_zero {false, 0, false, 0} |
||||
#define google_census_Metric_init_zero {{{NULL}, NULL}, {{NULL}, NULL}, false, google_census_Metric_MeasurementUnit_init_zero, false, 0} |
||||
#define google_census_Metric_BasicUnit_init_zero {false, (google_census_Metric_BasicUnit_Measure)0} |
||||
#define google_census_Metric_MeasurementUnit_init_zero {false, 0, {{NULL}, NULL}, {{NULL}, NULL}} |
||||
#define google_census_AggregationDescriptor_init_zero {0, {google_census_AggregationDescriptor_BucketBoundaries_init_zero}} |
||||
#define google_census_AggregationDescriptor_BucketBoundaries_init_zero {{{NULL}, NULL}} |
||||
#define google_census_AggregationDescriptor_IntervalBoundaries_init_zero {{{NULL}, NULL}} |
||||
#define google_census_Distribution_init_zero {false, 0, false, 0, false, google_census_Distribution_Range_init_zero, {{NULL}, NULL}} |
||||
#define google_census_Distribution_Range_init_zero {false, 0, false, 0} |
||||
#define google_census_IntervalStats_init_zero {{{NULL}, NULL}} |
||||
#define google_census_IntervalStats_Window_init_zero {false, google_census_Duration_init_zero, false, 0, false, 0} |
||||
#define google_census_Tag_init_zero {false, "", false, ""} |
||||
#define google_census_View_init_zero {{{NULL}, NULL}, {{NULL}, NULL}, false, 0, false, google_census_AggregationDescriptor_init_zero, {{NULL}, NULL}} |
||||
#define google_census_Aggregation_init_zero {{{NULL}, NULL}, {{NULL}, NULL}, 0, {google_census_Distribution_init_zero}, {{NULL}, NULL}} |
||||
#define google_census_ViewAggregations_init_zero {{{NULL}, NULL}, false, google_census_Timestamp_init_zero, false, google_census_Timestamp_init_zero} |
||||
|
||||
/* Field tags (for use in manual encoding/decoding) */ |
||||
#define google_census_AggregationDescriptor_BucketBoundaries_bounds_tag 1 |
||||
#define google_census_AggregationDescriptor_IntervalBoundaries_window_size_tag 1 |
||||
#define google_census_IntervalStats_window_tag 1 |
||||
#define google_census_AggregationDescriptor_bucket_boundaries_tag 1 |
||||
|
||||
#define google_census_AggregationDescriptor_interval_boundaries_tag 2 |
||||
#define google_census_Distribution_Range_min_tag 1 |
||||
#define google_census_Distribution_Range_max_tag 2 |
||||
#define google_census_Duration_seconds_tag 1 |
||||
#define google_census_Duration_nanos_tag 2 |
||||
#define google_census_Metric_BasicUnit_type_tag 1 |
||||
#define google_census_Metric_MeasurementUnit_prefix_tag 1 |
||||
#define google_census_Metric_MeasurementUnit_numerator_tag 2 |
||||
#define google_census_Metric_MeasurementUnit_denominator_tag 3 |
||||
#define google_census_Tag_key_tag 1 |
||||
#define google_census_Tag_value_tag 2 |
||||
#define google_census_Timestamp_seconds_tag 1 |
||||
#define google_census_Timestamp_nanos_tag 2 |
||||
#define google_census_Distribution_count_tag 1 |
||||
#define google_census_Distribution_mean_tag 2 |
||||
#define google_census_Distribution_range_tag 3 |
||||
#define google_census_Distribution_bucket_count_tag 4 |
||||
#define google_census_IntervalStats_Window_window_size_tag 1 |
||||
#define google_census_IntervalStats_Window_count_tag 2 |
||||
#define google_census_IntervalStats_Window_mean_tag 3 |
||||
#define google_census_Metric_name_tag 1 |
||||
#define google_census_Metric_description_tag 2 |
||||
#define google_census_Metric_unit_tag 3 |
||||
#define google_census_Metric_id_tag 4 |
||||
#define google_census_View_name_tag 1 |
||||
#define google_census_View_description_tag 2 |
||||
#define google_census_View_metric_id_tag 3 |
||||
#define google_census_View_aggregation_tag 4 |
||||
#define google_census_View_tag_key_tag 5 |
||||
#define google_census_ViewAggregations_aggregation_tag 1 |
||||
#define google_census_ViewAggregations_start_tag 2 |
||||
#define google_census_ViewAggregations_end_tag 3 |
||||
#define google_census_Aggregation_distribution_tag 3 |
||||
|
||||
#define google_census_Aggregation_interval_stats_tag 4 |
||||
#define google_census_Aggregation_name_tag 1 |
||||
#define google_census_Aggregation_description_tag 2 |
||||
#define google_census_Aggregation_tag_tag 5 |
||||
|
||||
/* Struct field encoding specification for nanopb */ |
||||
extern const pb_field_t google_census_Duration_fields[3]; |
||||
extern const pb_field_t google_census_Timestamp_fields[3]; |
||||
extern const pb_field_t google_census_Metric_fields[5]; |
||||
extern const pb_field_t google_census_Metric_BasicUnit_fields[2]; |
||||
extern const pb_field_t google_census_Metric_MeasurementUnit_fields[4]; |
||||
extern const pb_field_t google_census_AggregationDescriptor_fields[3]; |
||||
extern const pb_field_t google_census_AggregationDescriptor_BucketBoundaries_fields[2]; |
||||
extern const pb_field_t google_census_AggregationDescriptor_IntervalBoundaries_fields[2]; |
||||
extern const pb_field_t google_census_Distribution_fields[5]; |
||||
extern const pb_field_t google_census_Distribution_Range_fields[3]; |
||||
extern const pb_field_t google_census_IntervalStats_fields[2]; |
||||
extern const pb_field_t google_census_IntervalStats_Window_fields[4]; |
||||
extern const pb_field_t google_census_Tag_fields[3]; |
||||
extern const pb_field_t google_census_View_fields[6]; |
||||
extern const pb_field_t google_census_Aggregation_fields[6]; |
||||
extern const pb_field_t google_census_ViewAggregations_fields[4]; |
||||
|
||||
/* Maximum encoded size of messages (where known) */ |
||||
#define google_census_Duration_size 22 |
||||
#define google_census_Timestamp_size 22 |
||||
#define google_census_Metric_BasicUnit_size 2 |
||||
#define google_census_Distribution_Range_size 18 |
||||
#define google_census_IntervalStats_Window_size 44 |
||||
#define google_census_Tag_size 516 |
||||
|
||||
/* Message IDs (where set with "msgid" option) */ |
||||
#ifdef PB_MSGID |
||||
|
||||
#define CENSUS_MESSAGES \ |
||||
|
||||
|
||||
#endif |
||||
|
||||
#ifdef __cplusplus |
||||
} /* extern "C" */ |
||||
#endif |
||||
|
||||
#endif |
@ -0,0 +1,133 @@ |
||||
/*
|
||||
* |
||||
* Copyright 2016, Google Inc. |
||||
* All rights reserved. |
||||
* |
||||
* Redistribution and use in source and binary forms, with or without |
||||
* modification, are permitted provided that the following conditions are |
||||
* met: |
||||
* |
||||
* * Redistributions of source code must retain the above copyright |
||||
* notice, this list of conditions and the following disclaimer. |
||||
* * Redistributions in binary form must reproduce the above |
||||
* copyright notice, this list of conditions and the following disclaimer |
||||
* in the documentation and/or other materials provided with the |
||||
* distribution. |
||||
* * Neither the name of Google Inc. nor the names of its |
||||
* contributors may be used to endorse or promote products derived from |
||||
* this software without specific prior written permission. |
||||
* |
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||
* |
||||
*/ |
||||
|
||||
#include <limits.h> |
||||
#include <string.h> |
||||
|
||||
#include <grpc/support/alloc.h> |
||||
#include <grpc/support/sync.h> |
||||
|
||||
#include "src/core/ext/load_reporting/load_reporting.h" |
||||
#include "src/core/ext/load_reporting/load_reporting_filter.h" |
||||
#include "src/core/lib/channel/channel_stack_builder.h" |
||||
#include "src/core/lib/surface/channel_init.h" |
||||
|
||||
struct grpc_load_reporting_config { |
||||
grpc_load_reporting_fn fn; |
||||
void *user_data; |
||||
}; |
||||
|
||||
grpc_load_reporting_config *grpc_load_reporting_config_create( |
||||
grpc_load_reporting_fn fn, void *user_data) { |
||||
GPR_ASSERT(fn != NULL); |
||||
grpc_load_reporting_config *lrc = |
||||
gpr_malloc(sizeof(grpc_load_reporting_config)); |
||||
lrc->fn = fn; |
||||
lrc->user_data = user_data; |
||||
return lrc; |
||||
} |
||||
|
||||
grpc_load_reporting_config *grpc_load_reporting_config_copy( |
||||
grpc_load_reporting_config *src) { |
||||
return grpc_load_reporting_config_create(src->fn, src->user_data); |
||||
} |
||||
|
||||
void grpc_load_reporting_config_destroy(grpc_load_reporting_config *lrc) { |
||||
gpr_free(lrc); |
||||
} |
||||
|
||||
void grpc_load_reporting_config_call( |
||||
grpc_load_reporting_config *lrc, |
||||
const grpc_load_reporting_call_data *call_data) { |
||||
lrc->fn(call_data, lrc->user_data); |
||||
} |
||||
|
||||
static bool is_load_reporting_enabled(const grpc_channel_args *a) { |
||||
if (a == NULL) return false; |
||||
for (size_t i = 0; i < a->num_args; i++) { |
||||
if (0 == strcmp(a->args[i].key, GRPC_ARG_ENABLE_LOAD_REPORTING)) { |
||||
return a->args[i].type == GRPC_ARG_POINTER && |
||||
a->args[i].value.pointer.p != NULL; |
||||
} |
||||
} |
||||
return false; |
||||
} |
||||
|
||||
static bool maybe_add_load_reporting_filter(grpc_channel_stack_builder *builder, |
||||
void *arg) { |
||||
const grpc_channel_args *args = |
||||
grpc_channel_stack_builder_get_channel_arguments(builder); |
||||
if (is_load_reporting_enabled(args)) { |
||||
return grpc_channel_stack_builder_prepend_filter( |
||||
builder, (const grpc_channel_filter *)arg, NULL, NULL); |
||||
} |
||||
return true; |
||||
} |
||||
|
||||
static void lrd_arg_destroy(void *p) { grpc_load_reporting_config_destroy(p); } |
||||
|
||||
static void *lrd_arg_copy(void *p) { |
||||
return grpc_load_reporting_config_copy(p); |
||||
} |
||||
|
||||
static int lrd_arg_cmp(void *a, void *b) { |
||||
grpc_load_reporting_config *lhs = a; |
||||
grpc_load_reporting_config *rhs = b; |
||||
return !(lhs->fn == rhs->fn && lhs->user_data == rhs->user_data); |
||||
} |
||||
|
||||
static const grpc_arg_pointer_vtable lrd_ptr_vtable = { |
||||
lrd_arg_copy, lrd_arg_destroy, lrd_arg_cmp}; |
||||
|
||||
grpc_arg grpc_load_reporting_config_create_arg( |
||||
grpc_load_reporting_config *lrc) { |
||||
grpc_arg arg; |
||||
arg.type = GRPC_ARG_POINTER; |
||||
arg.key = GRPC_ARG_ENABLE_LOAD_REPORTING; |
||||
arg.value.pointer.p = lrc; |
||||
arg.value.pointer.vtable = &lrd_ptr_vtable; |
||||
return arg; |
||||
} |
||||
|
||||
/* Plugin registration */ |
||||
|
||||
void grpc_load_reporting_plugin_init(void) { |
||||
grpc_channel_init_register_stage(GRPC_CLIENT_CHANNEL, INT_MAX, |
||||
maybe_add_load_reporting_filter, |
||||
(void *)&grpc_load_reporting_filter); |
||||
grpc_channel_init_register_stage(GRPC_SERVER_CHANNEL, INT_MAX, |
||||
maybe_add_load_reporting_filter, |
||||
(void *)&grpc_load_reporting_filter); |
||||
} |
||||
|
||||
void grpc_load_reporting_plugin_shutdown() {} |
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue