Skip to content

Commit

Permalink
Merge pull request #242 from jupp0r/uninline-gateway-functions
Browse files Browse the repository at this point in the history
Uninline code from gateway
  • Loading branch information
gjasny committed Dec 15, 2018
2 parents 09f56af + 594c0a1 commit 9d0a50f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
20 changes: 10 additions & 10 deletions push/include/prometheus/gateway.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,15 @@ class Gateway {

static const Labels GetInstanceLabel(std::string hostname);

enum class HttpMethod {
Post,
Put,
Delete,
};

// Push metrics to the given pushgateway.
int Push() { return push(HttpMethod::Post); }
int Push();

std::future<int> AsyncPush() { return async_push(HttpMethod::Post); }
std::future<int> AsyncPush();

// PushAdd metrics to the given pushgateway.
int PushAdd() { return push(HttpMethod::Put); }
int PushAdd();

std::future<int> AsyncPushAdd() { return async_push(HttpMethod::Put); }
std::future<int> AsyncPushAdd();

// Delete metrics from the given pushgateway.
int Delete();
Expand All @@ -57,6 +51,12 @@ class Gateway {

std::string getUri(const CollectableEntry& collectable) const;

enum class HttpMethod {
Post,
Put,
Delete,
};

int performHttpRequest(HttpMethod method, const std::string& uri,
const std::string& body) const;

Expand Down
8 changes: 8 additions & 0 deletions push/src/gateway.cc
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,10 @@ std::string Gateway::getUri(const CollectableEntry& collectable) const {
return uri.str();
}

int Gateway::Push() { return push(HttpMethod::Post); }

int Gateway::PushAdd() { return push(HttpMethod::Put); }

int Gateway::push(HttpMethod method) {
const auto serializer = TextSerializer{};

Expand All @@ -143,6 +147,10 @@ int Gateway::push(HttpMethod method) {
return 200;
}

std::future<int> Gateway::AsyncPush() { return async_push(HttpMethod::Post); }

std::future<int> Gateway::AsyncPushAdd() { return async_push(HttpMethod::Put); }

std::future<int> Gateway::async_push(HttpMethod method) {
const auto serializer = TextSerializer{};
std::vector<std::future<int>> futures;
Expand Down

0 comments on commit 9d0a50f

Please sign in to comment.