LogDevice API
Reader.h
1 
8 #pragma once
9 
10 #include <chrono>
11 #include <memory>
12 #include <vector>
13 
14 #include <folly/Range.h>
15 
16 #include "logdevice/include/Record.h"
17 #include "logdevice/include/types.h"
18 
19 namespace facebook { namespace logdevice {
20 
21 struct ReadStreamAttributes;
22 
33 class Reader {
34  public:
54  virtual int startReading(logid_t log_id,
55  lsn_t from,
56  lsn_t until = LSN_MAX,
57  const ReadStreamAttributes* attrs = nullptr) = 0;
58 
67  virtual int stopReading(logid_t log_id) = 0;
68 
73  virtual bool isReading(logid_t log_id) const = 0;
74 
79  virtual bool isReadingAny() const = 0;
80 
93  virtual int setTimeout(std::chrono::milliseconds timeout) = 0;
94 
95  const std::chrono::milliseconds MAX_TIMEOUT{(1LL << 31) - 1};
96 
144  virtual ssize_t read(size_t nrecords,
145  std::vector<std::unique_ptr<DataRecord>>* data_out,
146  GapRecord* gap_out) = 0;
147 
163  virtual void waitOnlyWhenNoData() = 0;
164 
173  virtual void withoutPayload() = 0;
174 
184  virtual void forceNoSingleCopyDelivery() = 0;
185 
196  virtual void includeByteOffset() = 0;
197 
210  virtual void doNotSkipPartiallyTrimmedSections() = 0;
211 
225  virtual int isConnectionHealthy(logid_t) const = 0;
226 
236  virtual void doNotDecodeBufferedWrites() = 0;
237 
258  static lsn_t nextFromLsnWhenStuck(lsn_t stuck_lsn = LSN_INVALID,
259  lsn_t tail_lsn = LSN_INVALID);
260 
267  virtual ~Reader() {}
268 };
269 
270 }} // namespace facebook::logdevice
virtual void withoutPayload()=0
virtual int startReading(logid_t log_id, lsn_t from, lsn_t until=LSN_MAX, const ReadStreamAttributes *attrs=nullptr)=0
virtual bool isReading(logid_t log_id) const =0
virtual void doNotDecodeBufferedWrites()=0
virtual int stopReading(logid_t log_id)=0
Definition: Reader.h:33
virtual void doNotSkipPartiallyTrimmedSections()=0
Definition: AsyncReader.h:16
virtual ssize_t read(size_t nrecords, std::vector< std::unique_ptr< DataRecord >> *data_out, GapRecord *gap_out)=0
static lsn_t nextFromLsnWhenStuck(lsn_t stuck_lsn=LSN_INVALID, lsn_t tail_lsn=LSN_INVALID)
virtual void includeByteOffset()=0
virtual int setTimeout(std::chrono::milliseconds timeout)=0
virtual ~Reader()
Definition: Reader.h:267
virtual bool isReadingAny() const =0
virtual int isConnectionHealthy(logid_t) const =0
virtual void forceNoSingleCopyDelivery()=0
virtual void waitOnlyWhenNoData()=0