16 #include "logdevice/include/Client.h" 17 #include "logdevice/include/types.h" 19 namespace facebook {
namespace logdevice {
61 class BufferedWriterImpl;
62 class BufferedWriterAppendSink;
75 using Context =
void*;
76 using ContextSet = std::vector<std::pair<Context, PayloadVariant>>;
96 const DataRecordAttributes& ) {}
112 enum class RetryDecision { ALLOW, DENY };
128 return RetryDecision::ALLOW;
136 AppendCallback::Context context,
137 AppendAttributes attrs = AppendAttributes())
139 payload(std::move(payload)),
141 attrs(std::move(attrs)) {}
144 PayloadGroup&& payload,
145 AppendCallback::Context context,
146 AppendAttributes attrs = AppendAttributes())
148 payload(std::move(payload)),
150 attrs(std::move(attrs)) {}
157 AppendCallback::Context context;
158 AppendAttributes attrs;
162 using Compression = facebook::logdevice::Compression;
168 std::chrono::milliseconds time_trigger{-1};
172 ssize_t size_trigger = -1;
215 Mode mode = Mode::INDEPENDENT;
223 std::chrono::milliseconds retry_initial_delay{-1};
225 std::chrono::milliseconds retry_max_delay{60000};
228 Compression compression = Compression::LZ4;
233 bool destroy_payloads =
false;
236 static std::string modeToString(Mode mode);
238 static int parseMode(
const char* str, Mode* out_mode);
242 static std::string compressionToString(Compression c);
243 static int parseCompression(
const char* str, Compression* out_c);
260 int32_t memory_limit_mb = -1;
271 static std::unique_ptr<BufferedWriter>
create(std::shared_ptr<Client> client,
287 std::string&& payload,
288 AppendCallback::Context callback_context,
289 AppendAttributes&& attrs = AppendAttributes());
291 PayloadGroup&& payload_group,
292 AppendCallback::Context callback_context,
293 AppendAttributes&& attrs = AppendAttributes());
305 std::vector<Status>
append(std::vector<Append>&& appends);
331 friend class BufferedWriterImpl;
332 BufferedWriterImpl* impl();
Definition: BufferedWriter.h:133
int append(logid_t logid, std::string &&payload, AppendCallback::Context callback_context, AppendAttributes &&attrs=AppendAttributes())
static std::unique_ptr< BufferedWriter > create(std::shared_ptr< Client > client, AppendCallback *callback, Options options=Options())
std::variant< std::string, PayloadGroup > PayloadVariant
Definition: BufferedWriter.h:67
Definition: AsyncReader.h:16
virtual void onSuccess(logid_t, ContextSet, const DataRecordAttributes &)
Definition: BufferedWriter.h:94
Definition: BufferedWriter.h:73
Definition: BufferedWriter.h:64
Definition: BufferedWriter.h:160
virtual void onFailure(logid_t, ContextSet, Status)
Definition: BufferedWriter.h:108
Definition: BufferedWriter.h:248
virtual ~BufferedWriter()
Definition: BufferedWriter.h:324
virtual RetryDecision onRetry(logid_t, const ContextSet &, Status)
Definition: BufferedWriter.h:125