-
Notifications
You must be signed in to change notification settings - Fork 300
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
112 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#pragma once | ||
|
||
#include <string> | ||
|
||
#include <stdexcept> | ||
|
||
USERVER_NAMESPACE_BEGIN | ||
|
||
namespace storages::etcd { | ||
|
||
/// @brief Base class for all etcd client exceptions | ||
class EtcdError : public std::runtime_error { | ||
public: | ||
using std::runtime_error::runtime_error; | ||
}; | ||
|
||
} | ||
|
||
USERVER_NAMESPACE_END |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#pragma once | ||
|
||
#include <string> | ||
|
||
#include <userver/concurrent/queue.hpp> | ||
|
||
USERVER_NAMESPACE_BEGIN | ||
|
||
namespace storages::etcd { | ||
|
||
struct KVEvent final { | ||
std::string key; | ||
std::string value; | ||
std::size_t version; | ||
}; | ||
|
||
struct WatchListener final { | ||
concurrent::SpscQueue<KVEvent>::Consumer consumer; | ||
|
||
KVEvent GetEvent(); | ||
}; | ||
|
||
} | ||
|
||
USERVER_NAMESPACE_END |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#include <userver/storages/etcd/watch_listener.hpp> | ||
|
||
#include <userver/storages/etcd/exceptions.hpp> | ||
|
||
USERVER_NAMESPACE_BEGIN | ||
|
||
namespace storages::etcd { | ||
|
||
KVEvent WatchListener::GetEvent() { | ||
KVEvent event; | ||
if (!consumer.Pop(event)) { | ||
throw EtcdError("Consumer pop failed"); | ||
} | ||
return event; | ||
} | ||
|
||
} // namespace formats::parse | ||
|
||
USERVER_NAMESPACE_END |