LogDevice API
Classes | Public Member Functions | Static Public Member Functions | Friends | List of all members
facebook::logdevice::BufferedWriter Class Reference


struct  Append
class  AppendCallback
struct  LogOptions
struct  Options

Public Member Functions

int append (logid_t logid, std::string &&payload, AppendCallback::Context callback_context, AppendAttributes &&attrs=AppendAttributes())
std::vector< Status > append (std::vector< Append > &&appends)
int flushAll ()
virtual ~BufferedWriter ()

Static Public Member Functions

static std::unique_ptr< BufferedWritercreate (std::shared_ptr< Client > client, AppendCallback *callback, Options options=Options())


class BufferedWriterImpl

Constructor & Destructor Documentation

◆ ~BufferedWriter()

virtual facebook::logdevice::BufferedWriter::~BufferedWriter ( )

NOTE: involves communication with LogDevice threads, blocks until they acknowledge the destruction.

Member Function Documentation

◆ append() [1/2]

int facebook::logdevice::BufferedWriter::append ( logid_t  logid,
std::string &&  payload,
AppendCallback::Context  callback_context,
AppendAttributes &&  attrs = AppendAttributes() 

Same as Client::append() except the append may get buffered.

If the call succeeds (returns 0), the class assumes ownership of the payload. If the call fails, the payload remains in the given std::string. See Client::append for explanation of AppendAttributes

◆ append() [2/2]

std::vector<Status> facebook::logdevice::BufferedWriter::append ( std::vector< Append > &&  appends)

Multi-write version of append(). Requires less interthread communication than calling append() for each record.

A vector of Status objects, one for each input append. The status is E::OK if the append was successfully queued for writing, or otherwise one of the `err' codes documented for the single-write append(). If some of the appends fail, their payloads remain in the input vector.

◆ create()

static std::unique_ptr<BufferedWriter> facebook::logdevice::BufferedWriter::create ( std::shared_ptr< Client client,
AppendCallback callback,
Options  options = Options() 

Constructing and destructing a BufferedWriter involves interthread communication (with LogDevice library threads) and may block if those threads are busy. BufferedWriter instances are meant to be long-lived (and clients will typically use just one).

◆ flushAll()

int facebook::logdevice::BufferedWriter::flushAll ( )

Instructs the class to immediately flush all buffered appends. Does not block, just passes messages to LogDevice threads.

It is not intended for this to be called often in production as it can limit the amount of batching; space- and time-based flushing should be preferred.

0 on success, -1 if messages could not be posted to some LogDevice threads

The documentation for this class was generated from the following file: