A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://www.ncbi.nlm.nih.gov/IEB/ToolBox/CPP_DOC/doxyhtml/grpc__integration_8cpp_source.html below:

NCBI C++ ToolKit: src/serial/grpc_integration/grpc_integration.cpp Source File

42 # include <grpcpp/grpcpp.h> 43 # include <grpc++/server_context.h> 44 # include <grpc/support/alloc.h> 45 # include <grpc/support/log.h> 51 #define NCBI_USE_ERRCODE_X Serial_GRPCIntegration 56 #if defined(GRPC_CPP_VERSION_MAJOR) && (GRPC_CPP_VERSION_MAJOR > 1 || GRPC_CPP_VERSION_MINOR >= 67) 57 #include "absl/log/initialize.h" 58 #include "absl/log/log_sink_registry.h" 60 class

CNCBILogSink :

public

absl::LogSink {

63

absl::InitializeLog();

64

absl::AddLogSink(

this

);

68  void

Send(

const

absl::LogEntry& entry)

override

{

71

ncbi::CDiagCompileInfo diag_info(

72

src.c_str(), entry.source_line(),

75  switch

(entry.log_severity()) {

82

ncbi::CNcbiDiag(diag_info) << ncbi::Severity(sev) <<

msg

<< ncbi::Endm;

85 static

CNCBILogSink s_NCBILogSink;

86 #define GPR_SET_LOG_FUNCION 93

ncbi::CDiagCompileInfo diag_info(args->file, args->line, unk_func,

"GRPC"

);

95  switch

(args->severity) {

100

ncbi::CNcbiDiag(diag_info) << ncbi::Severity(sev) << args->message << ncbi::Endm;

103 #define GPR_SET_LOG_FUNCION gpr_set_log_function(s_NCBI_GPR_Log_Function) 116  if

(name ==

"ncbi_dtab"

) {

118

}

else if

(name ==

"ncbi_phid"

) {

120

}

else if

(name ==

"ncbi_sid"

) {

126  for

(

char

& c :

result

) {

127  if

( !

isalnum

((

unsigned char

) c) && kLegalPunct.

find

(c) ==

NPOS

) {

136  if

(name ==

"l5d-dtab"

) {

138

}

else if

(name ==

"ncbi-phid"

) {

140

}

else if

(name ==

"ncbi-sid"

) {

186

unique_ptr<TGRPCBaseClientContext>

191

unique_ptr<TGRPCBaseClientContext>

result 192

(TGRPCBaseClientContext::FromServerContext(sctx, options));

198  return

make_unique<CGRPCClientContext>();

207

cctx.set_initial_metadata_corked(

true

);

216

cctx.AddMetadata(

"dtab"

, rctx.

GetDtab

());

218

cctx.AddMetadata(

"client"

, dctx.

GetAppName

());

221  bool

need_filter = pass_through.

IsSet

(

"PATH"

);

224

<<

"No NCBI_CONTEXT_FIELDS or [Context] Fields" 225  " setting; performing ad-hoc filtering."

);

228

([&](

const string

& name,

const string

&

value

) {

229  if

( !need_filter || name ==

"http_proxy" 241

cctx.AddMetadata(

"ncbi_client_ip"

,

buf

);

261 #define TSCP(x, y) { CRequestStatus::x, grpc::y } 263  TSCP

(e400_BadRequest, INVALID_ARGUMENT),

264  TSCP

(e401_Unauthorized, PERMISSION_DENIED),

265  TSCP

(e402_PaymentRequired, PERMISSION_DENIED),

266  TSCP

(e403_Forbidden, PERMISSION_DENIED),

267  TSCP

(e404_NotFound, NOT_FOUND),

268  TSCP

(e405_MethodNotAllowed, UNIMPLEMENTED),

269  TSCP

(e406_NotAcceptable, UNIMPLEMENTED),

270  TSCP

(e407_ProxyAuthRequired, PERMISSION_DENIED),

271  TSCP

(e408_RequestTimeout, DEADLINE_EXCEEDED),

272  TSCP

(e409_Conflict, ABORTED),

273  TSCP

(e410_Gone, NOT_FOUND),

274  TSCP

(e411_LengthRequired, UNIMPLEMENTED),

275  TSCP

(e412_PreconditionFailed, FAILED_PRECONDITION),

276  TSCP

(e413_RequestEntityTooLarge, RESOURCE_EXHAUSTED),

277  TSCP

(e414_RequestURITooLong, RESOURCE_EXHAUSTED),

278  TSCP

(e415_UnsupportedMediaType, UNIMPLEMENTED),

279  TSCP

(e416_RangeNotSatisfiable, OUT_OF_RANGE),

280  TSCP

(e417_ExpectationFailed, FAILED_PRECONDITION),

281  TSCP

(e422_UnprocessableEntity, UNIMPLEMENTED),

282  TSCP

(e499_BrokenConnection, CANCELLED),

283  TSCP

(e500_InternalServerError, INTERNAL),

284  TSCP

(e501_NotImplemented, UNIMPLEMENTED),

285  TSCP

(e502_BadGateway, INTERNAL),

286  TSCP

(e503_ServiceUnavailable, UNAVAILABLE),

287  TSCP

(e504_GatewayTimeout, DEADLINE_EXCEEDED),

288  TSCP

(e505_HTTPVerNotSupported, UNIMPLEMENTED)

299  if

(it != sc_ErrorCodeMap.end()) {

364  string

client_name, peer_ip, port;

369  SIZE_TYPE

pos = sctx->peer().find(

':'

);

371  string

peer = sctx->peer().substr(pos + 1);

373

pos = peer.

rfind

(

':'

);

374  if

(pos ==

NPOS

|| peer[peer.size() - 1] ==

']'

) {

377

port = peer.

substr

(pos + 1);

378

host.

assign

(peer, 0, pos);

379  if

(host[0] ==

'['

&& host[pos - 1] ==

']'

) {

380

host = host.

substr

(1, pos - 2);

383  if

( !host.

empty

() ) {

388  for

(

const auto

& metadata : sctx->client_metadata()) {

389  CTempString

nm(metadata.first .data(), metadata.first .size());

390  CTempString

vl(metadata.second.data(), metadata.second.size());

398

grpc_fields[name2] =

value

;

401

= sc_RCSetterMap.find(name.c_str());

402  if

(it != sc_RCSetterMap.end()) {

407

rcsettings[it->second][name] =

value

;

408

}

else if

(metadata.first ==

"client"

) {

409

client_name =

value

;

412  for

(

const auto

& it : rcsettings) {

413  const string

*

value

=

nullptr

;

414  if

(it.second.size() == 1) {

415  value

= &it.second.begin()->second;

417  _ASSERT

(it.second.size() == 2);

418  const string

*old_name =

nullptr

, *new_name =

nullptr

;

419  for

(

const auto

& it2 : it.second) {

421

new_name = &it2.first;

424

old_name = &it2.first;

427  _ASSERT

(old_name !=

nullptr

);

430

<<

"Ignoring deprecated metadata field " 431

<< *old_name <<

" in favor of "

<< *new_name);

433

(*(it.first))(rctx, *

value

);

438  if

( !client_name.empty() ) {

439

extra.

Print

(

"client_name"

, client_name);

441  if

( !peer_ip.empty() ) {

442

extra.

Print

(

"peer_ip"

, peer_ip);

444  if

( !port.empty() ) {

445

extra.

Print

(

"client_port"

, port);

451  if

(app ==

nullptr

) {

457

list<string> env_names;

458  env

->Enumerate(env_names);

459  for

(

const auto

& it : env_names) {

463

env_fields[name] =

env

->Get(it);

483  auto

peer = sctx->peer();

488  for

(

const auto

& it : sctx->client_metadata()) {

489  CTempString

name(it.first.data(), it.first.size());

507  const char

* variable,

508  const char

* env_var_name,

512  if

(

addr

.empty() ) {

static grpc::Server::GlobalCallbacks *volatile sm_ServerCallbacks

static CNcbiApplication * Instance(void)

Singleton method.

Request context properties passed between tasks.

class CStaticArrayMap<> provides access to a static array in much the same way as CStaticArraySet<>,...

TBase::const_iterator const_iterator

CTempString implements a light-weight string on top of a storage buffer whose lifetime management is ...

const CNcbiEnvironment & GetEnvironment(void) const

Get the application's cached environment.

@ eNoOwnership

No ownership is assumed.

void PrintRequestStop(void)

Print request stop message (for request-driven applications)

CDiagContext_Extra & Print(const string &name, const string &value)

The method does not print the argument, but adds it to the string.

CDiagContext & GetDiagContext(void)

Get diag context instance.

void PrintRequestStart(const string &message)

Print request start message (for request-driven applications)

string GetSessionID(void) const

Session ID.

void SetRequestID(TCount rid)

Set request ID.

const string & GetNextSubHitID(CTempString prefix=CTempString())

Get current hit id appended with auto-incremented sub-hit id.

#define ERR_POST_X_ONCE(err_subcode, message)

Error posting only once during program execution with default error code and given error subcode.

void SetClientIP(const string &client)

bool IsSetSessionID(void) const

static CRequestContext & GetRequestContext(void)

Shortcut to CDiagContextThreadData::GetThreadData().GetRequestContext()

string GetClientIP(void) const

Client IP/hostname.

void Enumerate(TCallback callback)

Enumerate all properties.

bool IsSet(CTempString name) const

Check if the property is set.

const string & GetDtab(void) const

void Flush(void)

Print the message and reset object.

bool IsSetClientIP(void) const

void AddPassThroughProperty(const string &name, const string &value)

Add pass-through value if it matches a pattern from NCBI_CONTEXT_FIELDS.

void LogFields(const TEntries &entries) const

Log (as an extra) all names/values matching fields in NCBI_LOG_FIELDS.

const string & GetAppName(void) const

Get application name.

EDiagSev

Severity level for the posted diagnostics.

const char * g_DiagUnknownFunction(void)

@ eDiag_Trace

Trace message.

@ eDiag_Info

Informational message.

@ eDiag_Error

Error message.

@ eDiag_Warning

Warning message.

@ eDiag_Fatal

Fatal error – guarantees exit(or abort)

void Warning(CExceptionArgs_Base &args)

void Info(CExceptionArgs_Base &args)

static void AddStandardNCBIMetadata(TParent &cctx)

grpc::ClientContext TGRPCBaseClientContext

grpc::StatusCode g_AsGRPCStatusCode(CRequestStatus::ECode status_code)

static bool x_IsRealRequest(const TGRPCServerContext *sctx)

grpc::PropagationOptions TGRPCPropagationOptions

static void EndRequest(grpc::ServerContext *sctx)

grpc::ServerContext TGRPCServerContext

static unique_ptr< TParent > FromServerContext(const TGRPCServerContext &sc, TGRPCPropagationOptions opts=TGRPCPropagationOptions())

EInvocationType

How was BeginRequest or EndRequest called?

static bool IsImplemented(void)

string g_NCBI_GRPC_GetAddress(const char *section, const char *variable, const char *env_var_name, CParamBase::EParamSource *value_source)

Get "hostport" for the likes of "grpc::CreateChannel(hostport, ...)" trying (in order of priority):

static void BeginRequest(grpc::ServerContext *sctx)

@ eImplicit

From {Pre,Post}SynchronousRequest.

string g_GetConfigString(const char *section, const char *variable, const char *env_var_name, const char *default_value, CParamBase::EParamSource *src=nullptr)

Helper functions for getting values from registry/environment.

EParamSource

Source of the value returned by CParam::GetDefault().

#define END_NCBI_SCOPE

End previously defined NCBI scope.

#define BEGIN_NCBI_SCOPE

Define ncbi namespace.

NCBI_NS_STD::string::size_type SIZE_TYPE

size_type rfind(const CTempString match, size_type pos=npos) const

Find the first instance of the entire matching string within the current string in a backward directi...

CTempString & assign(const char *src_str, size_type len)

Assign new values to the content of the a string.

bool empty(void) const

Return true if the represented string is empty (i.e., the length is zero)

static string CParse(const CTempString str, EQuoted quoted=eQuoted)

Discard C-style backslash escapes.

static bool StartsWith(const CTempString str, const CTempString start, ECase use_case=eCase)

Check if a string starts with a specified prefix value.

CTempString substr(size_type pos) const

Obtain a substring from this string, beginning at a given offset.

size_type find(const CTempString match, size_type pos=0) const

Find the first instance of the entire matching string within the current string, beginning at an opti...

static string CEncode(const CTempString str, EQuoted quoted=eQuoted)

Encode a string for C/C++.

static string & ReplaceInPlace(string &src, const string &search, const string &replace, SIZE_TYPE start_pos=0, SIZE_TYPE max_replace=0, SIZE_TYPE *num_replace=0)

Replace occurrences of a substring within a string.

static string & ToLower(string &str)

Convert string to lower case – string& version.

@ eNotQuoted

String is not quoted.

@ eNocase

Case insensitive compare.

static void s_SetHitID(CRequestContext &r, const string &s)

static void s_SetSessionID(CRequestContext &r, const string &s)

SStaticPair< CRequestStatus::ECode, grpc::StatusCode > TStatusCodePair

SStaticPair< const char *, FRCSetter > TRCSetterPair

static void s_SetClientIP(CRequestContext &r, const string &s)

#define GPR_SET_LOG_FUNCION

void(* FRCSetter)(CRequestContext &, const string &)

static string s_EncodeMetadataName(const string &name)

static string s_DecodeMetadataValue(const CTempString &value)

static CGRPCInitializer s_GRPCInitializer

static const TRCSetterPair sc_RCSetters[]

static void s_SetDtab(CRequestContext &r, const string &s)

CStaticArrayMap< CRequestStatus::ECode, grpc::StatusCode > TStatusCodeMap

static string s_EncodeMetadataValue(const string &value)

CStaticArrayMap< const char *, FRCSetter, PCase_CStr > TRCSetterMap

DEFINE_STATIC_ARRAY_MAP(TStatusCodeMap, sc_ErrorCodeMap, sc_ErrorCodes)

static const TStatusCodePair sc_ErrorCodes[]

static void s_NCBI_GPR_Log_Function(gpr_log_func_args *args)

static string s_DecodeMetadataName(const CTempString &name)

Definition of all error codes used in serial libraries (xser.lib, xcser.lib).

const GenericPointer< typename T::ValueType > T2 value

char * NcbiGetHostIP(char *buf, size_t bufsize)

Defines the CNcbiApplication and CAppException classes for creating NCBI applications.

double r(size_t dimension_, const Int4 *score_, const double *prob_, double theta_)

Glue for integrating gRPC into the C++ toolkit, to ensure logging and metadata propagation (sid,...

static SLJIT_INLINE sljit_ins msg(sljit_gpr r, sljit_s32 d, sljit_gpr x, sljit_gpr b)

Template structure SStaticPair is simlified replacement of STL pair<> Main reason of introducing this...


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4