userver
C++ Async Framework
Toggle main menu visibility
Loading...
Searching...
No Matches
call_context.hpp
Go to the documentation of this file.
1
#pragma once
2
5
6
#include <grpcpp/server_context.h>
7
8
#include <
userver/tracing/span.hpp
>
9
#include <
userver/utils/any_storage.hpp
>
10
#include <
userver/utils/optional_ref.hpp
>
11
12
#include <
userver/ugrpc/server/storage_context.hpp
>
13
#include <userver/utils/impl/internal_tag_fwd.hpp>
14
15
namespace
google::protobuf {
16
class
Arena;
17
}
18
19
USERVER_NAMESPACE_BEGIN
20
21
namespace
ugrpc::server
{
22
23
namespace
impl {
24
struct
CallState;
25
}
// namespace impl
26
27
class
CallContextBase {
28
public
:
30
// For internal use only.
31
CallContextBase(utils::impl::InternalTag, impl::CallState& state);
33
34
CallContextBase(CallContextBase&&) =
delete
;
35
CallContextBase& operator=(CallContextBase&&) =
delete
;
36
38
grpc::ServerContextBase&
GetServerContext
();
39
41
const
grpc::ServerContextBase&
GetServerContext
()
const
;
42
44
std::string_view
GetCallName
()
const
;
45
47
std::string_view
GetServiceName
()
const
;
48
50
std::string_view
GetMethodName
()
const
;
51
53
tracing::Span
&
GetSpan
();
54
59
utils::OptionalRef<google::protobuf::Arena>
GetArena
()
const
;
60
65
std::shared_ptr<google::protobuf::Arena>
GetArenaSharedPtr
() const noexcept;
66
89
utils
::AnyStorage<
StorageContext
>&
GetStorageContext
();
90
91
protected:
93
// For internal use only.
94
const impl::CallState& GetCallState(
utils
::impl::InternalTag)
const
{
return
state_; }
95
96
// For internal use only.
97
impl::CallState& GetCallState(utils::impl::InternalTag) {
return
state_; }
98
99
// Prevent destruction via pointer to base.
100
~CallContextBase() =
default
;
102
103
private
:
104
impl::CallState& state_;
105
};
106
108
class
CallContext
final :
public
CallContextBase {
109
public
:
111
using
CallContextBase::CallContextBase;
113
};
114
116
class
GenericCallContext
final :
public
CallContextBase {
117
public
:
119
using
CallContextBase::CallContextBase;
121
123
void
SetMetricsCallName
(std::string_view call_name);
124
};
125
126
}
// namespace ugrpc::server
127
128
USERVER_NAMESPACE_END
userver
ugrpc
server
call_context.hpp
Generated on
for userver by
Doxygen
1.17.0