CernVM-FS
2.12.0
|
#include <subscriber_sse.h>
Public Member Functions | |
SubscriberSSE (const std::string &server_url) | |
virtual | ~SubscriberSSE () |
virtual bool | Subscribe (const std::string &topic) |
virtual void | Unsubscribe () |
Public Member Functions inherited from notify::Subscriber | |
Subscriber () | |
virtual | ~Subscriber () |
Private Member Functions | |
bool | ShouldQuit () const |
void | AppendToBuffer (const std::string &s) |
void | ClearBuffer () |
Static Private Member Functions | |
static size_t | CurlRecvCB (void *buffer, size_t size, size_t nmemb, void *userp) |
static int | CurlProgressCB (void *clientp, curl_off_t dltotal, curl_off_t dlnow, curl_off_t ultotal, curl_off_t ulnow) |
Private Attributes | |
std::string | server_url_ |
std::string | topic_ |
std::string | buffer_ |
atomic_int32 | should_quit_ |
Additional Inherited Members | |
Public Types inherited from notify::Subscriber | |
enum | Status { kContinue, kFinish, kError } |
Protected Member Functions inherited from notify::Subscriber | |
virtual Status | Consume (const std::string &topic, const std::string &msg_text)=0 |
Notification system subscriber based on server-sent events (SSE)
This class uses Curl to establish a long-lived HTTP connection to the notification system server. The expected response is of type "text/event-stream". The repository activity messages arrive as text lines with the following format:
data: <MESSAGE body>="">
The class is responsible for extracting the body of each message from the responses and consuming the messages when needed.
Definition at line 30 of file subscriber_sse.h.
|
explicit |
Definition at line 25 of file subscriber_sse.cc.
|
virtual |
Definition at line 32 of file subscriber_sse.cc.
|
private |
Append a string to the internal receive buffer
The given string is stripped of any event stream protocol prefix ("data: "), before being appended to the internal buffer used by the Curl receive callback.
Definition at line 102 of file subscriber_sse.cc.
Referenced by CurlRecvCB().
|
private |
Definition at line 110 of file subscriber_sse.cc.
Referenced by CurlRecvCB().
|
staticprivate |
Definition at line 149 of file subscriber_sse.cc.
Referenced by Subscribe().
|
staticprivate |
Definition at line 112 of file subscriber_sse.cc.
Referenced by Subscribe().
|
private |
Definition at line 98 of file subscriber_sse.cc.
Referenced by CurlProgressCB().
|
virtual |
Subscribe to a specific message topic
The only topics currently used by the notification system are repository names. The subscription delivers activity messages containing the current repository manifest. Returns false if an error occurred.
Implements notify::Subscriber.
Definition at line 34 of file subscriber_sse.cc.
|
virtual |
Unsubscribe
Cancel an active subscription
Reimplemented from notify::Subscriber.
Definition at line 94 of file subscriber_sse.cc.
Referenced by CurlRecvCB().
|
private |
Definition at line 59 of file subscriber_sse.h.
Referenced by AppendToBuffer(), ClearBuffer(), CurlRecvCB(), and Subscribe().
|
private |
Definition at line 57 of file subscriber_sse.h.
Referenced by Subscribe().
|
mutableprivate |
Definition at line 61 of file subscriber_sse.h.
Referenced by ShouldQuit(), and Unsubscribe().
|
private |
Definition at line 58 of file subscriber_sse.h.
Referenced by CurlRecvCB(), and Subscribe().