CernVM-FS  2.12.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
notify::SubscriberSSE Class Reference

#include <subscriber_sse.h>

Inheritance diagram for notify::SubscriberSSE:
Collaboration diagram for notify::SubscriberSSE:

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
 

Detailed Description

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.

Constructor & Destructor Documentation

notify::SubscriberSSE::SubscriberSSE ( const std::string &  server_url)
explicit

Definition at line 25 of file subscriber_sse.cc.

notify::SubscriberSSE::~SubscriberSSE ( )
virtual

Definition at line 32 of file subscriber_sse.cc.

Member Function Documentation

void notify::SubscriberSSE::AppendToBuffer ( const std::string &  s)
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().

Here is the caller graph for this function:

void notify::SubscriberSSE::ClearBuffer ( )
private

Definition at line 110 of file subscriber_sse.cc.

Referenced by CurlRecvCB().

Here is the caller graph for this function:

int notify::SubscriberSSE::CurlProgressCB ( void *  clientp,
curl_off_t  dltotal,
curl_off_t  dlnow,
curl_off_t  ultotal,
curl_off_t  ulnow 
)
staticprivate

Definition at line 149 of file subscriber_sse.cc.

Referenced by Subscribe().

Here is the call graph for this function:

Here is the caller graph for this function:

size_t notify::SubscriberSSE::CurlRecvCB ( void *  buffer,
size_t  size,
size_t  nmemb,
void *  userp 
)
staticprivate

Definition at line 112 of file subscriber_sse.cc.

Referenced by Subscribe().

Here is the call graph for this function:

Here is the caller graph for this function:

bool notify::SubscriberSSE::ShouldQuit ( ) const
private

Definition at line 98 of file subscriber_sse.cc.

Referenced by CurlProgressCB().

Here is the caller graph for this function:

bool notify::SubscriberSSE::Subscribe ( const std::string &  topic)
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.

Here is the call graph for this function:

void notify::SubscriberSSE::Unsubscribe ( )
virtual

Unsubscribe

Cancel an active subscription

Reimplemented from notify::Subscriber.

Definition at line 94 of file subscriber_sse.cc.

Referenced by CurlRecvCB().

Here is the caller graph for this function:

Member Data Documentation

std::string notify::SubscriberSSE::buffer_
private

Definition at line 59 of file subscriber_sse.h.

Referenced by AppendToBuffer(), ClearBuffer(), CurlRecvCB(), and Subscribe().

std::string notify::SubscriberSSE::server_url_
private

Definition at line 57 of file subscriber_sse.h.

Referenced by Subscribe().

atomic_int32 notify::SubscriberSSE::should_quit_
mutableprivate

Definition at line 61 of file subscriber_sse.h.

Referenced by ShouldQuit(), and Unsubscribe().

std::string notify::SubscriberSSE::topic_
private

Definition at line 58 of file subscriber_sse.h.

Referenced by CurlRecvCB(), and Subscribe().


The documentation for this class was generated from the following files: