OmniSciDB  72c90bc290
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RequestInfo.h
Go to the documentation of this file.
1 /*
2  * Copyright 2022 HEAVY.AI, Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 /*
18  * @file RequestInfo.h
19  * @description A struct for parsing TSessionInfo that contains a request_id.
20  */
21 
22 #pragma once
23 
24 #include "Logger/Logger.h"
25 
26 namespace heavyai {
27 
28 class RequestInfo {
29  std::string session_id_;
31 
32  public:
33  // If session_id_or_json starts with a '{' then it is assumed a json object.
34  // Otherwise interpret as a session_id and set request_id_=0;
35  RequestInfo(std::string const& session_id_or_json);
36  RequestInfo(std::string session_id, logger::RequestId const request_id)
37  : session_id_(std::move(session_id)), request_id_(request_id) {}
38  std::string json() const;
40  std::string const& sessionId() const { return session_id_; }
41  // Set request_id_ to current g_thread_local_ids.request_id_.
43 };
44 
45 } // namespace heavyai
logger::RequestId request_id_
Definition: RequestInfo.h:30
logger::RequestId requestId() const
Definition: RequestInfo.h:39
RequestInfo(std::string const &session_id_or_json)
Definition: RequestInfo.cpp:9
std::string session_id_
Definition: RequestInfo.h:29
std::string json() const
Definition: RequestInfo.cpp:22
RequestInfo(std::string session_id, logger::RequestId const request_id)
Definition: RequestInfo.h:36
RequestId request_id()
Definition: Logger.cpp:874
std::string const & sessionId() const
Definition: RequestInfo.h:40
uint64_t RequestId
Definition: Logger.h:131
void setRequestId(logger::RequestId const request_id)
Definition: RequestInfo.h:42