* do_not_track = ::getenv(
"DO_NOT_TRACK");
150 #if defined(NCBI_USAGE_REPORT_SUPPORTED) 234 else if(timeout.
IsZero()) {
255 #if defined(NCBI_USAGE_REPORT_SUPPORTED) 281 #if defined(NCBI_USAGE_REPORT_SUPPORTED) 286 for(
charc : name) {
290 #define CHECK_USAGE_REPORT_PARAM_NAME s_CheckName 292 #define CHECK_USAGE_REPORT_PARAM_NAME(name) 298 #if defined(NCBI_USAGE_REPORT_SUPPORTED) 299CHECK_USAGE_REPORT_PARAM_NAME(name);
307 return Add(name,
string(
value));
314 #if defined(NCBI_USAGE_REPORT_SUPPORTED) 316 for(
auto const¶m :
m_Params) {
322 result+= (param.first +
'='+= param.second);
360 #if defined(NCBI_USAGE_REPORT_SUPPORTED) 361 static strings_GetOS(
void)
367 #elif defined(_WIN32) 369 #elif defined(__CYGWIN__) 371 #elif defined(__linux__) 373 #elif defined(__FreeBSD__) 375 #elif defined(__NetBSD__) 377 #elif defined(__OpenBSD__) 379 #elif defined(__WXOSX__) 381 #elif defined(__APPLE__) 383 #elif defined(__hpux) 385 #elif defined(__osf__) 393 #elif defined(unix) || defined(__unix__) || defined(__unix) 403 return ctx.GetHost();
414 #define MT_GUARD std::lock_guard<std::mutex> mt_usage_guard(m_Usage_Mutex) 420 return*usage_report;
426 if(
value.empty()) {
434 #if defined(NCBI_USAGE_REPORT_SUPPORTED) 474 #if defined(NCBI_USAGE_REPORT_SUPPORTED) 481 #if defined(NCBI_USAGE_REPORT_SUPPORTED) 491 #if defined(NCBI_USAGE_REPORT_SUPPORTED) 497 if(!extra_params.empty()) {
498url +=
'&'+ extra_params;
514 #if defined(NCBI_USAGE_REPORT_SUPPORTED) 526 if(
m_Thread.get_id() == std::thread::id()) {
531 ERR_POST_ONCE(
Warning<<
"CUsageReport:: Unable to start reporting thread, reporting has disabled");
547 #if defined(NCBI_USAGE_REPORT_SUPPORTED) 559 #if defined(NCBI_USAGE_REPORT_SUPPORTED) 573 #if defined(NCBI_USAGE_REPORT_SUPPORTED) 575 return(
unsigned)
m_Queue.size();
584 #if defined(NCBI_USAGE_REPORT_SUPPORTED) 593 #if defined(NCBI_USAGE_REPORT_SUPPORTED) 605 #if defined(NCBI_USAGE_REPORT_SUPPORTED) 678 #if defined(NCBI_USAGE_REPORT_SUPPORTED) 698 #if defined(NCBI_USAGE_REPORT_SUPPORTED) 758 #if defined(NCBI_USAGE_REPORT_SUPPORTED)Guard for collecting diag messages (affects the current thread only).
CTimeout â Timeout interval.
The NCBI C++ standard methods for dealing with std::string.
static DLIST_TYPE *DLIST_NAME() first(DLIST_LIST_TYPE *list)
static CNcbiApplicationGuard InstanceGuard(void)
Singleton method.
CVersionInfo GetVersion(void) const
Get the program version information.
const string & GetProgramDisplayName(void) const
Get the application's "display" name.
#define ERR_POST_ONCE(message)
Error posting only once during program execution.
CDiagContext & GetDiagContext(void)
Get diag context instance.
#define NCBI_THROW(exception_class, err_code, message)
Generic macro to throw an exception, given the exception class, error code and message string.
void Warning(CExceptionArgs_Base &args)
CHttpResponse Get(const CUrl &url, const CTimeout &timeout=CTimeout(CTimeout::eDefault), THttpRetries retries=null)
Shortcut for GET requests.
int GetStatusCode(void) const
Get response status code.
CNullable< unsigned short, SGetHttpDefaultRetries > THttpRetries
Nullable retries for CHttpRequest.
#define NCBI_PARAM_TYPE(section, name)
Generate typename for a parameter from its {section, name} attributes.
@ eParam_NoThread
Do not use per-thread values.
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
std::thread m_Thread
Reporting thread.
static void SetMaxQueueSize(unsigned n)
Declare the maximum reporting jobs queue size per reporter.
string m_URL
Reporting URL.
void x_SetState(EState state)
Set new job state.
std::map< string, string > m_Params
Stored parameters.
void x_CopyFrom(const CUsageReportParameters &other)
Copy parameters to another objects.
unsigned GetQueueSize(void)
Get number of jobs in the queue â number of unprocessed yet jobs.
virtual void OnStateChange(EState)
Callback for async reporting.
static CTimeout GetTimeout()
Return timeout for network connection, if specified.
static void SetAppName(const string &name)
Set application name for the usage reporters.
std::condition_variable m_ThreadSignal
Signal conditional variable for reporting thread synchronization.
static void SetTimeout(const CTimeout &timeout)
Set timeout for connection.
void x_CopyFrom(const CUsageReportJob &other)
Copy data from 'other' job.
static void SetRetries(int retries)
Set muximum number of retries in case of error reporting.
string ToString() const
Convert parameters to string. URL-encode all values.
static string GetAppName(void)
EWait m_WaitMode
Waiting mode.
void Finish(void)
Finish reporting for the current reporting object.
std::mutex m_ThreadSignal_Mutex
void Send(void)
Report usage statistics (asynchronously), default parameters.
void x_SendAsync(TJobPtr job_ptr)
Send job asynchronously.
bool m_IsEnabled
Enable/disable status.
size_t m_CountTotal
Statistics: number of jobs processed.
int TWhat
Binary OR of "EWhat".
void x_ThreadHandler(void)
Thread handler for asynchronous job reporting.
static void SetAppVersion(const string &version)
Set application version for the usage reporter(s).
bool m_IsFinishing
TRUE if Finish() has called and reporting thread should terminate.
static void SetDefaultParameters(TWhat what=fDefault)
Set default reporting parameters.
void SetEnabled(bool enable=true)
Enable or disable usage reporter (current instance only).
EState m_State
Job state.
CUsageReportParameters & Add(const string &name, const string &value)
Add argument Name must contain only alphanumeric chars or '_'.
unsigned m_MaxQueueSize
Maximum allowed queue size.
void ClearQueue(void)
Remove all unprocessed reporting jobs from queue.
static string GetURL(void)
string m_DefaultParams
Default parameters to report, concatenated and URL-encoded.
CUsageReport(TWhat what=fDefault, const string &url=string(), unsigned max_queue_size=0)
Constructor.
static CUsageReport & Instance(void)
Return global instance of CUsageReport.
static TWhat GetDefaultParameters(void)
CDeadline m_WaitDeadline
Deadline for Wait(), if active.
static void SetEnabled(bool enable=true)
Enable or disable usage statistics reporting globally for all reporters.
static string GetAppVersion(void)
bool x_Send(const string &extra_params)
Send parameters string synchronously.
static int GetRetries()
Return muximum number of retries in case of error reporting, if specified.
static bool IsEnabled(void)
Indicates whether global application usage statistics collection is enabled.
static unsigned GetMaxQueueSize()
bool m_IsWaiting
TRUE if Wait() is active.
void x_ClearQueue(void)
Remove all unprocessed reporting jobs from queue - internal version.
size_t m_CountSent
Statistics: number of jobs successfully sent.
static void SetURL(const string &url)
Change CGI URL for reporting usage statistics.
bool CheckConnection()
Check that connection to the reporting URL can be established.
void Wait(EWait how=eAlways, CTimeout timeout=CTimeout(CTimeout::eDefault))
Wait until all queued jobs starts to process and queue is empty.
static bool CheckConnection()
Check that connection to reporting URL can be established.
list< TJobPtr > m_Queue
Job queue.
bool IsEnabled(void)
Indicates whether application usage statistics collection is enabled for a current reporter instance.
virtual ~CUsageReport(void)
Destructor.
@ fAppVersion
Application version ("version")
@ fHost
Host name ("host")
@ fAppName
Application name ("appname")
@ eQueued
Added to queue (sending temporary postpones)
@ eFailed
Result: send failed.
@ eCanceled
Result: canceled / removed from queue.
@ eRejected
Result: rejected / too many requests.
@ eCompleted
Result: successfully sent.
@ eRunning
Ready to send.
@ eSkipIfNoConnection
Do not try to send remaining jobs in the queue if all previous attempts failed.
static bool StringToBool(const CTempString str)
Convert string to bool.
static string URLEncode(const CTempString str, EUrlEncode flag=eUrlEnc_SkipMarkChars)
URL-encode string.
@ eUrlEnc_URIQueryValue
Encode query part of an URI, arg value.
@ eUrlEnc_URIQueryName
Encode query part of an URI, arg name.
bool IsExpired(void) const
Check if the deadline is expired.
double GetAsDouble(void) const
Get as number of seconds (fractional value).
void Set(EType type)
Set special value.
bool IsFinite() const
Check if timeout holds a numeric value.
@ eDefault
Default timeout (to be interpreted by the client code)
@ eInfinite
Infinite timeout.
virtual string Print(void) const
Print version information.
const string version
version string
const GenericPointer< typename T::ValueType > T2 value
const double kDefault_WaitTimeout
bool s_CheckConnection(const string &url)
const unsigned kDefault_MaxQueueSize
const bool kDefault_IsEnabled
static atomic< CUsageReport::TWhat > gs_DefaultParams(CUsageReport::fDefault)
CUsageReportAPI::
const int kDefault_ConnMaxTry
void s_AddDefaultParam(CUsageReportParameters ¶ms, const string &name, const string &value)
const char * kDefault_URL
#define MT_GUARD
Helpers.
NCBI_PARAM_DEF_EX(string, USAGE_REPORT, URL, kDefault_URL, eParam_NoThread, NCBI_USAGE_REPORT_URL)
NCBI_PARAM_DECL(string, USAGE_REPORT, URL)
const double kDefault_ConnTimeout
static string s_GetHost()
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