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 
202  virtual void withoutPayload() = 0;
203 
213  virtual void forceNoSingleCopyDelivery() = 0;
214 
225  virtual void includeByteOffset() = 0;
226 
239  virtual void doNotSkipPartiallyTrimmedSections() = 0;
240 
254  virtual int isConnectionHealthy(logid_t) const = 0;
255 
265  virtual void doNotDecodeBufferedWrites() = 0;
266 
287  static lsn_t nextFromLsnWhenStuck(lsn_t stuck_lsn = LSN_INVALID,
288  lsn_t tail_lsn = LSN_INVALID);
289 
294  virtual void getBytesBuffered(std::function<void(size_t)> callback) = 0;
295 
296  virtual ~AsyncReader() {}
297 };
298 
299 }} // namespace facebook::logdevice
Definition: AsyncReader.h:16
Definition: AsyncReader.h:40