Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ready signal for cluster announce and publish #175

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions include/cocaine/context.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ class context_t {
// Fired first thing on context shutdown. This is a very good time to cleanup persistent
// connections, synchronize disk state and so on.
context_signals_t shutdown;

// Fired on all static service creation.
context_signals_t ready;
};

// Lifecycle management signals.
Expand Down
4 changes: 2 additions & 2 deletions src/cluster/multicast.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,8 @@ multicast_t::multicast_t(context_t& context, interface& locator, const std::stri
std::bind(&multicast_t::on_receive, this, ph::_1, ph::_2, announce)
);

m_timer.expires_from_now(m_cfg.interval);
m_timer.async_wait(std::bind(&multicast_t::on_publish, this, ph::_1));
//First publish right after all service are started.
context.signals.ready.connect(std::bind(&multicast_t::on_publish, this, std::error_code()));
}

multicast_t::~multicast_t() {
Expand Down
4 changes: 2 additions & 2 deletions src/cluster/predefine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ predefine_t::predefine_t(context_t& context, interface& locator, const std::stri
);
}

m_timer.expires_from_now(m_cfg.interval);
m_timer.async_wait(std::bind(&predefine_t::on_announce, this, ph::_1));
//First announce right after all service are started.
context.signals.ready.connect(std::bind(&predefine_t::on_announce, this, std::error_code()));
}

predefine_t::~predefine_t() {
Expand Down
2 changes: 2 additions & 0 deletions src/context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,8 @@ context_t::bootstrap() {
}
}

signals.ready();

if(!errored.empty()) {
std::ostringstream stream;
std::ostream_iterator<char> builder(stream);
Expand Down