LogDevice API
AsyncReader.h
1 
8 #pragma once
9 
10 #include <functional>
11 #include <memory>
12 
13 #include "logdevice/include/Record.h"
14 #include "logdevice/include/types.h"
15 
16 namespace facebook { namespace logdevice {
17 
18 struct ReadStreamAttributes;
19 
20 enum class HealthChangeType {
21  LOG_HEALTHY = 0,
22  LOG_UNHEALTHY = 1,
23 };
24 
40 class AsyncReader {
41  public:
57  virtual void
58  setRecordCallback(std::function<bool(std::unique_ptr<DataRecord>&)>) = 0;
59 
72  virtual void setGapCallback(std::function<bool(const GapRecord&)>) = 0;
73 
78  virtual void setDoneCallback(std::function<void(logid_t)>) = 0;
79 
88  virtual void
89  setHealthChangeCallback(std::function<void(logid_t, HealthChangeType)>) = 0;
90 
145  virtual int startReading(logid_t log_id,
146  lsn_t from,
147  lsn_t until = LSN_MAX,
148  const ReadStreamAttributes* attrs = nullptr) = 0;
149 
171  virtual int stopReading(logid_t log_id,
172  std::function<void()> callback = nullptr) = 0;
173 
192  virtual int resumeReading(logid_t log_id) = 0;
193 
201  virtual void addMonitoringTag(std::string tag) = 0;
202 
211  virtual void withoutPayload() = 0;
212 
222  virtual void forceNoSingleCopyDelivery() = 0;
223 
234  virtual void includeByteOffset() = 0;
235 
248  virtual void doNotSkipPartiallyTrimmedSections() = 0;
249 
263  virtual int isConnectionHealthy(logid_t) const = 0;
264 
274  virtual void doNotDecodeBufferedWrites() = 0;
275 
296  static lsn_t nextFromLsnWhenStuck(lsn_t stuck_lsn = LSN_INVALID,
297  lsn_t tail_lsn = LSN_INVALID);
298 
303  virtual void getBytesBuffered(std::function<void(size_t)> callback) = 0;
304 
305  virtual void setReaderName(const std::string& reader_name) = 0;
306 
307  virtual ~AsyncReader() {}
308 };
309 
310 }} // namespace facebook::logdevice
Definition: AsyncReader.h:16
Definition: AsyncReader.h:40