47 return "ePSGS_InProgress";
51 return "ePSGS_NotFound";
55 return "ePSGS_Canceled";
57 return "ePSGS_Timeout";
59 return "ePSGS_Unauthorized";
63 return "unknown (" + to_string(status) +
")";
85 return "unauthorized";
89 return "unknown (" + to_string(status) +
")";
132 if (uv_thread_id == 0) {
136 "tries to schedule a postponed callback before "
137 "a thread was assigned to the processor (request id: " +
138 to_string(
m_Request->GetRequestId()) +
").";
144 app->GetUvLoopBinder(uv_thread_id).PostponeInvoke(cb, user_data,
146 }
catch (
const exception & exc) {
147 PSG_ERROR(
"Error scheduling a postponed callback by the processor '" +
148 GetName() +
"' (while serving request id: " +
149 to_string(
m_Request->GetRequestId()) +
"): " + exc.what());
152 PSG_ERROR(
"Unknown error scheduling a postponed callback by the processor '" +
153 GetName() +
"' (while serving request id: " +
154 to_string(
m_Request->GetRequestId()) +
")");
171 if (uv_thread_id == 0) {
175 "tries to schedule a socket callback before "
176 "a thread was assigned to the processor (request id: " +
177 to_string(
m_Request->GetRequestId()) +
").";
183 app->GetUvLoopBinder(uv_thread_id).SetSocketCallback(
184 fd, event, timeout_millisec, user_data,
185 event_cb, timeout_cb, error_cb,
187 }
catch (
const exception & exc) {
188 PSG_ERROR(
"Error scheduling a socket callback by the processor '" +
189 GetName() +
"' (while serving request id: " +
190 to_string(
m_Request->GetRequestId()) +
"): " + exc.what());
193 PSG_ERROR(
"Unknown error scheduling a socket callback by the processor '" +
194 GetName() +
"' (while serving request id: " +
195 to_string(
m_Request->GetRequestId()) +
")");
203 int request_seq_id_type,
207 auto parsed_seq_id_type = parsed_seq_id.
Which();
208 bool parsed_seq_id_type_found = (parsed_seq_id_type !=
211 if (!parsed_seq_id_type_found && request_seq_id_type < 0) {
212 eff_seq_id_type = -1;
216 if (!parsed_seq_id_type_found) {
217 eff_seq_id_type = request_seq_id_type;
221 if (request_seq_id_type < 0) {
222 eff_seq_id_type = parsed_seq_id_type;
227 if (parsed_seq_id_type == request_seq_id_type) {
228 eff_seq_id_type = request_seq_id_type;
237 "Seq id type mismatch. Parsed CSeq_id reports seq_id_type as " +
238 to_string(parsed_seq_id_type) +
" while the URL reports " +
239 to_string(request_seq_id_type) +
". They both belong to INSDC types so "
240 "CSeq_id provided type " + to_string(parsed_seq_id_type) +
241 " is taken as an effective one",
244 eff_seq_id_type = parsed_seq_id_type;
254 const string& request_seq_id,
255 int request_seq_id_type,
258 bool need_trace =
m_Request->NeedTrace();
262 seq_id.
Set(request_seq_id);
264 m_Reply->SendTrace(
"Parsing CSeq_id('" + stripped_seq_id +
265 "') succeeded",
m_Request->GetStartTimestamp());
267 if (request_seq_id_type <= 0) {
269 m_Reply->SendTrace(
"Parsing CSeq_id finished OK (#1)",
278 m_Reply->SendTrace(
"Parsing CSeq_id finished OK (#2)",
287 m_Reply->SendTrace(
"CSeq_id provided type " + to_string(seq_id_type) +
288 " and URL provided seq_id_type " +
289 to_string(request_seq_id_type) +
" mismatch",
296 m_Reply->SendTrace(
"Both types belong to INSDC types.\n"
297 "Parsing CSeq_id finished OK (#3)",
305 *err_msg =
"Seq_id '" + request_seq_id +
306 "' possible type mismatch: the URL provides " +
307 to_string(request_seq_id_type) +
308 " while the CSeq_Id detects it as " +
309 to_string(
static_cast<int>(seq_id_type));
313 m_Reply->SendTrace(
"Parsing CSeq_id('" + stripped_seq_id +
314 "') failed (exception)",
319 if (request_seq_id_type > 0) {
325 m_Reply->SendTrace(
"Parsing CSeq_id(eFasta_AsTypeAndContent, " +
326 to_string(request_seq_id_type) +
327 ", '" + stripped_seq_id +
"') succeeded.\n"
328 "Parsing CSeq_id finished OK (#4)",
334 m_Reply->SendTrace(
"Parsing CSeq_id(eFasta_AsTypeAndContent, " +
335 to_string(request_seq_id_type) +
336 ", '" + stripped_seq_id +
"') failed (exception)",
342 m_Reply->SendTrace(
"Parsing CSeq_id finished FAILED",
365 int request_seq_id_type)
367 auto parsed_seq_id_type = parsed_seq_id.
Which();
368 bool parsed_seq_id_type_found = (parsed_seq_id_type !=
371 if (!parsed_seq_id_type_found && request_seq_id_type < 0) {
375 if (!parsed_seq_id_type_found) {
379 if (request_seq_id_type < 0) {
384 if (parsed_seq_id_type == request_seq_id_type) {
function< EPSGS_PollContinue(void *user_data)> TEventCB
function< EPSGS_PollContinue(void *user_data)> TTimeoutCB
function< EPSGS_PollContinue(const string &message, void *user_data)> TErrorCB
function< void(void *user_data)> TProcessorCB
IPSGS_Processor::EPSGS_StartProcessing SignalStartProcessing(IPSGS_Processor *processor)
void SignalFinishProcessing(IPSGS_Processor *processor, CPSGS_Dispatcher::EPSGS_SignalSource signal_source)
static CPubseqGatewayApp * GetInstance(void)
virtual string GetName(void) const =0
Tells the processor name (used in logging and tracing)
static string StatusToString(EPSGS_Status status)
Converts the processor status to a string for tracing and logging purposes.
psg_time_point_t m_ProcessInvokeTimestamp
void OnBeforeProcess(void)
Called just before the virtual Process() method is called.
psg_time_point_t m_SignalStartTimestamp
void SetSocketCallback(int fd, CPSGS_SocketIOCallback::EPSGS_Event event, uint64_t timeout_millisec, void *user_data, CPSGS_SocketIOCallback::TEventCB event_cb, CPSGS_SocketIOCallback::TTimeoutCB timeout_cb, CPSGS_SocketIOCallback::TErrorCB error_cb)
The provided callbacks will be called from the libuv loop assigned to the processor when the correspo...
uv_thread_t GetUVThreadId(void) const
Provides the libuv thread id which runs the processor.
shared_ptr< CPSGS_Reply > m_Reply
EPSGS_StartProcessing
Tells wether to continue or not after a processor called SignalStartProcessing() method.
bool m_SignalStartTimestampInitialized
bool GetEffectiveSeqIdType(const objects::CSeq_id &parsed_seq_id, int request_seq_id_type, int16_t &eff_seq_id_type, bool need_trace)
psg_time_point_t m_SignalFinishTimestamp
EPSGS_Status
The GetStatus() method returns a processor current status.
void PostponeInvoke(CPSGS_UvLoopBinder::TProcessorCB cb, void *user_data)
The provided callback will be called from the libuv loop assigned to the processor.
bool m_ProcessInvokeTimestampInitialized
void SignalFinishProcessing(void)
A processor should call this method when it decides that there is nothing else to be done.
EPSGS_StartProcessing SignalStartProcessing(void)
A processor should call the method when it decides that it successfully started processing the reques...
shared_ptr< CPSGS_Request > m_Request
bool m_SignalFinishTimestampInitialized
EPSGS_SeqIdParsingResult ParseInputSeqId(objects::CSeq_id &seq_id, const string &request_seq_id, int request_seq_id_type, string *err_msg=nullptr)
Parse seq-id from a string and type representation.
static string StatusToProgressMessage(EPSGS_Status status)
Converts the processor status to a string for protocol message.
#define NCBI_THROW(exception_class, err_code, message)
Generic macro to throw an exception, given the exception class, error code and message string.
CSeq_id & Set(const CTempString &the_id, TParseFlags flags=fParse_AnyRaw)
Reassign based on flat specifications; arguments interpreted as with constructors.
@ eFasta_AsTypeAndContent
E_Choice Which(void) const
Which variant is currently selected.
@ e_not_set
No variant selected.
bool IsINSDCSeqIdType(CBioseqInfoRecord::TSeqIdType seq_id_type)
bool AreSeqIdTypesMatched(const CSeq_id &parsed_seq_id, int request_seq_id_type)
bool g_AllowProcessorTiming
string StripTrailingVerticalBars(const string &seq_id)
#define PSG_ERROR(message)
static SLJIT_INLINE sljit_ins msg(sljit_gpr r, sljit_s32 d, sljit_gpr x, sljit_gpr b)