cluck 1.0.1
The cluster lock service.
Namespaces | Functions | Variables
cluck_status.cpp File Reference

Implements the cluck status signal. More...

#include "cluck/cluck_status.h"
#include "cluck/exception.h"
#include "cluck/names.h"
#include <communicator/names.h>
#include <eventdispatcher/names.h>
#include <snapdev/poison.h>
Include dependency graph for cluck_status.cpp:

Go to the source code of this file.

Namespaces

namespace  cluck
 
namespace  cluck::anonymous_namespace{cluck_status.cpp}
 

Functions

bool cluck::is_lock_ready ()
 Check the current status of the cluck daemon.
 
void cluck::listen_to_cluck_status (ed::connection_with_send_message::pointer_t messenger, ed::dispatcher::pointer_t dispatcher, typename ed::dispatcher_match::execute_callback_t callback)
 Start listening to changes in the cluck status.
 
void cluck::anonymous_namespace{cluck_status.cpp}::msg_lock_status (ed::message &msg, typename ed::dispatcher_match::execute_callback_t callback)
 Setup the lock status.
 
void cluck::anonymous_namespace{cluck_status.cpp}::msg_ready (ed::message &msg, ed::connection_with_send_message::weak_t messenger)
 Also register for the READY message.
 

Variables

bool cluck::anonymous_namespace{cluck_status.cpp}::g_lock_ready = false
 Record the current status of the cluck daemon.
 

Detailed Description

When the cluck daemon is ready to receive LOCK messages, it sends a LOCK_READY to the local services. Until that message is received by clients, the cluck daemon is unresponsive or not even running. This means trying to obtain a lock may just time out.

The cluck status functions allow you to get notified once the lock system is ready. It does the following:

When it receives a LOCK_READY, it marks the cluck status as valid, ready to receive LOCK messages.

When it receives a NO_LOCK, it marks the cluck status as invalid, attempting to obtain a LOCK may result in a timeout because the cluck daemon is not ready.

Usage:

To initialize the lock status listener, call cluck::listen_to_cluck_status(). It expects a pointer to your messenger, dispatcher, and a callback. The callback gets called each time the status changes. It is optional and can be set to a null pointer.

To know the current status, call the cluck::is_lock_ready() function. If it returns false, then the cluck daemon is not yet ready. If it returns true, a LOCK will work as expected.

Definition in file cluck_status.cpp.

This document is part of the Snap! Websites Project.

Copyright by Made to Order Software Corp.