mirror of https://github.com/grpc/grpc.git
commit
c3ae72c089
212 changed files with 7363 additions and 2715 deletions
@ -0,0 +1,32 @@ |
|||||||
|
# Copyright 2019 The 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. |
||||||
|
|
||||||
|
load("@grpc_python_dependencies//:requirements.bzl", "requirement") |
||||||
|
|
||||||
|
py_library( |
||||||
|
name = "wait_for_ready_example", |
||||||
|
testonly = 1, |
||||||
|
srcs = ["wait_for_ready_example.py"], |
||||||
|
deps = [ |
||||||
|
"//src/python/grpcio/grpc:grpcio", |
||||||
|
"//examples:py_helloworld", |
||||||
|
], |
||||||
|
) |
||||||
|
|
||||||
|
py_test( |
||||||
|
name = "test/_wait_for_ready_example_test", |
||||||
|
srcs = ["test/_wait_for_ready_example_test.py"], |
||||||
|
deps = [":wait_for_ready_example",], |
||||||
|
size = "small", |
||||||
|
) |
@ -0,0 +1,32 @@ |
|||||||
|
# gRPC Python Example for Wait-for-ready |
||||||
|
|
||||||
|
The default behavior of an RPC is to fail instantly if the server is not ready yet. This example demonstrates how to change that behavior. |
||||||
|
|
||||||
|
|
||||||
|
### Definition of 'wait-for-ready' semantics |
||||||
|
> If an RPC is issued but the channel is in TRANSIENT_FAILURE or SHUTDOWN states, the RPC is unable to be transmitted promptly. By default, gRPC implementations SHOULD fail such RPCs immediately. This is known as "fail fast," but the usage of the term is historical. RPCs SHOULD NOT fail as a result of the channel being in other states (CONNECTING, READY, or IDLE). |
||||||
|
> |
||||||
|
> gRPC implementations MAY provide a per-RPC option to not fail RPCs as a result of the channel being in TRANSIENT_FAILURE state. Instead, the implementation queues the RPCs until the channel is READY. This is known as "wait for ready." The RPCs SHOULD still fail before READY if there are unrelated reasons, such as the channel is SHUTDOWN or the RPC's deadline is reached. |
||||||
|
> |
||||||
|
> From https://github.com/grpc/grpc/blob/master/doc/wait-for-ready.md |
||||||
|
|
||||||
|
|
||||||
|
### Use cases for 'wait-for-ready' |
||||||
|
|
||||||
|
When developers spin up gRPC clients and servers at the same time, it is very like to fail first couple RPC calls due to unavailability of the server. If developers failed to prepare for this situation, the result can be catastrophic. But with 'wait-for-ready' semantics, developers can initialize the client and server in any order, especially useful in testing. |
||||||
|
|
||||||
|
Also, developers may ensure the server is up before starting client. But in some cases like transient network failure may result in a temporary unavailability of the server. With 'wait-for-ready' semantics, those RPC calls will automatically wait until the server is ready to accept incoming requests. |
||||||
|
|
||||||
|
|
||||||
|
### DEMO Snippets |
||||||
|
|
||||||
|
```Python |
||||||
|
# Per RPC level |
||||||
|
stub = ...Stub(...) |
||||||
|
|
||||||
|
stub.important_transaction_1(..., wait_for_ready=True) |
||||||
|
stub.unimportant_transaction_2(...) |
||||||
|
stub.important_transaction_3(..., wait_for_ready=True) |
||||||
|
stub.unimportant_transaction_4(...) |
||||||
|
# The unimportant transactions can be status report, or health check, etc. |
||||||
|
``` |
@ -0,0 +1,114 @@ |
|||||||
|
# Copyright 2019 The 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. |
||||||
|
"""The Python example of utilizing wait-for-ready flag.""" |
||||||
|
|
||||||
|
from __future__ import print_function |
||||||
|
import logging |
||||||
|
from concurrent import futures |
||||||
|
from contextlib import contextmanager |
||||||
|
import socket |
||||||
|
import threading |
||||||
|
|
||||||
|
import grpc |
||||||
|
|
||||||
|
from examples.protos import helloworld_pb2 |
||||||
|
from examples.protos import helloworld_pb2_grpc |
||||||
|
|
||||||
|
_LOGGER = logging.getLogger(__name__) |
||||||
|
_LOGGER.setLevel(logging.INFO) |
||||||
|
|
||||||
|
_ONE_DAY_IN_SECONDS = 60 * 60 * 24 |
||||||
|
|
||||||
|
|
||||||
|
@contextmanager |
||||||
|
def get_free_loopback_tcp_port(): |
||||||
|
tcp_socket = socket.socket(socket.AF_INET6) |
||||||
|
tcp_socket.bind(('', 0)) |
||||||
|
address_tuple = tcp_socket.getsockname() |
||||||
|
yield "[::1]:%s" % (address_tuple[1]) |
||||||
|
tcp_socket.close() |
||||||
|
|
||||||
|
|
||||||
|
class Greeter(helloworld_pb2_grpc.GreeterServicer): |
||||||
|
|
||||||
|
def SayHello(self, request, unused_context): |
||||||
|
return helloworld_pb2.HelloReply(message='Hello, %s!' % request.name) |
||||||
|
|
||||||
|
|
||||||
|
def create_server(server_address): |
||||||
|
server = grpc.server(futures.ThreadPoolExecutor()) |
||||||
|
helloworld_pb2_grpc.add_GreeterServicer_to_server(Greeter(), server) |
||||||
|
bound_port = server.add_insecure_port(server_address) |
||||||
|
assert bound_port == int(server_address.split(':')[-1]) |
||||||
|
return server |
||||||
|
|
||||||
|
|
||||||
|
def process(stub, wait_for_ready=None): |
||||||
|
try: |
||||||
|
response = stub.SayHello( |
||||||
|
helloworld_pb2.HelloRequest(name='you'), |
||||||
|
wait_for_ready=wait_for_ready) |
||||||
|
message = response.message |
||||||
|
except grpc.RpcError as rpc_error: |
||||||
|
assert rpc_error.code() == grpc.StatusCode.UNAVAILABLE |
||||||
|
assert not wait_for_ready |
||||||
|
message = rpc_error |
||||||
|
else: |
||||||
|
assert wait_for_ready |
||||||
|
_LOGGER.info("Wait-for-ready %s, client received: %s", "enabled" |
||||||
|
if wait_for_ready else "disabled", message) |
||||||
|
|
||||||
|
|
||||||
|
def main(): |
||||||
|
# Pick a random free port |
||||||
|
with get_free_loopback_tcp_port() as server_address: |
||||||
|
|
||||||
|
# Register connectivity event to notify main thread |
||||||
|
transient_failure_event = threading.Event() |
||||||
|
|
||||||
|
def wait_for_transient_failure(channel_connectivity): |
||||||
|
if channel_connectivity == grpc.ChannelConnectivity.TRANSIENT_FAILURE: |
||||||
|
transient_failure_event.set() |
||||||
|
|
||||||
|
# Create gRPC channel |
||||||
|
channel = grpc.insecure_channel(server_address) |
||||||
|
channel.subscribe(wait_for_transient_failure) |
||||||
|
stub = helloworld_pb2_grpc.GreeterStub(channel) |
||||||
|
|
||||||
|
# Fire an RPC without wait_for_ready |
||||||
|
thread_disabled_wait_for_ready = threading.Thread( |
||||||
|
target=process, args=(stub, False)) |
||||||
|
thread_disabled_wait_for_ready.start() |
||||||
|
# Fire an RPC with wait_for_ready |
||||||
|
thread_enabled_wait_for_ready = threading.Thread( |
||||||
|
target=process, args=(stub, True)) |
||||||
|
thread_enabled_wait_for_ready.start() |
||||||
|
|
||||||
|
# Wait for the channel entering TRANSIENT FAILURE state. |
||||||
|
transient_failure_event.wait() |
||||||
|
server = create_server(server_address) |
||||||
|
server.start() |
||||||
|
|
||||||
|
# Expected to fail with StatusCode.UNAVAILABLE. |
||||||
|
thread_disabled_wait_for_ready.join() |
||||||
|
# Expected to success. |
||||||
|
thread_enabled_wait_for_ready.join() |
||||||
|
|
||||||
|
server.stop(None) |
||||||
|
channel.close() |
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__': |
||||||
|
logging.basicConfig(level=logging.INFO) |
||||||
|
main() |
@ -1,117 +0,0 @@ |
|||||||
/*
|
|
||||||
* |
|
||||||
* Copyright 2015 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_CHANNEL_IMPL_H |
|
||||||
#define GRPCPP_CHANNEL_IMPL_H |
|
||||||
|
|
||||||
#include <memory> |
|
||||||
#include <mutex> |
|
||||||
|
|
||||||
#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/config.h> |
|
||||||
#include <grpcpp/impl/codegen/grpc_library.h> |
|
||||||
#include <grpcpp/impl/codegen/sync.h> |
|
||||||
|
|
||||||
struct grpc_channel; |
|
||||||
|
|
||||||
namespace grpc_impl { |
|
||||||
|
|
||||||
class CompletionQueue; |
|
||||||
namespace experimental { |
|
||||||
/// Resets the channel's connection backoff.
|
|
||||||
/// TODO(roth): Once we see whether this proves useful, either create a gRFC
|
|
||||||
/// and change this to be a method of the Channel class, or remove it.
|
|
||||||
void ChannelResetConnectionBackoff(Channel* channel); |
|
||||||
} // namespace experimental
|
|
||||||
|
|
||||||
/// Channels represent a connection to an endpoint. Created by \a CreateChannel.
|
|
||||||
class Channel final : public ::grpc::ChannelInterface, |
|
||||||
public ::grpc::internal::CallHook, |
|
||||||
public std::enable_shared_from_this<Channel>, |
|
||||||
private ::grpc::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 ::grpc::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 ::grpc::internal::InterceptedChannel; |
|
||||||
Channel(const grpc::string& host, grpc_channel* c_channel, |
|
||||||
std::vector<std::unique_ptr< |
|
||||||
::grpc::experimental::ClientInterceptorFactoryInterface>> |
|
||||||
interceptor_creators); |
|
||||||
|
|
||||||
::grpc::internal::Call CreateCall(const ::grpc::internal::RpcMethod& method, |
|
||||||
::grpc::ClientContext* context, |
|
||||||
CompletionQueue* cq) override; |
|
||||||
void PerformOpsOnCall(::grpc::internal::CallOpSetInterface* ops, |
|
||||||
::grpc::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; |
|
||||||
|
|
||||||
::grpc::internal::Call CreateCallInternal( |
|
||||||
const ::grpc::internal::RpcMethod& method, ::grpc::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<::grpc::experimental::ClientInterceptorFactoryInterface>> |
|
||||||
interceptor_creators_; |
|
||||||
}; |
|
||||||
|
|
||||||
} // namespace grpc_impl
|
|
||||||
|
|
||||||
#endif // GRPCPP_CHANNEL_IMPL_H
|
|
@ -1,422 +0,0 @@ |
|||||||
/*
|
|
||||||
* |
|
||||||
* Copyright 2015-2016 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. |
|
||||||
* |
|
||||||
*/ |
|
||||||
|
|
||||||
/// A completion queue implements a concurrent producer-consumer queue, with
|
|
||||||
/// two main API-exposed methods: \a Next and \a AsyncNext. These
|
|
||||||
/// methods are the essential component of the gRPC C++ asynchronous API.
|
|
||||||
/// There is also a \a Shutdown method to indicate that a given completion queue
|
|
||||||
/// will no longer have regular events. This must be called before the
|
|
||||||
/// completion queue is destroyed.
|
|
||||||
/// All completion queue APIs are thread-safe and may be used concurrently with
|
|
||||||
/// any other completion queue API invocation; it is acceptable to have
|
|
||||||
/// multiple threads calling \a Next or \a AsyncNext on the same or different
|
|
||||||
/// completion queues, or to call these methods concurrently with a \a Shutdown
|
|
||||||
/// elsewhere.
|
|
||||||
/// \remark{All other API calls on completion queue should be completed before
|
|
||||||
/// a completion queue destructor is called.}
|
|
||||||
#ifndef GRPCPP_IMPL_CODEGEN_COMPLETION_QUEUE_IMPL_H |
|
||||||
#define GRPCPP_IMPL_CODEGEN_COMPLETION_QUEUE_IMPL_H |
|
||||||
|
|
||||||
#include <grpc/impl/codegen/atm.h> |
|
||||||
#include <grpcpp/impl/codegen/completion_queue_tag.h> |
|
||||||
#include <grpcpp/impl/codegen/core_codegen_interface.h> |
|
||||||
#include <grpcpp/impl/codegen/grpc_library.h> |
|
||||||
#include <grpcpp/impl/codegen/status.h> |
|
||||||
#include <grpcpp/impl/codegen/time.h> |
|
||||||
|
|
||||||
struct grpc_completion_queue; |
|
||||||
|
|
||||||
namespace grpc_impl { |
|
||||||
|
|
||||||
class Channel; |
|
||||||
class Server; |
|
||||||
class ServerBuilder; |
|
||||||
} // namespace grpc_impl
|
|
||||||
namespace grpc { |
|
||||||
|
|
||||||
template <class R> |
|
||||||
class ClientReader; |
|
||||||
template <class W> |
|
||||||
class ClientWriter; |
|
||||||
template <class W, class R> |
|
||||||
class ClientReaderWriter; |
|
||||||
template <class R> |
|
||||||
class ServerReader; |
|
||||||
template <class W> |
|
||||||
class ServerWriter; |
|
||||||
namespace internal { |
|
||||||
template <class W, class R> |
|
||||||
class ServerReaderWriterBody; |
|
||||||
} // namespace internal
|
|
||||||
|
|
||||||
class ChannelInterface; |
|
||||||
class ClientContext; |
|
||||||
class ServerContext; |
|
||||||
class ServerInterface; |
|
||||||
|
|
||||||
namespace internal { |
|
||||||
class CompletionQueueTag; |
|
||||||
class RpcMethod; |
|
||||||
template <class ServiceType, class RequestType, class ResponseType> |
|
||||||
class RpcMethodHandler; |
|
||||||
template <class ServiceType, class RequestType, class ResponseType> |
|
||||||
class ClientStreamingHandler; |
|
||||||
template <class ServiceType, class RequestType, class ResponseType> |
|
||||||
class ServerStreamingHandler; |
|
||||||
template <class ServiceType, class RequestType, class ResponseType> |
|
||||||
class BidiStreamingHandler; |
|
||||||
template <class Streamer, bool WriteNeeded> |
|
||||||
class TemplatedBidiStreamingHandler; |
|
||||||
template <StatusCode code> |
|
||||||
class ErrorMethodHandler; |
|
||||||
template <class InputMessage, class OutputMessage> |
|
||||||
class BlockingUnaryCallImpl; |
|
||||||
template <class Op1, class Op2, class Op3, class Op4, class Op5, class Op6> |
|
||||||
class CallOpSet; |
|
||||||
} // namespace internal
|
|
||||||
|
|
||||||
extern CoreCodegenInterface* g_core_codegen_interface; |
|
||||||
|
|
||||||
} // namespace grpc
|
|
||||||
|
|
||||||
namespace grpc_impl { |
|
||||||
|
|
||||||
/// A thin wrapper around \ref grpc_completion_queue (see \ref
|
|
||||||
/// src/core/lib/surface/completion_queue.h).
|
|
||||||
/// See \ref doc/cpp/perf_notes.md for notes on best practices for high
|
|
||||||
/// performance servers.
|
|
||||||
class CompletionQueue : private ::grpc::GrpcLibraryCodegen { |
|
||||||
public: |
|
||||||
/// Default constructor. Implicitly creates a \a grpc_completion_queue
|
|
||||||
/// instance.
|
|
||||||
CompletionQueue() |
|
||||||
: CompletionQueue(grpc_completion_queue_attributes{ |
|
||||||
GRPC_CQ_CURRENT_VERSION, GRPC_CQ_NEXT, GRPC_CQ_DEFAULT_POLLING, |
|
||||||
nullptr}) {} |
|
||||||
|
|
||||||
/// Wrap \a take, taking ownership of the instance.
|
|
||||||
///
|
|
||||||
/// \param take The completion queue instance to wrap. Ownership is taken.
|
|
||||||
explicit CompletionQueue(grpc_completion_queue* take); |
|
||||||
|
|
||||||
/// Destructor. Destroys the owned wrapped completion queue / instance.
|
|
||||||
~CompletionQueue() { |
|
||||||
::grpc::g_core_codegen_interface->grpc_completion_queue_destroy(cq_); |
|
||||||
} |
|
||||||
|
|
||||||
/// Tri-state return for AsyncNext: SHUTDOWN, GOT_EVENT, TIMEOUT.
|
|
||||||
enum NextStatus { |
|
||||||
SHUTDOWN, ///< The completion queue has been shutdown and fully-drained
|
|
||||||
GOT_EVENT, ///< Got a new event; \a tag will be filled in with its
|
|
||||||
///< associated value; \a ok indicating its success.
|
|
||||||
TIMEOUT ///< deadline was reached.
|
|
||||||
}; |
|
||||||
|
|
||||||
/// Read from the queue, blocking until an event is available or the queue is
|
|
||||||
/// shutting down.
|
|
||||||
///
|
|
||||||
/// \param tag [out] Updated to point to the read event's tag.
|
|
||||||
/// \param ok [out] true if read a successful event, false otherwise.
|
|
||||||
///
|
|
||||||
/// Note that each tag sent to the completion queue (through RPC operations
|
|
||||||
/// or alarms) will be delivered out of the completion queue by a call to
|
|
||||||
/// Next (or a related method), regardless of whether the operation succeeded
|
|
||||||
/// or not. Success here means that this operation completed in the normal
|
|
||||||
/// valid manner.
|
|
||||||
///
|
|
||||||
/// Server-side RPC request: \a ok indicates that the RPC has indeed
|
|
||||||
/// been started. If it is false, the server has been Shutdown
|
|
||||||
/// before this particular call got matched to an incoming RPC.
|
|
||||||
///
|
|
||||||
/// Client-side StartCall/RPC invocation: \a ok indicates that the RPC is
|
|
||||||
/// going to go to the wire. If it is false, it not going to the wire. This
|
|
||||||
/// would happen if the channel is either permanently broken or
|
|
||||||
/// transiently broken but with the fail-fast option. (Note that async unary
|
|
||||||
/// RPCs don't post a CQ tag at this point, nor do client-streaming
|
|
||||||
/// or bidi-streaming RPCs that have the initial metadata corked option set.)
|
|
||||||
///
|
|
||||||
/// Client-side Write, Client-side WritesDone, Server-side Write,
|
|
||||||
/// Server-side Finish, Server-side SendInitialMetadata (which is
|
|
||||||
/// typically included in Write or Finish when not done explicitly):
|
|
||||||
/// \a ok means that the data/metadata/status/etc is going to go to the
|
|
||||||
/// wire. If it is false, it not going to the wire because the call
|
|
||||||
/// is already dead (i.e., canceled, deadline expired, other side
|
|
||||||
/// dropped the channel, etc).
|
|
||||||
///
|
|
||||||
/// Client-side Read, Server-side Read, Client-side
|
|
||||||
/// RecvInitialMetadata (which is typically included in Read if not
|
|
||||||
/// done explicitly): \a ok indicates whether there is a valid message
|
|
||||||
/// that got read. If not, you know that there are certainly no more
|
|
||||||
/// messages that can ever be read from this stream. For the client-side
|
|
||||||
/// operations, this only happens because the call is dead. For the
|
|
||||||
/// server-sider operation, though, this could happen because the client
|
|
||||||
/// has done a WritesDone already.
|
|
||||||
///
|
|
||||||
/// Client-side Finish: \a ok should always be true
|
|
||||||
///
|
|
||||||
/// Server-side AsyncNotifyWhenDone: \a ok should always be true
|
|
||||||
///
|
|
||||||
/// Alarm: \a ok is true if it expired, false if it was canceled
|
|
||||||
///
|
|
||||||
/// \return true if got an event, false if the queue is fully drained and
|
|
||||||
/// shut down.
|
|
||||||
bool Next(void** tag, bool* ok) { |
|
||||||
return (AsyncNextInternal(tag, ok, |
|
||||||
::grpc::g_core_codegen_interface->gpr_inf_future( |
|
||||||
GPR_CLOCK_REALTIME)) != SHUTDOWN); |
|
||||||
} |
|
||||||
|
|
||||||
/// Read from the queue, blocking up to \a deadline (or the queue's shutdown).
|
|
||||||
/// Both \a tag and \a ok are updated upon success (if an event is available
|
|
||||||
/// within the \a deadline). A \a tag points to an arbitrary location usually
|
|
||||||
/// employed to uniquely identify an event.
|
|
||||||
///
|
|
||||||
/// \param tag [out] Upon sucess, updated to point to the event's tag.
|
|
||||||
/// \param ok [out] Upon sucess, true if a successful event, false otherwise
|
|
||||||
/// See documentation for CompletionQueue::Next for explanation of ok
|
|
||||||
/// \param deadline [in] How long to block in wait for an event.
|
|
||||||
///
|
|
||||||
/// \return The type of event read.
|
|
||||||
template <typename T> |
|
||||||
NextStatus AsyncNext(void** tag, bool* ok, const T& deadline) { |
|
||||||
::grpc::TimePoint<T> deadline_tp(deadline); |
|
||||||
return AsyncNextInternal(tag, ok, deadline_tp.raw_time()); |
|
||||||
} |
|
||||||
|
|
||||||
/// EXPERIMENTAL
|
|
||||||
/// First executes \a F, then reads from the queue, blocking up to
|
|
||||||
/// \a deadline (or the queue's shutdown).
|
|
||||||
/// Both \a tag and \a ok are updated upon success (if an event is available
|
|
||||||
/// within the \a deadline). A \a tag points to an arbitrary location usually
|
|
||||||
/// employed to uniquely identify an event.
|
|
||||||
///
|
|
||||||
/// \param f [in] Function to execute before calling AsyncNext on this queue.
|
|
||||||
/// \param tag [out] Upon sucess, updated to point to the event's tag.
|
|
||||||
/// \param ok [out] Upon sucess, true if read a regular event, false
|
|
||||||
/// otherwise.
|
|
||||||
/// \param deadline [in] How long to block in wait for an event.
|
|
||||||
///
|
|
||||||
/// \return The type of event read.
|
|
||||||
template <typename T, typename F> |
|
||||||
NextStatus DoThenAsyncNext(F&& f, void** tag, bool* ok, const T& deadline) { |
|
||||||
CompletionQueueTLSCache cache = CompletionQueueTLSCache(this); |
|
||||||
f(); |
|
||||||
if (cache.Flush(tag, ok)) { |
|
||||||
return GOT_EVENT; |
|
||||||
} else { |
|
||||||
return AsyncNext(tag, ok, deadline); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
/// Request the shutdown of the queue.
|
|
||||||
///
|
|
||||||
/// \warning This method must be called at some point if this completion queue
|
|
||||||
/// is accessed with Next or AsyncNext. \a Next will not return false
|
|
||||||
/// until this method has been called and all pending tags have been drained.
|
|
||||||
/// (Likewise for \a AsyncNext returning \a NextStatus::SHUTDOWN .)
|
|
||||||
/// Only once either one of these methods does that (that is, once the queue
|
|
||||||
/// has been \em drained) can an instance of this class be destroyed.
|
|
||||||
/// Also note that applications must ensure that no work is enqueued on this
|
|
||||||
/// completion queue after this method is called.
|
|
||||||
void Shutdown(); |
|
||||||
|
|
||||||
/// Returns a \em raw pointer to the underlying \a grpc_completion_queue
|
|
||||||
/// instance.
|
|
||||||
///
|
|
||||||
/// \warning Remember that the returned instance is owned. No transfer of
|
|
||||||
/// owership is performed.
|
|
||||||
grpc_completion_queue* cq() { return cq_; } |
|
||||||
|
|
||||||
protected: |
|
||||||
/// Private constructor of CompletionQueue only visible to friend classes
|
|
||||||
CompletionQueue(const grpc_completion_queue_attributes& attributes) { |
|
||||||
cq_ = ::grpc::g_core_codegen_interface->grpc_completion_queue_create( |
|
||||||
::grpc::g_core_codegen_interface->grpc_completion_queue_factory_lookup( |
|
||||||
&attributes), |
|
||||||
&attributes, NULL); |
|
||||||
InitialAvalanching(); // reserve this for the future shutdown
|
|
||||||
} |
|
||||||
|
|
||||||
private: |
|
||||||
// Friend synchronous wrappers so that they can access Pluck(), which is
|
|
||||||
// a semi-private API geared towards the synchronous implementation.
|
|
||||||
template <class R> |
|
||||||
friend class ::grpc::ClientReader; |
|
||||||
template <class W> |
|
||||||
friend class ::grpc::ClientWriter; |
|
||||||
template <class W, class R> |
|
||||||
friend class ::grpc::ClientReaderWriter; |
|
||||||
template <class R> |
|
||||||
friend class ::grpc::ServerReader; |
|
||||||
template <class W> |
|
||||||
friend class ::grpc::ServerWriter; |
|
||||||
template <class W, class R> |
|
||||||
friend class ::grpc::internal::ServerReaderWriterBody; |
|
||||||
template <class ServiceType, class RequestType, class ResponseType> |
|
||||||
friend class ::grpc::internal::RpcMethodHandler; |
|
||||||
template <class ServiceType, class RequestType, class ResponseType> |
|
||||||
friend class ::grpc::internal::ClientStreamingHandler; |
|
||||||
template <class ServiceType, class RequestType, class ResponseType> |
|
||||||
friend class ::grpc::internal::ServerStreamingHandler; |
|
||||||
template <class Streamer, bool WriteNeeded> |
|
||||||
friend class ::grpc::internal::TemplatedBidiStreamingHandler; |
|
||||||
template <::grpc::StatusCode code> |
|
||||||
friend class ::grpc::internal::ErrorMethodHandler; |
|
||||||
friend class ::grpc_impl::Server; |
|
||||||
friend class ::grpc::ServerContext; |
|
||||||
friend class ::grpc::ServerInterface; |
|
||||||
template <class InputMessage, class OutputMessage> |
|
||||||
friend class ::grpc::internal::BlockingUnaryCallImpl; |
|
||||||
|
|
||||||
// Friends that need access to constructor for callback CQ
|
|
||||||
friend class ::grpc_impl::Channel; |
|
||||||
|
|
||||||
// For access to Register/CompleteAvalanching
|
|
||||||
template <class Op1, class Op2, class Op3, class Op4, class Op5, class Op6> |
|
||||||
friend class ::grpc::internal::CallOpSet; |
|
||||||
|
|
||||||
/// EXPERIMENTAL
|
|
||||||
/// Creates a Thread Local cache to store the first event
|
|
||||||
/// On this completion queue queued from this thread. Once
|
|
||||||
/// initialized, it must be flushed on the same thread.
|
|
||||||
class CompletionQueueTLSCache { |
|
||||||
public: |
|
||||||
CompletionQueueTLSCache(CompletionQueue* cq); |
|
||||||
~CompletionQueueTLSCache(); |
|
||||||
bool Flush(void** tag, bool* ok); |
|
||||||
|
|
||||||
private: |
|
||||||
CompletionQueue* cq_; |
|
||||||
bool flushed_; |
|
||||||
}; |
|
||||||
|
|
||||||
NextStatus AsyncNextInternal(void** tag, bool* ok, gpr_timespec deadline); |
|
||||||
|
|
||||||
/// Wraps \a grpc_completion_queue_pluck.
|
|
||||||
/// \warning Must not be mixed with calls to \a Next.
|
|
||||||
bool Pluck(::grpc::internal::CompletionQueueTag* tag) { |
|
||||||
auto deadline = |
|
||||||
::grpc::g_core_codegen_interface->gpr_inf_future(GPR_CLOCK_REALTIME); |
|
||||||
while (true) { |
|
||||||
auto ev = ::grpc::g_core_codegen_interface->grpc_completion_queue_pluck( |
|
||||||
cq_, tag, deadline, nullptr); |
|
||||||
bool ok = ev.success != 0; |
|
||||||
void* ignored = tag; |
|
||||||
if (tag->FinalizeResult(&ignored, &ok)) { |
|
||||||
GPR_CODEGEN_ASSERT(ignored == tag); |
|
||||||
return ok; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
/// Performs a single polling pluck on \a tag.
|
|
||||||
/// \warning Must not be mixed with calls to \a Next.
|
|
||||||
///
|
|
||||||
/// TODO: sreek - This calls tag->FinalizeResult() even if the cq_ is already
|
|
||||||
/// shutdown. This is most likely a bug and if it is a bug, then change this
|
|
||||||
/// implementation to simple call the other TryPluck function with a zero
|
|
||||||
/// timeout. i.e:
|
|
||||||
/// TryPluck(tag, gpr_time_0(GPR_CLOCK_REALTIME))
|
|
||||||
void TryPluck(::grpc::internal::CompletionQueueTag* tag) { |
|
||||||
auto deadline = |
|
||||||
::grpc::g_core_codegen_interface->gpr_time_0(GPR_CLOCK_REALTIME); |
|
||||||
auto ev = ::grpc::g_core_codegen_interface->grpc_completion_queue_pluck( |
|
||||||
cq_, tag, deadline, nullptr); |
|
||||||
if (ev.type == GRPC_QUEUE_TIMEOUT) return; |
|
||||||
bool ok = ev.success != 0; |
|
||||||
void* ignored = tag; |
|
||||||
// the tag must be swallowed if using TryPluck
|
|
||||||
GPR_CODEGEN_ASSERT(!tag->FinalizeResult(&ignored, &ok)); |
|
||||||
} |
|
||||||
|
|
||||||
/// Performs a single polling pluck on \a tag. Calls tag->FinalizeResult if
|
|
||||||
/// the pluck() was successful and returned the tag.
|
|
||||||
///
|
|
||||||
/// This exects tag->FinalizeResult (if called) to return 'false' i.e expects
|
|
||||||
/// that the tag is internal not something that is returned to the user.
|
|
||||||
void TryPluck(::grpc::internal::CompletionQueueTag* tag, |
|
||||||
gpr_timespec deadline) { |
|
||||||
auto ev = ::grpc::g_core_codegen_interface->grpc_completion_queue_pluck( |
|
||||||
cq_, tag, deadline, nullptr); |
|
||||||
if (ev.type == GRPC_QUEUE_TIMEOUT || ev.type == GRPC_QUEUE_SHUTDOWN) { |
|
||||||
return; |
|
||||||
} |
|
||||||
|
|
||||||
bool ok = ev.success != 0; |
|
||||||
void* ignored = tag; |
|
||||||
GPR_CODEGEN_ASSERT(!tag->FinalizeResult(&ignored, &ok)); |
|
||||||
} |
|
||||||
|
|
||||||
/// Manage state of avalanching operations : completion queue tags that
|
|
||||||
/// trigger other completion queue operations. The underlying core completion
|
|
||||||
/// queue should not really shutdown until all avalanching operations have
|
|
||||||
/// been finalized. Note that we maintain the requirement that an avalanche
|
|
||||||
/// registration must take place before CQ shutdown (which must be maintained
|
|
||||||
/// elsehwere)
|
|
||||||
void InitialAvalanching() { |
|
||||||
gpr_atm_rel_store(&avalanches_in_flight_, static_cast<gpr_atm>(1)); |
|
||||||
} |
|
||||||
void RegisterAvalanching() { |
|
||||||
gpr_atm_no_barrier_fetch_add(&avalanches_in_flight_, |
|
||||||
static_cast<gpr_atm>(1)); |
|
||||||
} |
|
||||||
void CompleteAvalanching() { |
|
||||||
if (gpr_atm_no_barrier_fetch_add(&avalanches_in_flight_, |
|
||||||
static_cast<gpr_atm>(-1)) == 1) { |
|
||||||
::grpc::g_core_codegen_interface->grpc_completion_queue_shutdown(cq_); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
grpc_completion_queue* cq_; // owned
|
|
||||||
|
|
||||||
gpr_atm avalanches_in_flight_; |
|
||||||
}; |
|
||||||
|
|
||||||
/// A specific type of completion queue used by the processing of notifications
|
|
||||||
/// by servers. Instantiated by \a ServerBuilder.
|
|
||||||
class ServerCompletionQueue : public CompletionQueue { |
|
||||||
public: |
|
||||||
bool IsFrequentlyPolled() { return polling_type_ != GRPC_CQ_NON_LISTENING; } |
|
||||||
|
|
||||||
protected: |
|
||||||
/// Default constructor
|
|
||||||
ServerCompletionQueue() : polling_type_(GRPC_CQ_DEFAULT_POLLING) {} |
|
||||||
|
|
||||||
private: |
|
||||||
/// \param completion_type indicates whether this is a NEXT or CALLBACK
|
|
||||||
/// completion queue.
|
|
||||||
/// \param polling_type Informs the GRPC library about the type of polling
|
|
||||||
/// allowed on this completion queue. See grpc_cq_polling_type's description
|
|
||||||
/// in grpc_types.h for more details.
|
|
||||||
/// \param shutdown_cb is the shutdown callback used for CALLBACK api queues
|
|
||||||
ServerCompletionQueue(grpc_cq_completion_type completion_type, |
|
||||||
grpc_cq_polling_type polling_type, |
|
||||||
grpc_experimental_completion_queue_functor* shutdown_cb) |
|
||||||
: CompletionQueue(grpc_completion_queue_attributes{ |
|
||||||
GRPC_CQ_CURRENT_VERSION, completion_type, polling_type, |
|
||||||
shutdown_cb}), |
|
||||||
polling_type_(polling_type) {} |
|
||||||
|
|
||||||
grpc_cq_polling_type polling_type_; |
|
||||||
friend class ::grpc_impl::ServerBuilder; |
|
||||||
friend class ::grpc_impl::Server; |
|
||||||
}; |
|
||||||
|
|
||||||
} // namespace grpc_impl
|
|
||||||
|
|
||||||
#endif // GRPCPP_IMPL_CODEGEN_COMPLETION_QUEUE_IMPL_H
|
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,105 @@ |
|||||||
|
/* This file was generated by upbc (the upb compiler) from the input
|
||||||
|
* file: |
||||||
|
* |
||||||
|
* envoy/api/v2/endpoint/load_report.proto |
||||||
|
* |
||||||
|
* Do not edit -- your changes will be discarded when the file is |
||||||
|
* regenerated. */ |
||||||
|
|
||||||
|
#include <stddef.h> |
||||||
|
#include "upb/msg.h" |
||||||
|
#include "envoy/api/v2/endpoint/load_report.upb.h" |
||||||
|
#include "envoy/api/v2/core/address.upb.h" |
||||||
|
#include "envoy/api/v2/core/base.upb.h" |
||||||
|
#include "google/protobuf/duration.upb.h" |
||||||
|
#include "validate/validate.upb.h" |
||||||
|
#include "gogoproto/gogo.upb.h" |
||||||
|
|
||||||
|
#include "upb/port_def.inc" |
||||||
|
|
||||||
|
static const upb_msglayout *const envoy_api_v2_endpoint_UpstreamLocalityStats_submsgs[3] = { |
||||||
|
&envoy_api_v2_core_Locality_msginit, |
||||||
|
&envoy_api_v2_endpoint_EndpointLoadMetricStats_msginit, |
||||||
|
&envoy_api_v2_endpoint_UpstreamEndpointStats_msginit, |
||||||
|
}; |
||||||
|
|
||||||
|
static const upb_msglayout_field envoy_api_v2_endpoint_UpstreamLocalityStats__fields[7] = { |
||||||
|
{1, UPB_SIZE(28, 32), 0, 0, 11, 1}, |
||||||
|
{2, UPB_SIZE(0, 0), 0, 0, 4, 1}, |
||||||
|
{3, UPB_SIZE(8, 8), 0, 0, 4, 1}, |
||||||
|
{4, UPB_SIZE(16, 16), 0, 0, 4, 1}, |
||||||
|
{5, UPB_SIZE(32, 40), 0, 1, 11, 3}, |
||||||
|
{6, UPB_SIZE(24, 24), 0, 0, 13, 1}, |
||||||
|
{7, UPB_SIZE(36, 48), 0, 2, 11, 3}, |
||||||
|
}; |
||||||
|
|
||||||
|
const upb_msglayout envoy_api_v2_endpoint_UpstreamLocalityStats_msginit = { |
||||||
|
&envoy_api_v2_endpoint_UpstreamLocalityStats_submsgs[0], |
||||||
|
&envoy_api_v2_endpoint_UpstreamLocalityStats__fields[0], |
||||||
|
UPB_SIZE(40, 56), 7, false, |
||||||
|
}; |
||||||
|
|
||||||
|
static const upb_msglayout *const envoy_api_v2_endpoint_UpstreamEndpointStats_submsgs[2] = { |
||||||
|
&envoy_api_v2_core_Address_msginit, |
||||||
|
&envoy_api_v2_endpoint_EndpointLoadMetricStats_msginit, |
||||||
|
}; |
||||||
|
|
||||||
|
static const upb_msglayout_field envoy_api_v2_endpoint_UpstreamEndpointStats__fields[5] = { |
||||||
|
{1, UPB_SIZE(24, 24), 0, 0, 11, 1}, |
||||||
|
{2, UPB_SIZE(0, 0), 0, 0, 4, 1}, |
||||||
|
{3, UPB_SIZE(8, 8), 0, 0, 4, 1}, |
||||||
|
{4, UPB_SIZE(16, 16), 0, 0, 4, 1}, |
||||||
|
{5, UPB_SIZE(28, 32), 0, 1, 11, 3}, |
||||||
|
}; |
||||||
|
|
||||||
|
const upb_msglayout envoy_api_v2_endpoint_UpstreamEndpointStats_msginit = { |
||||||
|
&envoy_api_v2_endpoint_UpstreamEndpointStats_submsgs[0], |
||||||
|
&envoy_api_v2_endpoint_UpstreamEndpointStats__fields[0], |
||||||
|
UPB_SIZE(32, 40), 5, false, |
||||||
|
}; |
||||||
|
|
||||||
|
static const upb_msglayout_field envoy_api_v2_endpoint_EndpointLoadMetricStats__fields[3] = { |
||||||
|
{1, UPB_SIZE(16, 16), 0, 0, 9, 1}, |
||||||
|
{2, UPB_SIZE(0, 0), 0, 0, 4, 1}, |
||||||
|
{3, UPB_SIZE(8, 8), 0, 0, 1, 1}, |
||||||
|
}; |
||||||
|
|
||||||
|
const upb_msglayout envoy_api_v2_endpoint_EndpointLoadMetricStats_msginit = { |
||||||
|
NULL, |
||||||
|
&envoy_api_v2_endpoint_EndpointLoadMetricStats__fields[0], |
||||||
|
UPB_SIZE(24, 32), 3, false, |
||||||
|
}; |
||||||
|
|
||||||
|
static const upb_msglayout *const envoy_api_v2_endpoint_ClusterStats_submsgs[3] = { |
||||||
|
&envoy_api_v2_endpoint_ClusterStats_DroppedRequests_msginit, |
||||||
|
&envoy_api_v2_endpoint_UpstreamLocalityStats_msginit, |
||||||
|
&google_protobuf_Duration_msginit, |
||||||
|
}; |
||||||
|
|
||||||
|
static const upb_msglayout_field envoy_api_v2_endpoint_ClusterStats__fields[5] = { |
||||||
|
{1, UPB_SIZE(8, 8), 0, 0, 9, 1}, |
||||||
|
{2, UPB_SIZE(20, 32), 0, 1, 11, 3}, |
||||||
|
{3, UPB_SIZE(0, 0), 0, 0, 4, 1}, |
||||||
|
{4, UPB_SIZE(16, 24), 0, 2, 11, 1}, |
||||||
|
{5, UPB_SIZE(24, 40), 0, 0, 11, 3}, |
||||||
|
}; |
||||||
|
|
||||||
|
const upb_msglayout envoy_api_v2_endpoint_ClusterStats_msginit = { |
||||||
|
&envoy_api_v2_endpoint_ClusterStats_submsgs[0], |
||||||
|
&envoy_api_v2_endpoint_ClusterStats__fields[0], |
||||||
|
UPB_SIZE(32, 48), 5, false, |
||||||
|
}; |
||||||
|
|
||||||
|
static const upb_msglayout_field envoy_api_v2_endpoint_ClusterStats_DroppedRequests__fields[2] = { |
||||||
|
{1, UPB_SIZE(8, 8), 0, 0, 9, 1}, |
||||||
|
{2, UPB_SIZE(0, 0), 0, 0, 4, 1}, |
||||||
|
}; |
||||||
|
|
||||||
|
const upb_msglayout envoy_api_v2_endpoint_ClusterStats_DroppedRequests_msginit = { |
||||||
|
NULL, |
||||||
|
&envoy_api_v2_endpoint_ClusterStats_DroppedRequests__fields[0], |
||||||
|
UPB_SIZE(16, 32), 2, false, |
||||||
|
}; |
||||||
|
|
||||||
|
#include "upb/port_undef.inc" |
||||||
|
|
@ -0,0 +1,299 @@ |
|||||||
|
/* This file was generated by upbc (the upb compiler) from the input
|
||||||
|
* file: |
||||||
|
* |
||||||
|
* envoy/api/v2/endpoint/load_report.proto |
||||||
|
* |
||||||
|
* Do not edit -- your changes will be discarded when the file is |
||||||
|
* regenerated. */ |
||||||
|
|
||||||
|
#ifndef ENVOY_API_V2_ENDPOINT_LOAD_REPORT_PROTO_UPB_H_ |
||||||
|
#define ENVOY_API_V2_ENDPOINT_LOAD_REPORT_PROTO_UPB_H_ |
||||||
|
|
||||||
|
#include "upb/generated_util.h" |
||||||
|
|
||||||
|
#include "upb/msg.h" |
||||||
|
|
||||||
|
#include "upb/decode.h" |
||||||
|
#include "upb/encode.h" |
||||||
|
#include "upb/port_def.inc" |
||||||
|
#ifdef __cplusplus |
||||||
|
extern "C" { |
||||||
|
#endif |
||||||
|
|
||||||
|
struct envoy_api_v2_endpoint_UpstreamLocalityStats; |
||||||
|
struct envoy_api_v2_endpoint_UpstreamEndpointStats; |
||||||
|
struct envoy_api_v2_endpoint_EndpointLoadMetricStats; |
||||||
|
struct envoy_api_v2_endpoint_ClusterStats; |
||||||
|
struct envoy_api_v2_endpoint_ClusterStats_DroppedRequests; |
||||||
|
typedef struct envoy_api_v2_endpoint_UpstreamLocalityStats envoy_api_v2_endpoint_UpstreamLocalityStats; |
||||||
|
typedef struct envoy_api_v2_endpoint_UpstreamEndpointStats envoy_api_v2_endpoint_UpstreamEndpointStats; |
||||||
|
typedef struct envoy_api_v2_endpoint_EndpointLoadMetricStats envoy_api_v2_endpoint_EndpointLoadMetricStats; |
||||||
|
typedef struct envoy_api_v2_endpoint_ClusterStats envoy_api_v2_endpoint_ClusterStats; |
||||||
|
typedef struct envoy_api_v2_endpoint_ClusterStats_DroppedRequests envoy_api_v2_endpoint_ClusterStats_DroppedRequests; |
||||||
|
extern const upb_msglayout envoy_api_v2_endpoint_UpstreamLocalityStats_msginit; |
||||||
|
extern const upb_msglayout envoy_api_v2_endpoint_UpstreamEndpointStats_msginit; |
||||||
|
extern const upb_msglayout envoy_api_v2_endpoint_EndpointLoadMetricStats_msginit; |
||||||
|
extern const upb_msglayout envoy_api_v2_endpoint_ClusterStats_msginit; |
||||||
|
extern const upb_msglayout envoy_api_v2_endpoint_ClusterStats_DroppedRequests_msginit; |
||||||
|
struct envoy_api_v2_core_Address; |
||||||
|
struct envoy_api_v2_core_Locality; |
||||||
|
struct google_protobuf_Duration; |
||||||
|
extern const upb_msglayout envoy_api_v2_core_Address_msginit; |
||||||
|
extern const upb_msglayout envoy_api_v2_core_Locality_msginit; |
||||||
|
extern const upb_msglayout google_protobuf_Duration_msginit; |
||||||
|
|
||||||
|
/* Enums */ |
||||||
|
|
||||||
|
|
||||||
|
/* envoy.api.v2.endpoint.UpstreamLocalityStats */ |
||||||
|
|
||||||
|
UPB_INLINE envoy_api_v2_endpoint_UpstreamLocalityStats *envoy_api_v2_endpoint_UpstreamLocalityStats_new(upb_arena *arena) { |
||||||
|
return (envoy_api_v2_endpoint_UpstreamLocalityStats *)upb_msg_new(&envoy_api_v2_endpoint_UpstreamLocalityStats_msginit, arena); |
||||||
|
} |
||||||
|
UPB_INLINE envoy_api_v2_endpoint_UpstreamLocalityStats *envoy_api_v2_endpoint_UpstreamLocalityStats_parsenew(upb_strview buf, upb_arena *arena) { |
||||||
|
envoy_api_v2_endpoint_UpstreamLocalityStats *ret = envoy_api_v2_endpoint_UpstreamLocalityStats_new(arena); |
||||||
|
return (ret && upb_decode(buf, ret, &envoy_api_v2_endpoint_UpstreamLocalityStats_msginit)) ? ret : NULL; |
||||||
|
} |
||||||
|
UPB_INLINE char *envoy_api_v2_endpoint_UpstreamLocalityStats_serialize(const envoy_api_v2_endpoint_UpstreamLocalityStats *msg, upb_arena *arena, size_t *len) { |
||||||
|
return upb_encode(msg, &envoy_api_v2_endpoint_UpstreamLocalityStats_msginit, arena, len); |
||||||
|
} |
||||||
|
|
||||||
|
UPB_INLINE const struct envoy_api_v2_core_Locality* envoy_api_v2_endpoint_UpstreamLocalityStats_locality(const envoy_api_v2_endpoint_UpstreamLocalityStats *msg) { return UPB_FIELD_AT(msg, const struct envoy_api_v2_core_Locality*, UPB_SIZE(28, 32)); } |
||||||
|
UPB_INLINE uint64_t envoy_api_v2_endpoint_UpstreamLocalityStats_total_successful_requests(const envoy_api_v2_endpoint_UpstreamLocalityStats *msg) { return UPB_FIELD_AT(msg, uint64_t, UPB_SIZE(0, 0)); } |
||||||
|
UPB_INLINE uint64_t envoy_api_v2_endpoint_UpstreamLocalityStats_total_requests_in_progress(const envoy_api_v2_endpoint_UpstreamLocalityStats *msg) { return UPB_FIELD_AT(msg, uint64_t, UPB_SIZE(8, 8)); } |
||||||
|
UPB_INLINE uint64_t envoy_api_v2_endpoint_UpstreamLocalityStats_total_error_requests(const envoy_api_v2_endpoint_UpstreamLocalityStats *msg) { return UPB_FIELD_AT(msg, uint64_t, UPB_SIZE(16, 16)); } |
||||||
|
UPB_INLINE const envoy_api_v2_endpoint_EndpointLoadMetricStats* const* envoy_api_v2_endpoint_UpstreamLocalityStats_load_metric_stats(const envoy_api_v2_endpoint_UpstreamLocalityStats *msg, size_t *len) { return (const envoy_api_v2_endpoint_EndpointLoadMetricStats* const*)_upb_array_accessor(msg, UPB_SIZE(32, 40), len); } |
||||||
|
UPB_INLINE uint32_t envoy_api_v2_endpoint_UpstreamLocalityStats_priority(const envoy_api_v2_endpoint_UpstreamLocalityStats *msg) { return UPB_FIELD_AT(msg, uint32_t, UPB_SIZE(24, 24)); } |
||||||
|
UPB_INLINE const envoy_api_v2_endpoint_UpstreamEndpointStats* const* envoy_api_v2_endpoint_UpstreamLocalityStats_upstream_endpoint_stats(const envoy_api_v2_endpoint_UpstreamLocalityStats *msg, size_t *len) { return (const envoy_api_v2_endpoint_UpstreamEndpointStats* const*)_upb_array_accessor(msg, UPB_SIZE(36, 48), len); } |
||||||
|
|
||||||
|
UPB_INLINE void envoy_api_v2_endpoint_UpstreamLocalityStats_set_locality(envoy_api_v2_endpoint_UpstreamLocalityStats *msg, struct envoy_api_v2_core_Locality* value) { |
||||||
|
UPB_FIELD_AT(msg, struct envoy_api_v2_core_Locality*, UPB_SIZE(28, 32)) = value; |
||||||
|
} |
||||||
|
UPB_INLINE struct envoy_api_v2_core_Locality* envoy_api_v2_endpoint_UpstreamLocalityStats_mutable_locality(envoy_api_v2_endpoint_UpstreamLocalityStats *msg, upb_arena *arena) { |
||||||
|
struct envoy_api_v2_core_Locality* sub = (struct envoy_api_v2_core_Locality*)envoy_api_v2_endpoint_UpstreamLocalityStats_locality(msg); |
||||||
|
if (sub == NULL) { |
||||||
|
sub = (struct envoy_api_v2_core_Locality*)upb_msg_new(&envoy_api_v2_core_Locality_msginit, arena); |
||||||
|
if (!sub) return NULL; |
||||||
|
envoy_api_v2_endpoint_UpstreamLocalityStats_set_locality(msg, sub); |
||||||
|
} |
||||||
|
return sub; |
||||||
|
} |
||||||
|
UPB_INLINE void envoy_api_v2_endpoint_UpstreamLocalityStats_set_total_successful_requests(envoy_api_v2_endpoint_UpstreamLocalityStats *msg, uint64_t value) { |
||||||
|
UPB_FIELD_AT(msg, uint64_t, UPB_SIZE(0, 0)) = value; |
||||||
|
} |
||||||
|
UPB_INLINE void envoy_api_v2_endpoint_UpstreamLocalityStats_set_total_requests_in_progress(envoy_api_v2_endpoint_UpstreamLocalityStats *msg, uint64_t value) { |
||||||
|
UPB_FIELD_AT(msg, uint64_t, UPB_SIZE(8, 8)) = value; |
||||||
|
} |
||||||
|
UPB_INLINE void envoy_api_v2_endpoint_UpstreamLocalityStats_set_total_error_requests(envoy_api_v2_endpoint_UpstreamLocalityStats *msg, uint64_t value) { |
||||||
|
UPB_FIELD_AT(msg, uint64_t, UPB_SIZE(16, 16)) = value; |
||||||
|
} |
||||||
|
UPB_INLINE envoy_api_v2_endpoint_EndpointLoadMetricStats** envoy_api_v2_endpoint_UpstreamLocalityStats_mutable_load_metric_stats(envoy_api_v2_endpoint_UpstreamLocalityStats *msg, size_t *len) { |
||||||
|
return (envoy_api_v2_endpoint_EndpointLoadMetricStats**)_upb_array_mutable_accessor(msg, UPB_SIZE(32, 40), len); |
||||||
|
} |
||||||
|
UPB_INLINE envoy_api_v2_endpoint_EndpointLoadMetricStats** envoy_api_v2_endpoint_UpstreamLocalityStats_resize_load_metric_stats(envoy_api_v2_endpoint_UpstreamLocalityStats *msg, size_t len, upb_arena *arena) { |
||||||
|
return (envoy_api_v2_endpoint_EndpointLoadMetricStats**)_upb_array_resize_accessor(msg, UPB_SIZE(32, 40), len, UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, arena); |
||||||
|
} |
||||||
|
UPB_INLINE struct envoy_api_v2_endpoint_EndpointLoadMetricStats* envoy_api_v2_endpoint_UpstreamLocalityStats_add_load_metric_stats(envoy_api_v2_endpoint_UpstreamLocalityStats *msg, upb_arena *arena) { |
||||||
|
struct envoy_api_v2_endpoint_EndpointLoadMetricStats* sub = (struct envoy_api_v2_endpoint_EndpointLoadMetricStats*)upb_msg_new(&envoy_api_v2_endpoint_EndpointLoadMetricStats_msginit, arena); |
||||||
|
bool ok = _upb_array_append_accessor( |
||||||
|
msg, UPB_SIZE(32, 40), UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, &sub, arena); |
||||||
|
if (!ok) return NULL; |
||||||
|
return sub; |
||||||
|
} |
||||||
|
UPB_INLINE void envoy_api_v2_endpoint_UpstreamLocalityStats_set_priority(envoy_api_v2_endpoint_UpstreamLocalityStats *msg, uint32_t value) { |
||||||
|
UPB_FIELD_AT(msg, uint32_t, UPB_SIZE(24, 24)) = value; |
||||||
|
} |
||||||
|
UPB_INLINE envoy_api_v2_endpoint_UpstreamEndpointStats** envoy_api_v2_endpoint_UpstreamLocalityStats_mutable_upstream_endpoint_stats(envoy_api_v2_endpoint_UpstreamLocalityStats *msg, size_t *len) { |
||||||
|
return (envoy_api_v2_endpoint_UpstreamEndpointStats**)_upb_array_mutable_accessor(msg, UPB_SIZE(36, 48), len); |
||||||
|
} |
||||||
|
UPB_INLINE envoy_api_v2_endpoint_UpstreamEndpointStats** envoy_api_v2_endpoint_UpstreamLocalityStats_resize_upstream_endpoint_stats(envoy_api_v2_endpoint_UpstreamLocalityStats *msg, size_t len, upb_arena *arena) { |
||||||
|
return (envoy_api_v2_endpoint_UpstreamEndpointStats**)_upb_array_resize_accessor(msg, UPB_SIZE(36, 48), len, UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, arena); |
||||||
|
} |
||||||
|
UPB_INLINE struct envoy_api_v2_endpoint_UpstreamEndpointStats* envoy_api_v2_endpoint_UpstreamLocalityStats_add_upstream_endpoint_stats(envoy_api_v2_endpoint_UpstreamLocalityStats *msg, upb_arena *arena) { |
||||||
|
struct envoy_api_v2_endpoint_UpstreamEndpointStats* sub = (struct envoy_api_v2_endpoint_UpstreamEndpointStats*)upb_msg_new(&envoy_api_v2_endpoint_UpstreamEndpointStats_msginit, arena); |
||||||
|
bool ok = _upb_array_append_accessor( |
||||||
|
msg, UPB_SIZE(36, 48), UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, &sub, arena); |
||||||
|
if (!ok) return NULL; |
||||||
|
return sub; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
/* envoy.api.v2.endpoint.UpstreamEndpointStats */ |
||||||
|
|
||||||
|
UPB_INLINE envoy_api_v2_endpoint_UpstreamEndpointStats *envoy_api_v2_endpoint_UpstreamEndpointStats_new(upb_arena *arena) { |
||||||
|
return (envoy_api_v2_endpoint_UpstreamEndpointStats *)upb_msg_new(&envoy_api_v2_endpoint_UpstreamEndpointStats_msginit, arena); |
||||||
|
} |
||||||
|
UPB_INLINE envoy_api_v2_endpoint_UpstreamEndpointStats *envoy_api_v2_endpoint_UpstreamEndpointStats_parsenew(upb_strview buf, upb_arena *arena) { |
||||||
|
envoy_api_v2_endpoint_UpstreamEndpointStats *ret = envoy_api_v2_endpoint_UpstreamEndpointStats_new(arena); |
||||||
|
return (ret && upb_decode(buf, ret, &envoy_api_v2_endpoint_UpstreamEndpointStats_msginit)) ? ret : NULL; |
||||||
|
} |
||||||
|
UPB_INLINE char *envoy_api_v2_endpoint_UpstreamEndpointStats_serialize(const envoy_api_v2_endpoint_UpstreamEndpointStats *msg, upb_arena *arena, size_t *len) { |
||||||
|
return upb_encode(msg, &envoy_api_v2_endpoint_UpstreamEndpointStats_msginit, arena, len); |
||||||
|
} |
||||||
|
|
||||||
|
UPB_INLINE const struct envoy_api_v2_core_Address* envoy_api_v2_endpoint_UpstreamEndpointStats_address(const envoy_api_v2_endpoint_UpstreamEndpointStats *msg) { return UPB_FIELD_AT(msg, const struct envoy_api_v2_core_Address*, UPB_SIZE(24, 24)); } |
||||||
|
UPB_INLINE uint64_t envoy_api_v2_endpoint_UpstreamEndpointStats_total_successful_requests(const envoy_api_v2_endpoint_UpstreamEndpointStats *msg) { return UPB_FIELD_AT(msg, uint64_t, UPB_SIZE(0, 0)); } |
||||||
|
UPB_INLINE uint64_t envoy_api_v2_endpoint_UpstreamEndpointStats_total_requests_in_progress(const envoy_api_v2_endpoint_UpstreamEndpointStats *msg) { return UPB_FIELD_AT(msg, uint64_t, UPB_SIZE(8, 8)); } |
||||||
|
UPB_INLINE uint64_t envoy_api_v2_endpoint_UpstreamEndpointStats_total_error_requests(const envoy_api_v2_endpoint_UpstreamEndpointStats *msg) { return UPB_FIELD_AT(msg, uint64_t, UPB_SIZE(16, 16)); } |
||||||
|
UPB_INLINE const envoy_api_v2_endpoint_EndpointLoadMetricStats* const* envoy_api_v2_endpoint_UpstreamEndpointStats_load_metric_stats(const envoy_api_v2_endpoint_UpstreamEndpointStats *msg, size_t *len) { return (const envoy_api_v2_endpoint_EndpointLoadMetricStats* const*)_upb_array_accessor(msg, UPB_SIZE(28, 32), len); } |
||||||
|
|
||||||
|
UPB_INLINE void envoy_api_v2_endpoint_UpstreamEndpointStats_set_address(envoy_api_v2_endpoint_UpstreamEndpointStats *msg, struct envoy_api_v2_core_Address* value) { |
||||||
|
UPB_FIELD_AT(msg, struct envoy_api_v2_core_Address*, UPB_SIZE(24, 24)) = value; |
||||||
|
} |
||||||
|
UPB_INLINE struct envoy_api_v2_core_Address* envoy_api_v2_endpoint_UpstreamEndpointStats_mutable_address(envoy_api_v2_endpoint_UpstreamEndpointStats *msg, upb_arena *arena) { |
||||||
|
struct envoy_api_v2_core_Address* sub = (struct envoy_api_v2_core_Address*)envoy_api_v2_endpoint_UpstreamEndpointStats_address(msg); |
||||||
|
if (sub == NULL) { |
||||||
|
sub = (struct envoy_api_v2_core_Address*)upb_msg_new(&envoy_api_v2_core_Address_msginit, arena); |
||||||
|
if (!sub) return NULL; |
||||||
|
envoy_api_v2_endpoint_UpstreamEndpointStats_set_address(msg, sub); |
||||||
|
} |
||||||
|
return sub; |
||||||
|
} |
||||||
|
UPB_INLINE void envoy_api_v2_endpoint_UpstreamEndpointStats_set_total_successful_requests(envoy_api_v2_endpoint_UpstreamEndpointStats *msg, uint64_t value) { |
||||||
|
UPB_FIELD_AT(msg, uint64_t, UPB_SIZE(0, 0)) = value; |
||||||
|
} |
||||||
|
UPB_INLINE void envoy_api_v2_endpoint_UpstreamEndpointStats_set_total_requests_in_progress(envoy_api_v2_endpoint_UpstreamEndpointStats *msg, uint64_t value) { |
||||||
|
UPB_FIELD_AT(msg, uint64_t, UPB_SIZE(8, 8)) = value; |
||||||
|
} |
||||||
|
UPB_INLINE void envoy_api_v2_endpoint_UpstreamEndpointStats_set_total_error_requests(envoy_api_v2_endpoint_UpstreamEndpointStats *msg, uint64_t value) { |
||||||
|
UPB_FIELD_AT(msg, uint64_t, UPB_SIZE(16, 16)) = value; |
||||||
|
} |
||||||
|
UPB_INLINE envoy_api_v2_endpoint_EndpointLoadMetricStats** envoy_api_v2_endpoint_UpstreamEndpointStats_mutable_load_metric_stats(envoy_api_v2_endpoint_UpstreamEndpointStats *msg, size_t *len) { |
||||||
|
return (envoy_api_v2_endpoint_EndpointLoadMetricStats**)_upb_array_mutable_accessor(msg, UPB_SIZE(28, 32), len); |
||||||
|
} |
||||||
|
UPB_INLINE envoy_api_v2_endpoint_EndpointLoadMetricStats** envoy_api_v2_endpoint_UpstreamEndpointStats_resize_load_metric_stats(envoy_api_v2_endpoint_UpstreamEndpointStats *msg, size_t len, upb_arena *arena) { |
||||||
|
return (envoy_api_v2_endpoint_EndpointLoadMetricStats**)_upb_array_resize_accessor(msg, UPB_SIZE(28, 32), len, UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, arena); |
||||||
|
} |
||||||
|
UPB_INLINE struct envoy_api_v2_endpoint_EndpointLoadMetricStats* envoy_api_v2_endpoint_UpstreamEndpointStats_add_load_metric_stats(envoy_api_v2_endpoint_UpstreamEndpointStats *msg, upb_arena *arena) { |
||||||
|
struct envoy_api_v2_endpoint_EndpointLoadMetricStats* sub = (struct envoy_api_v2_endpoint_EndpointLoadMetricStats*)upb_msg_new(&envoy_api_v2_endpoint_EndpointLoadMetricStats_msginit, arena); |
||||||
|
bool ok = _upb_array_append_accessor( |
||||||
|
msg, UPB_SIZE(28, 32), UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, &sub, arena); |
||||||
|
if (!ok) return NULL; |
||||||
|
return sub; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
/* envoy.api.v2.endpoint.EndpointLoadMetricStats */ |
||||||
|
|
||||||
|
UPB_INLINE envoy_api_v2_endpoint_EndpointLoadMetricStats *envoy_api_v2_endpoint_EndpointLoadMetricStats_new(upb_arena *arena) { |
||||||
|
return (envoy_api_v2_endpoint_EndpointLoadMetricStats *)upb_msg_new(&envoy_api_v2_endpoint_EndpointLoadMetricStats_msginit, arena); |
||||||
|
} |
||||||
|
UPB_INLINE envoy_api_v2_endpoint_EndpointLoadMetricStats *envoy_api_v2_endpoint_EndpointLoadMetricStats_parsenew(upb_strview buf, upb_arena *arena) { |
||||||
|
envoy_api_v2_endpoint_EndpointLoadMetricStats *ret = envoy_api_v2_endpoint_EndpointLoadMetricStats_new(arena); |
||||||
|
return (ret && upb_decode(buf, ret, &envoy_api_v2_endpoint_EndpointLoadMetricStats_msginit)) ? ret : NULL; |
||||||
|
} |
||||||
|
UPB_INLINE char *envoy_api_v2_endpoint_EndpointLoadMetricStats_serialize(const envoy_api_v2_endpoint_EndpointLoadMetricStats *msg, upb_arena *arena, size_t *len) { |
||||||
|
return upb_encode(msg, &envoy_api_v2_endpoint_EndpointLoadMetricStats_msginit, arena, len); |
||||||
|
} |
||||||
|
|
||||||
|
UPB_INLINE upb_strview envoy_api_v2_endpoint_EndpointLoadMetricStats_metric_name(const envoy_api_v2_endpoint_EndpointLoadMetricStats *msg) { return UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(16, 16)); } |
||||||
|
UPB_INLINE uint64_t envoy_api_v2_endpoint_EndpointLoadMetricStats_num_requests_finished_with_metric(const envoy_api_v2_endpoint_EndpointLoadMetricStats *msg) { return UPB_FIELD_AT(msg, uint64_t, UPB_SIZE(0, 0)); } |
||||||
|
UPB_INLINE double envoy_api_v2_endpoint_EndpointLoadMetricStats_total_metric_value(const envoy_api_v2_endpoint_EndpointLoadMetricStats *msg) { return UPB_FIELD_AT(msg, double, UPB_SIZE(8, 8)); } |
||||||
|
|
||||||
|
UPB_INLINE void envoy_api_v2_endpoint_EndpointLoadMetricStats_set_metric_name(envoy_api_v2_endpoint_EndpointLoadMetricStats *msg, upb_strview value) { |
||||||
|
UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(16, 16)) = value; |
||||||
|
} |
||||||
|
UPB_INLINE void envoy_api_v2_endpoint_EndpointLoadMetricStats_set_num_requests_finished_with_metric(envoy_api_v2_endpoint_EndpointLoadMetricStats *msg, uint64_t value) { |
||||||
|
UPB_FIELD_AT(msg, uint64_t, UPB_SIZE(0, 0)) = value; |
||||||
|
} |
||||||
|
UPB_INLINE void envoy_api_v2_endpoint_EndpointLoadMetricStats_set_total_metric_value(envoy_api_v2_endpoint_EndpointLoadMetricStats *msg, double value) { |
||||||
|
UPB_FIELD_AT(msg, double, UPB_SIZE(8, 8)) = value; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
/* envoy.api.v2.endpoint.ClusterStats */ |
||||||
|
|
||||||
|
UPB_INLINE envoy_api_v2_endpoint_ClusterStats *envoy_api_v2_endpoint_ClusterStats_new(upb_arena *arena) { |
||||||
|
return (envoy_api_v2_endpoint_ClusterStats *)upb_msg_new(&envoy_api_v2_endpoint_ClusterStats_msginit, arena); |
||||||
|
} |
||||||
|
UPB_INLINE envoy_api_v2_endpoint_ClusterStats *envoy_api_v2_endpoint_ClusterStats_parsenew(upb_strview buf, upb_arena *arena) { |
||||||
|
envoy_api_v2_endpoint_ClusterStats *ret = envoy_api_v2_endpoint_ClusterStats_new(arena); |
||||||
|
return (ret && upb_decode(buf, ret, &envoy_api_v2_endpoint_ClusterStats_msginit)) ? ret : NULL; |
||||||
|
} |
||||||
|
UPB_INLINE char *envoy_api_v2_endpoint_ClusterStats_serialize(const envoy_api_v2_endpoint_ClusterStats *msg, upb_arena *arena, size_t *len) { |
||||||
|
return upb_encode(msg, &envoy_api_v2_endpoint_ClusterStats_msginit, arena, len); |
||||||
|
} |
||||||
|
|
||||||
|
UPB_INLINE upb_strview envoy_api_v2_endpoint_ClusterStats_cluster_name(const envoy_api_v2_endpoint_ClusterStats *msg) { return UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(8, 8)); } |
||||||
|
UPB_INLINE const envoy_api_v2_endpoint_UpstreamLocalityStats* const* envoy_api_v2_endpoint_ClusterStats_upstream_locality_stats(const envoy_api_v2_endpoint_ClusterStats *msg, size_t *len) { return (const envoy_api_v2_endpoint_UpstreamLocalityStats* const*)_upb_array_accessor(msg, UPB_SIZE(20, 32), len); } |
||||||
|
UPB_INLINE uint64_t envoy_api_v2_endpoint_ClusterStats_total_dropped_requests(const envoy_api_v2_endpoint_ClusterStats *msg) { return UPB_FIELD_AT(msg, uint64_t, UPB_SIZE(0, 0)); } |
||||||
|
UPB_INLINE const struct google_protobuf_Duration* envoy_api_v2_endpoint_ClusterStats_load_report_interval(const envoy_api_v2_endpoint_ClusterStats *msg) { return UPB_FIELD_AT(msg, const struct google_protobuf_Duration*, UPB_SIZE(16, 24)); } |
||||||
|
UPB_INLINE const envoy_api_v2_endpoint_ClusterStats_DroppedRequests* const* envoy_api_v2_endpoint_ClusterStats_dropped_requests(const envoy_api_v2_endpoint_ClusterStats *msg, size_t *len) { return (const envoy_api_v2_endpoint_ClusterStats_DroppedRequests* const*)_upb_array_accessor(msg, UPB_SIZE(24, 40), len); } |
||||||
|
|
||||||
|
UPB_INLINE void envoy_api_v2_endpoint_ClusterStats_set_cluster_name(envoy_api_v2_endpoint_ClusterStats *msg, upb_strview value) { |
||||||
|
UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(8, 8)) = value; |
||||||
|
} |
||||||
|
UPB_INLINE envoy_api_v2_endpoint_UpstreamLocalityStats** envoy_api_v2_endpoint_ClusterStats_mutable_upstream_locality_stats(envoy_api_v2_endpoint_ClusterStats *msg, size_t *len) { |
||||||
|
return (envoy_api_v2_endpoint_UpstreamLocalityStats**)_upb_array_mutable_accessor(msg, UPB_SIZE(20, 32), len); |
||||||
|
} |
||||||
|
UPB_INLINE envoy_api_v2_endpoint_UpstreamLocalityStats** envoy_api_v2_endpoint_ClusterStats_resize_upstream_locality_stats(envoy_api_v2_endpoint_ClusterStats *msg, size_t len, upb_arena *arena) { |
||||||
|
return (envoy_api_v2_endpoint_UpstreamLocalityStats**)_upb_array_resize_accessor(msg, UPB_SIZE(20, 32), len, UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, arena); |
||||||
|
} |
||||||
|
UPB_INLINE struct envoy_api_v2_endpoint_UpstreamLocalityStats* envoy_api_v2_endpoint_ClusterStats_add_upstream_locality_stats(envoy_api_v2_endpoint_ClusterStats *msg, upb_arena *arena) { |
||||||
|
struct envoy_api_v2_endpoint_UpstreamLocalityStats* sub = (struct envoy_api_v2_endpoint_UpstreamLocalityStats*)upb_msg_new(&envoy_api_v2_endpoint_UpstreamLocalityStats_msginit, arena); |
||||||
|
bool ok = _upb_array_append_accessor( |
||||||
|
msg, UPB_SIZE(20, 32), UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, &sub, arena); |
||||||
|
if (!ok) return NULL; |
||||||
|
return sub; |
||||||
|
} |
||||||
|
UPB_INLINE void envoy_api_v2_endpoint_ClusterStats_set_total_dropped_requests(envoy_api_v2_endpoint_ClusterStats *msg, uint64_t value) { |
||||||
|
UPB_FIELD_AT(msg, uint64_t, UPB_SIZE(0, 0)) = value; |
||||||
|
} |
||||||
|
UPB_INLINE void envoy_api_v2_endpoint_ClusterStats_set_load_report_interval(envoy_api_v2_endpoint_ClusterStats *msg, struct google_protobuf_Duration* value) { |
||||||
|
UPB_FIELD_AT(msg, struct google_protobuf_Duration*, UPB_SIZE(16, 24)) = value; |
||||||
|
} |
||||||
|
UPB_INLINE struct google_protobuf_Duration* envoy_api_v2_endpoint_ClusterStats_mutable_load_report_interval(envoy_api_v2_endpoint_ClusterStats *msg, upb_arena *arena) { |
||||||
|
struct google_protobuf_Duration* sub = (struct google_protobuf_Duration*)envoy_api_v2_endpoint_ClusterStats_load_report_interval(msg); |
||||||
|
if (sub == NULL) { |
||||||
|
sub = (struct google_protobuf_Duration*)upb_msg_new(&google_protobuf_Duration_msginit, arena); |
||||||
|
if (!sub) return NULL; |
||||||
|
envoy_api_v2_endpoint_ClusterStats_set_load_report_interval(msg, sub); |
||||||
|
} |
||||||
|
return sub; |
||||||
|
} |
||||||
|
UPB_INLINE envoy_api_v2_endpoint_ClusterStats_DroppedRequests** envoy_api_v2_endpoint_ClusterStats_mutable_dropped_requests(envoy_api_v2_endpoint_ClusterStats *msg, size_t *len) { |
||||||
|
return (envoy_api_v2_endpoint_ClusterStats_DroppedRequests**)_upb_array_mutable_accessor(msg, UPB_SIZE(24, 40), len); |
||||||
|
} |
||||||
|
UPB_INLINE envoy_api_v2_endpoint_ClusterStats_DroppedRequests** envoy_api_v2_endpoint_ClusterStats_resize_dropped_requests(envoy_api_v2_endpoint_ClusterStats *msg, size_t len, upb_arena *arena) { |
||||||
|
return (envoy_api_v2_endpoint_ClusterStats_DroppedRequests**)_upb_array_resize_accessor(msg, UPB_SIZE(24, 40), len, UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, arena); |
||||||
|
} |
||||||
|
UPB_INLINE struct envoy_api_v2_endpoint_ClusterStats_DroppedRequests* envoy_api_v2_endpoint_ClusterStats_add_dropped_requests(envoy_api_v2_endpoint_ClusterStats *msg, upb_arena *arena) { |
||||||
|
struct envoy_api_v2_endpoint_ClusterStats_DroppedRequests* sub = (struct envoy_api_v2_endpoint_ClusterStats_DroppedRequests*)upb_msg_new(&envoy_api_v2_endpoint_ClusterStats_DroppedRequests_msginit, arena); |
||||||
|
bool ok = _upb_array_append_accessor( |
||||||
|
msg, UPB_SIZE(24, 40), UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, &sub, arena); |
||||||
|
if (!ok) return NULL; |
||||||
|
return sub; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
/* envoy.api.v2.endpoint.ClusterStats.DroppedRequests */ |
||||||
|
|
||||||
|
UPB_INLINE envoy_api_v2_endpoint_ClusterStats_DroppedRequests *envoy_api_v2_endpoint_ClusterStats_DroppedRequests_new(upb_arena *arena) { |
||||||
|
return (envoy_api_v2_endpoint_ClusterStats_DroppedRequests *)upb_msg_new(&envoy_api_v2_endpoint_ClusterStats_DroppedRequests_msginit, arena); |
||||||
|
} |
||||||
|
UPB_INLINE envoy_api_v2_endpoint_ClusterStats_DroppedRequests *envoy_api_v2_endpoint_ClusterStats_DroppedRequests_parsenew(upb_strview buf, upb_arena *arena) { |
||||||
|
envoy_api_v2_endpoint_ClusterStats_DroppedRequests *ret = envoy_api_v2_endpoint_ClusterStats_DroppedRequests_new(arena); |
||||||
|
return (ret && upb_decode(buf, ret, &envoy_api_v2_endpoint_ClusterStats_DroppedRequests_msginit)) ? ret : NULL; |
||||||
|
} |
||||||
|
UPB_INLINE char *envoy_api_v2_endpoint_ClusterStats_DroppedRequests_serialize(const envoy_api_v2_endpoint_ClusterStats_DroppedRequests *msg, upb_arena *arena, size_t *len) { |
||||||
|
return upb_encode(msg, &envoy_api_v2_endpoint_ClusterStats_DroppedRequests_msginit, arena, len); |
||||||
|
} |
||||||
|
|
||||||
|
UPB_INLINE upb_strview envoy_api_v2_endpoint_ClusterStats_DroppedRequests_category(const envoy_api_v2_endpoint_ClusterStats_DroppedRequests *msg) { return UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(8, 8)); } |
||||||
|
UPB_INLINE uint64_t envoy_api_v2_endpoint_ClusterStats_DroppedRequests_dropped_count(const envoy_api_v2_endpoint_ClusterStats_DroppedRequests *msg) { return UPB_FIELD_AT(msg, uint64_t, UPB_SIZE(0, 0)); } |
||||||
|
|
||||||
|
UPB_INLINE void envoy_api_v2_endpoint_ClusterStats_DroppedRequests_set_category(envoy_api_v2_endpoint_ClusterStats_DroppedRequests *msg, upb_strview value) { |
||||||
|
UPB_FIELD_AT(msg, upb_strview, UPB_SIZE(8, 8)) = value; |
||||||
|
} |
||||||
|
UPB_INLINE void envoy_api_v2_endpoint_ClusterStats_DroppedRequests_set_dropped_count(envoy_api_v2_endpoint_ClusterStats_DroppedRequests *msg, uint64_t value) { |
||||||
|
UPB_FIELD_AT(msg, uint64_t, UPB_SIZE(0, 0)) = value; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
#ifdef __cplusplus |
||||||
|
} /* extern "C" */ |
||||||
|
#endif |
||||||
|
|
||||||
|
#include "upb/port_undef.inc" |
||||||
|
|
||||||
|
#endif /* ENVOY_API_V2_ENDPOINT_LOAD_REPORT_PROTO_UPB_H_ */ |
@ -0,0 +1,52 @@ |
|||||||
|
/* This file was generated by upbc (the upb compiler) from the input
|
||||||
|
* file: |
||||||
|
* |
||||||
|
* envoy/service/load_stats/v2/lrs.proto |
||||||
|
* |
||||||
|
* Do not edit -- your changes will be discarded when the file is |
||||||
|
* regenerated. */ |
||||||
|
|
||||||
|
#include <stddef.h> |
||||||
|
#include "upb/msg.h" |
||||||
|
#include "envoy/service/load_stats/v2/lrs.upb.h" |
||||||
|
#include "envoy/api/v2/core/base.upb.h" |
||||||
|
#include "envoy/api/v2/endpoint/load_report.upb.h" |
||||||
|
#include "google/protobuf/duration.upb.h" |
||||||
|
#include "validate/validate.upb.h" |
||||||
|
|
||||||
|
#include "upb/port_def.inc" |
||||||
|
|
||||||
|
static const upb_msglayout *const envoy_service_load_stats_v2_LoadStatsRequest_submsgs[2] = { |
||||||
|
&envoy_api_v2_core_Node_msginit, |
||||||
|
&envoy_api_v2_endpoint_ClusterStats_msginit, |
||||||
|
}; |
||||||
|
|
||||||
|
static const upb_msglayout_field envoy_service_load_stats_v2_LoadStatsRequest__fields[2] = { |
||||||
|
{1, UPB_SIZE(0, 0), 0, 0, 11, 1}, |
||||||
|
{2, UPB_SIZE(4, 8), 0, 1, 11, 3}, |
||||||
|
}; |
||||||
|
|
||||||
|
const upb_msglayout envoy_service_load_stats_v2_LoadStatsRequest_msginit = { |
||||||
|
&envoy_service_load_stats_v2_LoadStatsRequest_submsgs[0], |
||||||
|
&envoy_service_load_stats_v2_LoadStatsRequest__fields[0], |
||||||
|
UPB_SIZE(8, 16), 2, false, |
||||||
|
}; |
||||||
|
|
||||||
|
static const upb_msglayout *const envoy_service_load_stats_v2_LoadStatsResponse_submsgs[1] = { |
||||||
|
&google_protobuf_Duration_msginit, |
||||||
|
}; |
||||||
|
|
||||||
|
static const upb_msglayout_field envoy_service_load_stats_v2_LoadStatsResponse__fields[3] = { |
||||||
|
{1, UPB_SIZE(8, 16), 0, 0, 9, 3}, |
||||||
|
{2, UPB_SIZE(4, 8), 0, 0, 11, 1}, |
||||||
|
{3, UPB_SIZE(0, 0), 0, 0, 8, 1}, |
||||||
|
}; |
||||||
|
|
||||||
|
const upb_msglayout envoy_service_load_stats_v2_LoadStatsResponse_msginit = { |
||||||
|
&envoy_service_load_stats_v2_LoadStatsResponse_submsgs[0], |
||||||
|
&envoy_service_load_stats_v2_LoadStatsResponse__fields[0], |
||||||
|
UPB_SIZE(12, 24), 3, false, |
||||||
|
}; |
||||||
|
|
||||||
|
#include "upb/port_undef.inc" |
||||||
|
|
@ -0,0 +1,132 @@ |
|||||||
|
/* This file was generated by upbc (the upb compiler) from the input
|
||||||
|
* file: |
||||||
|
* |
||||||
|
* envoy/service/load_stats/v2/lrs.proto |
||||||
|
* |
||||||
|
* Do not edit -- your changes will be discarded when the file is |
||||||
|
* regenerated. */ |
||||||
|
|
||||||
|
#ifndef ENVOY_SERVICE_LOAD_STATS_V2_LRS_PROTO_UPB_H_ |
||||||
|
#define ENVOY_SERVICE_LOAD_STATS_V2_LRS_PROTO_UPB_H_ |
||||||
|
|
||||||
|
#include "upb/generated_util.h" |
||||||
|
|
||||||
|
#include "upb/msg.h" |
||||||
|
|
||||||
|
#include "upb/decode.h" |
||||||
|
#include "upb/encode.h" |
||||||
|
#include "upb/port_def.inc" |
||||||
|
#ifdef __cplusplus |
||||||
|
extern "C" { |
||||||
|
#endif |
||||||
|
|
||||||
|
struct envoy_service_load_stats_v2_LoadStatsRequest; |
||||||
|
struct envoy_service_load_stats_v2_LoadStatsResponse; |
||||||
|
typedef struct envoy_service_load_stats_v2_LoadStatsRequest envoy_service_load_stats_v2_LoadStatsRequest; |
||||||
|
typedef struct envoy_service_load_stats_v2_LoadStatsResponse envoy_service_load_stats_v2_LoadStatsResponse; |
||||||
|
extern const upb_msglayout envoy_service_load_stats_v2_LoadStatsRequest_msginit; |
||||||
|
extern const upb_msglayout envoy_service_load_stats_v2_LoadStatsResponse_msginit; |
||||||
|
struct envoy_api_v2_core_Node; |
||||||
|
struct envoy_api_v2_endpoint_ClusterStats; |
||||||
|
struct google_protobuf_Duration; |
||||||
|
extern const upb_msglayout envoy_api_v2_core_Node_msginit; |
||||||
|
extern const upb_msglayout envoy_api_v2_endpoint_ClusterStats_msginit; |
||||||
|
extern const upb_msglayout google_protobuf_Duration_msginit; |
||||||
|
|
||||||
|
/* Enums */ |
||||||
|
|
||||||
|
|
||||||
|
/* envoy.service.load_stats.v2.LoadStatsRequest */ |
||||||
|
|
||||||
|
UPB_INLINE envoy_service_load_stats_v2_LoadStatsRequest *envoy_service_load_stats_v2_LoadStatsRequest_new(upb_arena *arena) { |
||||||
|
return (envoy_service_load_stats_v2_LoadStatsRequest *)upb_msg_new(&envoy_service_load_stats_v2_LoadStatsRequest_msginit, arena); |
||||||
|
} |
||||||
|
UPB_INLINE envoy_service_load_stats_v2_LoadStatsRequest *envoy_service_load_stats_v2_LoadStatsRequest_parsenew(upb_strview buf, upb_arena *arena) { |
||||||
|
envoy_service_load_stats_v2_LoadStatsRequest *ret = envoy_service_load_stats_v2_LoadStatsRequest_new(arena); |
||||||
|
return (ret && upb_decode(buf, ret, &envoy_service_load_stats_v2_LoadStatsRequest_msginit)) ? ret : NULL; |
||||||
|
} |
||||||
|
UPB_INLINE char *envoy_service_load_stats_v2_LoadStatsRequest_serialize(const envoy_service_load_stats_v2_LoadStatsRequest *msg, upb_arena *arena, size_t *len) { |
||||||
|
return upb_encode(msg, &envoy_service_load_stats_v2_LoadStatsRequest_msginit, arena, len); |
||||||
|
} |
||||||
|
|
||||||
|
UPB_INLINE const struct envoy_api_v2_core_Node* envoy_service_load_stats_v2_LoadStatsRequest_node(const envoy_service_load_stats_v2_LoadStatsRequest *msg) { return UPB_FIELD_AT(msg, const struct envoy_api_v2_core_Node*, UPB_SIZE(0, 0)); } |
||||||
|
UPB_INLINE const struct envoy_api_v2_endpoint_ClusterStats* const* envoy_service_load_stats_v2_LoadStatsRequest_cluster_stats(const envoy_service_load_stats_v2_LoadStatsRequest *msg, size_t *len) { return (const struct envoy_api_v2_endpoint_ClusterStats* const*)_upb_array_accessor(msg, UPB_SIZE(4, 8), len); } |
||||||
|
|
||||||
|
UPB_INLINE void envoy_service_load_stats_v2_LoadStatsRequest_set_node(envoy_service_load_stats_v2_LoadStatsRequest *msg, struct envoy_api_v2_core_Node* value) { |
||||||
|
UPB_FIELD_AT(msg, struct envoy_api_v2_core_Node*, UPB_SIZE(0, 0)) = value; |
||||||
|
} |
||||||
|
UPB_INLINE struct envoy_api_v2_core_Node* envoy_service_load_stats_v2_LoadStatsRequest_mutable_node(envoy_service_load_stats_v2_LoadStatsRequest *msg, upb_arena *arena) { |
||||||
|
struct envoy_api_v2_core_Node* sub = (struct envoy_api_v2_core_Node*)envoy_service_load_stats_v2_LoadStatsRequest_node(msg); |
||||||
|
if (sub == NULL) { |
||||||
|
sub = (struct envoy_api_v2_core_Node*)upb_msg_new(&envoy_api_v2_core_Node_msginit, arena); |
||||||
|
if (!sub) return NULL; |
||||||
|
envoy_service_load_stats_v2_LoadStatsRequest_set_node(msg, sub); |
||||||
|
} |
||||||
|
return sub; |
||||||
|
} |
||||||
|
UPB_INLINE struct envoy_api_v2_endpoint_ClusterStats** envoy_service_load_stats_v2_LoadStatsRequest_mutable_cluster_stats(envoy_service_load_stats_v2_LoadStatsRequest *msg, size_t *len) { |
||||||
|
return (struct envoy_api_v2_endpoint_ClusterStats**)_upb_array_mutable_accessor(msg, UPB_SIZE(4, 8), len); |
||||||
|
} |
||||||
|
UPB_INLINE struct envoy_api_v2_endpoint_ClusterStats** envoy_service_load_stats_v2_LoadStatsRequest_resize_cluster_stats(envoy_service_load_stats_v2_LoadStatsRequest *msg, size_t len, upb_arena *arena) { |
||||||
|
return (struct envoy_api_v2_endpoint_ClusterStats**)_upb_array_resize_accessor(msg, UPB_SIZE(4, 8), len, UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, arena); |
||||||
|
} |
||||||
|
UPB_INLINE struct envoy_api_v2_endpoint_ClusterStats* envoy_service_load_stats_v2_LoadStatsRequest_add_cluster_stats(envoy_service_load_stats_v2_LoadStatsRequest *msg, upb_arena *arena) { |
||||||
|
struct envoy_api_v2_endpoint_ClusterStats* sub = (struct envoy_api_v2_endpoint_ClusterStats*)upb_msg_new(&envoy_api_v2_endpoint_ClusterStats_msginit, arena); |
||||||
|
bool ok = _upb_array_append_accessor( |
||||||
|
msg, UPB_SIZE(4, 8), UPB_SIZE(4, 8), UPB_TYPE_MESSAGE, &sub, arena); |
||||||
|
if (!ok) return NULL; |
||||||
|
return sub; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
/* envoy.service.load_stats.v2.LoadStatsResponse */ |
||||||
|
|
||||||
|
UPB_INLINE envoy_service_load_stats_v2_LoadStatsResponse *envoy_service_load_stats_v2_LoadStatsResponse_new(upb_arena *arena) { |
||||||
|
return (envoy_service_load_stats_v2_LoadStatsResponse *)upb_msg_new(&envoy_service_load_stats_v2_LoadStatsResponse_msginit, arena); |
||||||
|
} |
||||||
|
UPB_INLINE envoy_service_load_stats_v2_LoadStatsResponse *envoy_service_load_stats_v2_LoadStatsResponse_parsenew(upb_strview buf, upb_arena *arena) { |
||||||
|
envoy_service_load_stats_v2_LoadStatsResponse *ret = envoy_service_load_stats_v2_LoadStatsResponse_new(arena); |
||||||
|
return (ret && upb_decode(buf, ret, &envoy_service_load_stats_v2_LoadStatsResponse_msginit)) ? ret : NULL; |
||||||
|
} |
||||||
|
UPB_INLINE char *envoy_service_load_stats_v2_LoadStatsResponse_serialize(const envoy_service_load_stats_v2_LoadStatsResponse *msg, upb_arena *arena, size_t *len) { |
||||||
|
return upb_encode(msg, &envoy_service_load_stats_v2_LoadStatsResponse_msginit, arena, len); |
||||||
|
} |
||||||
|
|
||||||
|
UPB_INLINE upb_strview const* envoy_service_load_stats_v2_LoadStatsResponse_clusters(const envoy_service_load_stats_v2_LoadStatsResponse *msg, size_t *len) { return (upb_strview const*)_upb_array_accessor(msg, UPB_SIZE(8, 16), len); } |
||||||
|
UPB_INLINE const struct google_protobuf_Duration* envoy_service_load_stats_v2_LoadStatsResponse_load_reporting_interval(const envoy_service_load_stats_v2_LoadStatsResponse *msg) { return UPB_FIELD_AT(msg, const struct google_protobuf_Duration*, UPB_SIZE(4, 8)); } |
||||||
|
UPB_INLINE bool envoy_service_load_stats_v2_LoadStatsResponse_report_endpoint_granularity(const envoy_service_load_stats_v2_LoadStatsResponse *msg) { return UPB_FIELD_AT(msg, bool, UPB_SIZE(0, 0)); } |
||||||
|
|
||||||
|
UPB_INLINE upb_strview* envoy_service_load_stats_v2_LoadStatsResponse_mutable_clusters(envoy_service_load_stats_v2_LoadStatsResponse *msg, size_t *len) { |
||||||
|
return (upb_strview*)_upb_array_mutable_accessor(msg, UPB_SIZE(8, 16), len); |
||||||
|
} |
||||||
|
UPB_INLINE upb_strview* envoy_service_load_stats_v2_LoadStatsResponse_resize_clusters(envoy_service_load_stats_v2_LoadStatsResponse *msg, size_t len, upb_arena *arena) { |
||||||
|
return (upb_strview*)_upb_array_resize_accessor(msg, UPB_SIZE(8, 16), len, UPB_SIZE(8, 16), UPB_TYPE_STRING, arena); |
||||||
|
} |
||||||
|
UPB_INLINE bool envoy_service_load_stats_v2_LoadStatsResponse_add_clusters(envoy_service_load_stats_v2_LoadStatsResponse *msg, upb_strview val, upb_arena *arena) { |
||||||
|
return _upb_array_append_accessor( |
||||||
|
msg, UPB_SIZE(8, 16), UPB_SIZE(8, 16), UPB_TYPE_STRING, &val, arena); |
||||||
|
} |
||||||
|
UPB_INLINE void envoy_service_load_stats_v2_LoadStatsResponse_set_load_reporting_interval(envoy_service_load_stats_v2_LoadStatsResponse *msg, struct google_protobuf_Duration* value) { |
||||||
|
UPB_FIELD_AT(msg, struct google_protobuf_Duration*, UPB_SIZE(4, 8)) = value; |
||||||
|
} |
||||||
|
UPB_INLINE struct google_protobuf_Duration* envoy_service_load_stats_v2_LoadStatsResponse_mutable_load_reporting_interval(envoy_service_load_stats_v2_LoadStatsResponse *msg, upb_arena *arena) { |
||||||
|
struct google_protobuf_Duration* sub = (struct google_protobuf_Duration*)envoy_service_load_stats_v2_LoadStatsResponse_load_reporting_interval(msg); |
||||||
|
if (sub == NULL) { |
||||||
|
sub = (struct google_protobuf_Duration*)upb_msg_new(&google_protobuf_Duration_msginit, arena); |
||||||
|
if (!sub) return NULL; |
||||||
|
envoy_service_load_stats_v2_LoadStatsResponse_set_load_reporting_interval(msg, sub); |
||||||
|
} |
||||||
|
return sub; |
||||||
|
} |
||||||
|
UPB_INLINE void envoy_service_load_stats_v2_LoadStatsResponse_set_report_endpoint_granularity(envoy_service_load_stats_v2_LoadStatsResponse *msg, bool value) { |
||||||
|
UPB_FIELD_AT(msg, bool, UPB_SIZE(0, 0)) = value; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
#ifdef __cplusplus |
||||||
|
} /* extern "C" */ |
||||||
|
#endif |
||||||
|
|
||||||
|
#include "upb/port_undef.inc" |
||||||
|
|
||||||
|
#endif /* ENVOY_SERVICE_LOAD_STATS_V2_LRS_PROTO_UPB_H_ */ |
@ -0,0 +1,127 @@ |
|||||||
|
/*
|
||||||
|
* |
||||||
|
* Copyright 2015 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. |
||||||
|
* |
||||||
|
*/ |
||||||
|
|
||||||
|
#include <grpc/support/port_platform.h> |
||||||
|
|
||||||
|
#include <limits.h> |
||||||
|
#include <string.h> |
||||||
|
|
||||||
|
#include <grpc/compression.h> |
||||||
|
#include <grpc/grpc.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/compression/compression_args.h" |
||||||
|
#include "src/core/lib/gpr/string.h" |
||||||
|
#include "src/core/lib/gpr/useful.h" |
||||||
|
|
||||||
|
grpc_compression_algorithm grpc_channel_args_get_compression_algorithm( |
||||||
|
const grpc_channel_args* a) { |
||||||
|
size_t i; |
||||||
|
if (a == nullptr) return GRPC_COMPRESS_NONE; |
||||||
|
for (i = 0; i < a->num_args; ++i) { |
||||||
|
if (a->args[i].type == GRPC_ARG_INTEGER && |
||||||
|
!strcmp(GRPC_COMPRESSION_CHANNEL_DEFAULT_ALGORITHM, a->args[i].key)) { |
||||||
|
return static_cast<grpc_compression_algorithm>(a->args[i].value.integer); |
||||||
|
break; |
||||||
|
} |
||||||
|
} |
||||||
|
return GRPC_COMPRESS_NONE; |
||||||
|
} |
||||||
|
|
||||||
|
grpc_channel_args* grpc_channel_args_set_compression_algorithm( |
||||||
|
grpc_channel_args* a, grpc_compression_algorithm algorithm) { |
||||||
|
GPR_ASSERT(algorithm < GRPC_COMPRESS_ALGORITHMS_COUNT); |
||||||
|
grpc_arg tmp; |
||||||
|
tmp.type = GRPC_ARG_INTEGER; |
||||||
|
tmp.key = (char*)GRPC_COMPRESSION_CHANNEL_DEFAULT_ALGORITHM; |
||||||
|
tmp.value.integer = algorithm; |
||||||
|
return grpc_channel_args_copy_and_add(a, &tmp, 1); |
||||||
|
} |
||||||
|
|
||||||
|
/** Returns 1 if the argument for compression algorithm's enabled states bitset
|
||||||
|
* was found in \a a, returning the arg's value in \a states. Otherwise, returns |
||||||
|
* 0. */ |
||||||
|
static int find_compression_algorithm_states_bitset(const grpc_channel_args* a, |
||||||
|
int** states_arg) { |
||||||
|
if (a != nullptr) { |
||||||
|
size_t i; |
||||||
|
for (i = 0; i < a->num_args; ++i) { |
||||||
|
if (a->args[i].type == GRPC_ARG_INTEGER && |
||||||
|
!strcmp(GRPC_COMPRESSION_CHANNEL_ENABLED_ALGORITHMS_BITSET, |
||||||
|
a->args[i].key)) { |
||||||
|
*states_arg = &a->args[i].value.integer; |
||||||
|
**states_arg |= 0x1; /* forcefully enable support for no compression */ |
||||||
|
return 1; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
return 0; /* GPR_FALSE */ |
||||||
|
} |
||||||
|
|
||||||
|
grpc_channel_args* grpc_channel_args_compression_algorithm_set_state( |
||||||
|
grpc_channel_args** a, grpc_compression_algorithm algorithm, int state) { |
||||||
|
int* states_arg = nullptr; |
||||||
|
grpc_channel_args* result = *a; |
||||||
|
const int states_arg_found = |
||||||
|
find_compression_algorithm_states_bitset(*a, &states_arg); |
||||||
|
|
||||||
|
if (grpc_channel_args_get_compression_algorithm(*a) == algorithm && |
||||||
|
state == 0) { |
||||||
|
const char* algo_name = nullptr; |
||||||
|
GPR_ASSERT(grpc_compression_algorithm_name(algorithm, &algo_name) != 0); |
||||||
|
gpr_log(GPR_ERROR, |
||||||
|
"Tried to disable default compression algorithm '%s'. The " |
||||||
|
"operation has been ignored.", |
||||||
|
algo_name); |
||||||
|
} else if (states_arg_found) { |
||||||
|
if (state != 0) { |
||||||
|
GPR_BITSET((unsigned*)states_arg, algorithm); |
||||||
|
} else if (algorithm != GRPC_COMPRESS_NONE) { |
||||||
|
GPR_BITCLEAR((unsigned*)states_arg, algorithm); |
||||||
|
} |
||||||
|
} else { |
||||||
|
/* create a new arg */ |
||||||
|
grpc_arg tmp; |
||||||
|
tmp.type = GRPC_ARG_INTEGER; |
||||||
|
tmp.key = (char*)GRPC_COMPRESSION_CHANNEL_ENABLED_ALGORITHMS_BITSET; |
||||||
|
/* all enabled by default */ |
||||||
|
tmp.value.integer = (1u << GRPC_COMPRESS_ALGORITHMS_COUNT) - 1; |
||||||
|
if (state != 0) { |
||||||
|
GPR_BITSET((unsigned*)&tmp.value.integer, algorithm); |
||||||
|
} else if (algorithm != GRPC_COMPRESS_NONE) { |
||||||
|
GPR_BITCLEAR((unsigned*)&tmp.value.integer, algorithm); |
||||||
|
} |
||||||
|
result = grpc_channel_args_copy_and_add(*a, &tmp, 1); |
||||||
|
grpc_channel_args_destroy(*a); |
||||||
|
*a = result; |
||||||
|
} |
||||||
|
return result; |
||||||
|
} |
||||||
|
|
||||||
|
uint32_t grpc_channel_args_compression_algorithm_get_states( |
||||||
|
const grpc_channel_args* a) { |
||||||
|
int* states_arg; |
||||||
|
if (find_compression_algorithm_states_bitset(a, &states_arg)) { |
||||||
|
return static_cast<uint32_t>(*states_arg); |
||||||
|
} else { |
||||||
|
return (1u << GRPC_COMPRESS_ALGORITHMS_COUNT) - 1; /* All algs. enabled */ |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,55 @@ |
|||||||
|
/*
|
||||||
|
* |
||||||
|
* Copyright 2015 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 GRPC_CORE_LIB_COMPRESSION_COMPRESSION_ARGS_H |
||||||
|
#define GRPC_CORE_LIB_COMPRESSION_COMPRESSION_ARGS_H |
||||||
|
|
||||||
|
#include <grpc/support/port_platform.h> |
||||||
|
|
||||||
|
#include <grpc/compression.h> |
||||||
|
#include <grpc/impl/codegen/grpc_types.h> |
||||||
|
|
||||||
|
/** Returns the compression algorithm set in \a a. */ |
||||||
|
grpc_compression_algorithm grpc_channel_args_get_compression_algorithm( |
||||||
|
const grpc_channel_args* a); |
||||||
|
|
||||||
|
/** Returns a channel arg instance with compression enabled. If \a a is
|
||||||
|
* non-NULL, its args are copied. N.B. GRPC_COMPRESS_NONE disables compression |
||||||
|
* for the channel. */ |
||||||
|
grpc_channel_args* grpc_channel_args_set_compression_algorithm( |
||||||
|
grpc_channel_args* a, grpc_compression_algorithm algorithm); |
||||||
|
|
||||||
|
/** Sets the support for the given compression algorithm. By default, all
|
||||||
|
* compression algorithms are enabled. It's an error to disable an algorithm set |
||||||
|
* by grpc_channel_args_set_compression_algorithm. |
||||||
|
* |
||||||
|
* Returns an instance with the updated algorithm states. The \a a pointer is |
||||||
|
* modified to point to the returned instance (which may be different from the |
||||||
|
* input value of \a a). */ |
||||||
|
grpc_channel_args* grpc_channel_args_compression_algorithm_set_state( |
||||||
|
grpc_channel_args** a, grpc_compression_algorithm algorithm, int state); |
||||||
|
|
||||||
|
/** Returns the bitset representing the support state (true for enabled, false
|
||||||
|
* for disabled) for compression algorithms. |
||||||
|
* |
||||||
|
* The i-th bit of the returned bitset corresponds to the i-th entry in the |
||||||
|
* grpc_compression_algorithm enum. */ |
||||||
|
uint32_t grpc_channel_args_compression_algorithm_get_states( |
||||||
|
const grpc_channel_args* a); |
||||||
|
|
||||||
|
#endif /* GRPC_CORE_LIB_COMPRESSION_COMPRESSION_ARGS_H */ |
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue