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 <optional>
7#include <string>
8#include <vector>
9
10#include <viam/sdk/common/grpc_fwd.hpp>
11
12namespace viam {
13namespace sdk {
14
24 public:
35 static const std::optional<const GrpcContextObserver>& current() noexcept;
36
46 const GrpcServerContext& context() const noexcept;
47
59 std::vector<std::string> get_client_metadata_field_values(const std::string& key) const;
60
72 class Enable;
73 friend class Enable;
74
75 private:
76 explicit GrpcContextObserver(const GrpcServerContext& context) noexcept;
77 const GrpcServerContext& context_;
78};
79
80} // namespace sdk
81} // 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:23
const GrpcServerContext & context() const noexcept
Returns the underlying gRPC server context.
static const std::optional< const GrpcContextObserver > & current() noexcept
Returns the current thread-local gRPC context observer, if one is active.
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.