42 #define NCBI_USE_ERRCODE_X ConnServ_ReadWrite
49 #define JOB_OUTPUT_PREFIX_LEN 2
52 m_MaxDataSize(max_data_size),
54 m_WriterCreate(writer_create)
66 if (bytes_written) *bytes_written =
count;
106 return [api](
string&
key)
mutable {
return api.
PutData(&
key); };
120 stream->exceptions(IOS_BASE::badbit | IOS_BASE::failbit);
159 m_Storage(storage), m_Data(data_or_key)
166 string service(
key.GetServiceName());
168 if (service.empty()) {
174 key.GetHost(),
key.GetPort());
183 if (data_size !=
NULL)
189 "Unknown data type \"" <<
202 if (bytes_read !=
NULL)
211 if (bytes_read !=
NULL)
230 stream->exceptions(IOS_BASE::badbit | IOS_BASE::failbit);
Client API for NetCache server.
void StickToServer(SSocketAddress address)
CNetServerPool GetServerPool()
Note about the "buf_size" parameter for streams in this API.
@ fLeakExceptions
Exceptions leaked out.
@ fOwnReader
Own the underlying reader.
String or Blob Storage Reader.
CStringOrBlobStorageReader(const string &data_or_key, SNetCacheAPIImpl *storage, size_t *data_size=NULL)
virtual ERW_Result Read(void *buf, size_t count, size_t *bytes_read=0)
Read as many as "count" bytes into a buffer pointed to by the "buf" argument.
static EType x_GetDataType(string &data)
virtual ERW_Result PendingCount(size_t *count)
Via parameter "count" (which is guaranteed to be supplied non-NULL) return the number of bytes that a...
unique_ptr< IReader > m_NetCacheReader
String or Blob Storage Writer.
CStringOrBlobStorageWriter(size_t max_string_size, SNetCacheAPIImpl *storage, string &job_output_ref)
ERW_Result Write(const void *buf, size_t count, size_t *bytes_written=0) override
Write up to "count" bytes from the buffer pointed to by the "buf" argument onto the output device.
function< IEmbeddedStreamWriter *(string &)> TWriterCreate
ERW_Result Flush() override
Flush pending data (if any) down to the output device.
CStringOrWriter(size_t max_data_size, string &data_ref, TWriterCreate writer_create)
TWriterCreate m_WriterCreate
unique_ptr< IEmbeddedStreamWriter > m_Writer
Writer-based output stream.
#define JOB_OUTPUT_PREFIX_LEN
static const char s_JobOutputPrefixEmbedded[]
static const char s_JobOutputPrefixNetCache[]
CStringOrWriter::TWriterCreate s_NetCacheWriterCreate(CNetCacheAPI api)
#define NCBI_THROW_FMT(exception_class, err_code, message)
The same as NCBI_THROW but with message processed as output to ostream.
string PutData(const void *buf, size_t size, const CNamedParameterList *optional=NULL)
Put BLOB to server.
IReader * GetReader(const string &key, size_t *blob_size=NULL, const CNamedParameterList *optional=NULL)
Get a pointer to the IReader interface to read blob contents.
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
ERW_Result
Result codes for I/O operations.
IO_PREFIX::ostream CNcbiOstream
Portable alias for ostream.
IO_PREFIX::istream CNcbiIstream
Portable alias for istream.
@ eRW_Eof
End of data, should be considered permanent.
@ eRW_Error
Unrecoverable error, no retry possible.
@ eRW_Success
Everything is okay, I/O completed.
static string UIntToString(unsigned int value, TNumToStringFlags flags=0, int base=10)
Convert UInt to string.
static int CompareCase(const CTempString s1, SIZE_TYPE pos, SIZE_TYPE n, const char *s2)
Case-sensitive compare of a substring with another string.
Definition of all error codes used in connect services library (xconnserv.lib and others).
const struct ncbi::grid::netcache::search::fields::KEY key
Reader-writer based streams.
Meaningful information encoded in the NetCache key.
CNcbiIstream & operator()(CNetCacheAPI nc_api, const string &data, size_t *data_size)
unique_ptr< CNcbiIstream > stream
unique_ptr< IEmbeddedStreamWriter > writer
CNcbiOstream & operator()(CNetCacheAPI nc_api, size_t embedded_max_size, string &data)
unique_ptr< CNcbiOstream > stream
void Reset(bool flush=false)