Lines
100 %
Functions
#pragma once
#include <cstdint>
#include <string>
#include "envoy/buffer/buffer.h"
#include "envoy/common/platform.h"
#include "envoy/config/core/v3/grpc_service.pb.h"
#include "envoy/server/factory_context.h"
#include "grpcpp/grpcpp.h"
namespace Envoy {
namespace Grpc {
class GoogleGrpcUtils {
public:
/**
* Build grpc::ByteBuffer which aliases the data in a Buffer::InstancePtr.
* @param buffer source data container.
* @return byteBuffer target container aliased to the data in Buffer::Instance and owning the
* Buffer::Instance.
*/
static grpc::ByteBuffer makeByteBuffer(Buffer::InstancePtr&& buffer);
* Build Buffer::Instance which aliases the data in a grpc::ByteBuffer.
* @return a Buffer::InstancePtr aliased to the data in the provided grpc::ByteBuffer and
* owning the corresponding grpc::Slice(s) or nullptr if the grpc::ByteBuffer is bad.
static Buffer::InstancePtr makeBufferInstance(const grpc::ByteBuffer& buffer);
* Build grpc::ChannelArguments from gRPC service config.
* @param config Google gRPC config.
* @return grpc::ChannelArguments corresponding to config.
static grpc::ChannelArguments
channelArgsFromConfig(const envoy::config::core::v3::GrpcService& config);
* Build gRPC channel based on the given GrpcService configuration.
* @param api reference to the Api object
* @return static std::shared_ptr<grpc::Channel> a gRPC channel.
static std::shared_ptr<grpc::Channel>
createChannel(const envoy::config::core::v3::GrpcService& config,
Server::Configuration::CommonFactoryContext& context);
};
} // namespace Grpc
} // namespace Envoy