Skip to content

Commit 9be746c

Browse files
Enzo Bettiniorca-zhang
authored andcommitted
Added timestamp precision option to server_info
1 parent 64cc65f commit 9be746c

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

influxdb.hpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,11 @@ namespace influxdb_cpp {
3535
std::string host_;
3636
int port_;
3737
std::string db_;
38+
std::string precision_;
3839
std::string usr_;
3940
std::string pwd_;
40-
server_info(const std::string& host, int port, const std::string& db = "", const std::string& usr = "", const std::string& pwd = "")
41-
: host_(host), port_(port), db_(db), usr_(usr), pwd_(pwd) {}
41+
server_info(const std::string& host, int port, const std::string& db = "", const std::string& precision="ms", const std::string& usr = "", const std::string& pwd = "")
42+
: host_(host), port_(port), db_(db), precision_(precision), usr_(usr), pwd_(pwd) {}
4243
};
4344
namespace detail {
4445
struct meas_caller;
@@ -213,8 +214,8 @@ namespace influxdb_cpp {
213214

214215
for(;;) {
215216
iv[0].iov_len = snprintf(&header[0], len,
216-
"%s /%s?db=%s&u=%s&p=%s%s HTTP/1.1\r\nHost: %s\r\nContent-Length: %d\r\n\r\n",
217-
method, uri, si.db_.c_str(), si.usr_.c_str(), si.pwd_.c_str(),
217+
"%s /%s?db=%s&u=%s&p=%s&precision=%s%s HTTP/1.1\r\nHost: %s\r\nContent-Length: %d\r\n\r\n",
218+
method, uri, si.db_.c_str(), si.usr_.c_str(), si.pwd_.c_str(), si.precision_.c_str(),
218219
querystring.c_str(), si.host_.c_str(), (int)body.length());
219220
if((int)iv[0].iov_len >= len)
220221
header.resize(len *= 2);

0 commit comments

Comments
 (0)