Viam C++ SDK current
Loading...
Searching...
No Matches
grpc_context_observer.hpp
Go to the documentation of this file.
1
4#pragma once
5
6#include <string>
7#include <vector>
8
9#include <boost/optional/optional.hpp>
10
11#include <viam/sdk/common/grpc_fwd.hpp>
12
13namespace viam {
14namespace sdk {
15
25 public:
36 static const boost::optional<const GrpcContextObserver>& current() noexcept;
37
47 const GrpcServerContext& context() const noexcept;
48
60 std::vector<std::string> get_client_metadata_field_values(const std::string& key) const;
61
73 class Enable;
74 friend class Enable;
75
76 private:
77 explicit GrpcContextObserver(const GrpcServerContext& context) noexcept;
78 const GrpcServerContext& context_;
79};
80
81} // namespace sdk
82} // namespace viam
RAII helper for activating the gRPC context observer for the current thread.
Definition grpc_context_observer.hpp:10
Provides thread-local access to the current gRPC server context during request handling.
Definition grpc_context_observer.hpp:24
static const boost::optional< const GrpcContextObserver > & current() noexcept
Returns the current thread-local gRPC context observer, if one is active.
const GrpcServerContext & context() const noexcept
Returns the underlying gRPC server context.
std::vector< std::string > get_client_metadata_field_values(const std::string &key) const
Retrieves all values for a given metadata key from the client's initial metadata.