-
Notifications
You must be signed in to change notification settings - Fork 46
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
Support for the LISTEN / NOTIFY functionality? #231
Labels
feature
feature request
Comments
Hi Michael! Yep, what do you think about such an interface? class notification {
public:
/* notification channel name */
std::string_view relname() const noexcept;
/* process ID of notifying server process */
int backend_pid() const noexcept;
/* notification payload string */
std::string_view extra() const noexcept;
/* true if has notification */
operator bool () const noexcept;
bool operator!() const noexcept;
private:
std::shared_ptr<const ::PGnotify> v_; // to be easy copyable
};
template <typename Connection>
notification get_notification(Connection& conn);
template <typename Connection, typename CompletionToken>
auto wait_notification(Connection&& conn, CompletionToken continuation);
template <typename Connection, typename TimeConstraint, typename CompletionToken>
auto wait_notification(Connection&& conn, TimeConstraint t, CompletionToken continuation); And usage like: auto conn = ozo::request(..., yield);
// trying to get notification that may be received during the request operation
auto notification = ozo::get_notification(conn);
while(!notification) {
// trying to wait for notification
wait_notification(conn, yield);
notification = ozo::get_notification(conn);
}
// handle notification
std::cout << notification.extra() << std::endl; |
Comments or suggestions inline below.
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
E.g.: https://www.postgresql.org/docs/11/sql-listen.html
The text was updated successfully, but these errors were encountered: