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 
69  virtual int stopReading(logid_t log_id) = 0;
70 
75  virtual bool isReading(logid_t log_id) const = 0;
76 
81  virtual bool isReadingAny() const = 0;
82 
95  virtual int setTimeout(std::chrono::milliseconds timeout) = 0;
96 
97  const std::chrono::milliseconds MAX_TIMEOUT{(1LL << 31) - 1};
98 
146  virtual ssize_t read(size_t nrecords,
147  std::vector<std::unique_ptr<DataRecord>>* data_out,
148  GapRecord* gap_out) = 0;
149 
165  virtual void waitOnlyWhenNoData() = 0;
166 
173  virtual void addMonitoringTag(std::string tag) = 0;
174 
183  virtual void withoutPayload() = 0;
184 
194  virtual void forceNoSingleCopyDelivery() = 0;
195 
206  virtual void includeByteOffset() = 0;
207 
220  virtual void doNotSkipPartiallyTrimmedSections() = 0;
221 
235  virtual int isConnectionHealthy(logid_t) const = 0;
236 
246  virtual void doNotDecodeBufferedWrites() = 0;
247 
248  virtual void setReaderName(const std::string&) = 0;
249 
270  static lsn_t nextFromLsnWhenStuck(lsn_t stuck_lsn = LSN_INVALID,
271  lsn_t tail_lsn = LSN_INVALID);
272 
279  virtual ~Reader() {}
280 };
281 
282 }} // 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:279
virtual bool isReadingAny() const =0
virtual int isConnectionHealthy(logid_t) const =0
virtual void forceNoSingleCopyDelivery()=0
virtual void addMonitoringTag(std::string tag)=0
virtual void waitOnlyWhenNoData()=0