1
1
#pragma once
2
2
3
+ #include " codecs/codecs.h"
4
+ #include " common/counters.h"
5
+ #include " common/executor.h"
6
+ #include " common/retry_policy.h"
7
+
3
8
#include < src/api/grpc/ydb_topic_v1.grpc.pb.h>
9
+
4
10
#include < ydb-cpp-sdk/client/driver/driver.h>
5
11
#include < ydb-cpp-sdk/client/scheme/scheme.h>
6
- #include < src/client/topic/codecs/codecs.h>
7
12
#include < ydb-cpp-sdk/client/types/exceptions/exceptions.h>
8
13
9
- #include < ydb-cpp-sdk/library/monlib/dynamic_counters/counters.h>
10
14
#include < ydb-cpp-sdk/library/logger/log.h>
11
- #include < ydb-cpp-sdk/library/retry/retry_policy.h>
12
- #include < ydb-cpp-sdk/util/string/builder.h>
13
15
16
+ #include < ydb-cpp-sdk/util/string/builder.h>
14
17
#include < ydb-cpp-sdk/util/datetime/base.h>
15
18
#include < ydb-cpp-sdk/util/generic/size_literals.h>
16
19
#include < ydb-cpp-sdk/util/thread/pool.h>
@@ -32,14 +35,6 @@ namespace NYdb {
32
35
33
36
namespace NYdb ::NTopic {
34
37
35
- enum class ECodec : ui32 {
36
- RAW = 1 ,
37
- GZIP = 2 ,
38
- LZOP = 3 ,
39
- ZSTD = 4 ,
40
- CUSTOM = 10000 ,
41
- };
42
-
43
38
enum class EMeteringMode : ui32 {
44
39
Unspecified = 0 ,
45
40
ReservedCapacity = 1 ,
@@ -684,71 +679,6 @@ class TContinuationTokenIssuer {
684
679
}
685
680
};
686
681
687
- struct TWriterCounters : public TThrRefBase {
688
- using TSelf = TWriterCounters;
689
- using TPtr = TIntrusivePtr<TSelf>;
690
-
691
- explicit TWriterCounters (const TIntrusivePtr<::NMonitoring::TDynamicCounters>& counters);
692
-
693
- ::NMonitoring::TDynamicCounters::TCounterPtr Errors;
694
- ::NMonitoring::TDynamicCounters::TCounterPtr CurrentSessionLifetimeMs;
695
-
696
- ::NMonitoring::TDynamicCounters::TCounterPtr BytesWritten;
697
- ::NMonitoring::TDynamicCounters::TCounterPtr MessagesWritten;
698
- ::NMonitoring::TDynamicCounters::TCounterPtr BytesWrittenCompressed;
699
-
700
- ::NMonitoring::TDynamicCounters::TCounterPtr BytesInflightUncompressed;
701
- ::NMonitoring::TDynamicCounters::TCounterPtr BytesInflightCompressed;
702
- ::NMonitoring::TDynamicCounters::TCounterPtr BytesInflightTotal;
703
- ::NMonitoring::TDynamicCounters::TCounterPtr MessagesInflight;
704
-
705
- // ! Histograms reporting % usage of memory limit in time.
706
- // ! Provides a histogram looking like: 10% : 100ms, 20%: 300ms, ... 50%: 200ms, ... 100%: 50ms
707
- // ! Which means that < 10% memory usage was observed for 100ms during the period and 50% usage was observed for 200ms
708
- // ! Used to monitor if the writer successfully deals with data flow provided. Larger values in higher buckets
709
- // ! mean that writer is close to overflow (or being overflown) for major periods of time
710
- // ! 3 histograms stand for:
711
- // ! Total memory usage:
712
- ::NMonitoring::THistogramPtr TotalBytesInflightUsageByTime;
713
- // ! Memory usage by messages waiting for comression:
714
- ::NMonitoring::THistogramPtr UncompressedBytesInflightUsageByTime;
715
- // ! Memory usage by compressed messages pending for write:
716
- ::NMonitoring::THistogramPtr CompressedBytesInflightUsageByTime;
717
- };
718
-
719
- struct TReaderCounters : public TThrRefBase {
720
- using TSelf = TReaderCounters;
721
- using TPtr = TIntrusivePtr<TSelf>;
722
-
723
- TReaderCounters () = default ;
724
- explicit TReaderCounters (const TIntrusivePtr<::NMonitoring::TDynamicCounters>& counters);
725
-
726
- ::NMonitoring::TDynamicCounters::TCounterPtr Errors;
727
- ::NMonitoring::TDynamicCounters::TCounterPtr CurrentSessionLifetimeMs;
728
-
729
- ::NMonitoring::TDynamicCounters::TCounterPtr BytesRead;
730
- ::NMonitoring::TDynamicCounters::TCounterPtr MessagesRead;
731
- ::NMonitoring::TDynamicCounters::TCounterPtr BytesReadCompressed;
732
-
733
- ::NMonitoring::TDynamicCounters::TCounterPtr BytesInflightUncompressed;
734
- ::NMonitoring::TDynamicCounters::TCounterPtr BytesInflightCompressed;
735
- ::NMonitoring::TDynamicCounters::TCounterPtr BytesInflightTotal;
736
- ::NMonitoring::TDynamicCounters::TCounterPtr MessagesInflight;
737
-
738
- // ! Histograms reporting % usage of memory limit in time.
739
- // ! Provides a histogram looking like: 10% : 100ms, 20%: 300ms, ... 50%: 200ms, ... 100%: 50ms
740
- // ! Which means < 10% memory usage was observed for 100ms during the period and 50% usage was observed for 200ms.
741
- // ! Used to monitor if the read session successfully deals with data flow provided. Larger values in higher buckets
742
- // ! mean that read session is close to overflow (or being overflown) for major periods of time.
743
- // !
744
- // ! Total memory usage.
745
- ::NMonitoring::THistogramPtr TotalBytesInflightUsageByTime;
746
- // ! Memory usage by messages waiting that are ready to be received by user.
747
- ::NMonitoring::THistogramPtr UncompressedBytesInflightUsageByTime;
748
- // ! Memory usage by compressed messages pending for decompression.
749
- ::NMonitoring::THistogramPtr CompressedBytesInflightUsageByTime;
750
- };
751
-
752
682
// ! Partition session.
753
683
struct TPartitionSession : public TThrRefBase , public TPrintable <TPartitionSession> {
754
684
using TPtr = TIntrusivePtr<TPartitionSession>;
@@ -1147,73 +1077,6 @@ void TPrintable<TSessionClosedEvent>::DebugString(TStringBuilder& ret, bool prin
1147
1077
1148
1078
std::string DebugString (const TReadSessionEvent::TEvent& event);
1149
1079
1150
- // ! Retry policy.
1151
- // ! Calculates delay before next retry.
1152
- // ! Has several default implementations:
1153
- // ! - exponential backoff policy;
1154
- // ! - retries with fixed interval;
1155
- // ! - no retries.
1156
-
1157
- struct IRetryPolicy : ::IRetryPolicy<EStatus> {
1158
- // !
1159
- // ! Default implementations.
1160
- // !
1161
-
1162
- static TPtr GetDefaultPolicy (); // Exponential backoff with infinite retry attempts.
1163
- static TPtr GetNoRetryPolicy (); // Denies all kind of retries.
1164
-
1165
- // ! Randomized exponential backoff policy.
1166
- static TPtr GetExponentialBackoffPolicy (
1167
- TDuration minDelay = TDuration::MilliSeconds(10 ),
1168
- // Delay for statuses that require waiting before retry (such as OVERLOADED).
1169
- TDuration minLongRetryDelay = TDuration::MilliSeconds(200 ), TDuration maxDelay = TDuration::Seconds(30 ),
1170
- size_t maxRetries = std::numeric_limits<size_t>::max(), TDuration maxTime = TDuration::Max(),
1171
- double scaleFactor = 2.0, std::function<ERetryErrorClass(EStatus)> customRetryClassFunction = {});
1172
-
1173
- // ! Randomized fixed interval policy.
1174
- static TPtr GetFixedIntervalPolicy (TDuration delay = TDuration::MilliSeconds(100 ),
1175
- // Delay for statuses that require waiting before retry (such as OVERLOADED).
1176
- TDuration longRetryDelay = TDuration::MilliSeconds(300 ),
1177
- size_t maxRetries = std::numeric_limits<size_t>::max(),
1178
- TDuration maxTime = TDuration::Max(),
1179
- std::function<ERetryErrorClass(EStatus)> customRetryClassFunction = {});
1180
- };
1181
-
1182
- class IExecutor : public TThrRefBase {
1183
- public:
1184
- using TPtr = TIntrusivePtr<IExecutor>;
1185
- using TFunction = std::function<void ()>;
1186
-
1187
- // Is executor asynchronous.
1188
- virtual bool IsAsync () const = 0;
1189
-
1190
- // Post function to execute.
1191
- virtual void Post (TFunction&& f) = 0;
1192
-
1193
- // Start method.
1194
- // This method is idempotent.
1195
- // It can be called many times. Only the first one has effect.
1196
- void Start () {
1197
- std::lock_guard guard (StartLock);
1198
- if (!Started) {
1199
- DoStart ();
1200
- Started = true ;
1201
- }
1202
- }
1203
-
1204
- private:
1205
- virtual void DoStart () = 0;
1206
-
1207
- private:
1208
- bool Started = false ;
1209
- TAdaptiveLock StartLock;
1210
- };
1211
- IExecutor::TPtr CreateThreadPoolExecutorAdapter (
1212
- std::shared_ptr<IThreadPool> threadPool); // Thread pool is expected to have been started.
1213
- IExecutor::TPtr CreateThreadPoolExecutor (size_t threads);
1214
-
1215
- IExecutor::TPtr CreateSyncExecutor ();
1216
-
1217
1080
// ! Events for write session.
1218
1081
struct TWriteSessionEvent {
1219
1082
0 commit comments