17
17
namespace NKikimr {
18
18
namespace NGRpcServer {
19
19
20
- /* *
21
- * Context for performing operations on a bidirectional stream
22
- *
23
- * Only one thread is allowed to call methods on this class at any time
24
- */
25
- template <class TIn , class TOut >
26
- class IGRpcStreamingContext : public TThrRefBase {
20
+ class IGRpcStreamingContextBase : public TThrRefBase {
27
21
public:
28
- using ISelf = IGRpcStreamingContext<TIn, TOut>;
29
-
30
22
enum EEv {
31
23
EvBegin = EventSpaceBegin (TKikimrEvents::ES_GRPC_STREAMING),
32
24
@@ -35,11 +27,6 @@ class IGRpcStreamingContext : public TThrRefBase {
35
27
EvNotifiedWhenDone,
36
28
};
37
29
38
- struct TEvReadFinished : public TEventLocal <TEvReadFinished, EvReadFinished> {
39
- TIn Record;
40
- bool Success;
41
- };
42
-
43
30
struct TEvWriteFinished : public TEventLocal <TEvWriteFinished, EvWriteFinished> {
44
31
bool Success;
45
32
};
@@ -53,9 +40,8 @@ class IGRpcStreamingContext : public TThrRefBase {
53
40
};
54
41
55
42
public:
56
- virtual ~IGRpcStreamingContext () = default ;
43
+ virtual ~IGRpcStreamingContextBase () = default ;
57
44
58
- public:
59
45
/* *
60
46
* Asynchronously cancels the request
61
47
*
@@ -79,6 +65,38 @@ class IGRpcStreamingContext : public TThrRefBase {
79
65
*/
80
66
virtual bool Read () = 0;
81
67
68
+ /* *
69
+ * Schedules stream termination with the specified status
70
+ *
71
+ * Only the first call is accepted, after which new Read or Write calls
72
+ * are no longer permitted and ignored.
73
+ */
74
+ virtual bool Finish (const grpc::Status& status) = 0;
75
+
76
+ virtual NYdbGrpc::TAuthState& GetAuthState () const = 0;
77
+ virtual TString GetPeerName () const = 0;
78
+ virtual TVector<TStringBuf> GetPeerMetaValues (TStringBuf key) const = 0;
79
+ virtual grpc_compression_level GetCompressionLevel () const = 0;
80
+ virtual void UseDatabase (const TString& database) = 0;
81
+ virtual TString GetRpcMethodName () const = 0;
82
+ };
83
+
84
+ /* *
85
+ * Context for performing operations on a bidirectional stream
86
+ *
87
+ * Only one thread is allowed to call methods on this class at any time
88
+ */
89
+ template <class TIn , class TOut >
90
+ class IGRpcStreamingContext : public IGRpcStreamingContextBase {
91
+ public:
92
+ using ISelf = IGRpcStreamingContext<TIn, TOut>;
93
+
94
+ struct TEvReadFinished : public TEventLocal <TEvReadFinished, EvReadFinished> {
95
+ TIn Record;
96
+ bool Success;
97
+ };
98
+
99
+ public:
82
100
/* *
83
101
* Schedules the next message write
84
102
*
@@ -88,14 +106,6 @@ class IGRpcStreamingContext : public TThrRefBase {
88
106
*/
89
107
virtual bool Write (TOut&& message, const grpc::WriteOptions& options = { }) = 0;
90
108
91
- /* *
92
- * Schedules stream termination with the specified status
93
- *
94
- * Only the first call is accepted, after which new Read or Write calls
95
- * are no longer permitted and ignored.
96
- */
97
- virtual bool Finish (const grpc::Status& status) = 0;
98
-
99
109
/* *
100
110
* Schedules the next message write combined with the status
101
111
*
@@ -109,13 +119,6 @@ class IGRpcStreamingContext : public TThrRefBase {
109
119
* This is similar to Write and Finish combined into a more efficient call.
110
120
*/
111
121
virtual bool WriteAndFinish (TOut&& message, const grpc::WriteOptions& options, const grpc::Status& status) = 0;
112
-
113
- public:
114
- virtual NYdbGrpc::TAuthState& GetAuthState () const = 0;
115
- virtual TString GetPeerName () const = 0;
116
- virtual TVector<TStringBuf> GetPeerMetaValues (TStringBuf key) const = 0;
117
- virtual grpc_compression_level GetCompressionLevel () const = 0;
118
- virtual void UseDatabase (const TString& database) = 0;
119
122
};
120
123
121
124
template <class TIn , class TOut , class TServer , int LoggerServiceId>
@@ -602,6 +605,10 @@ class TGRpcStreamingRequest final
602
605
}
603
606
}
604
607
608
+ TString GetRpcMethodName () const {
609
+ return TStringBuilder () << TServer::TCurrentGRpcService::service_full_name () << ' /' << Name;
610
+ }
611
+
605
612
private:
606
613
class TFacade : public IContext {
607
614
public:
@@ -661,6 +668,10 @@ class TGRpcStreamingRequest final
661
668
Self->UseDatabase (database);
662
669
}
663
670
671
+ TString GetRpcMethodName () const override {
672
+ return Self->GetRpcMethodName ();
673
+ }
674
+
664
675
private:
665
676
TIntrusivePtr<TSelf> Self;
666
677
};
0 commit comments