Project

General

Profile

Actions

Feature #993

closed

Postgres NOTIFY

Added by Boris Nagaev almost 15 years ago. Updated 2 days ago.

Status:
Closed
Priority:
Normal
Target version:
Start date:
09/20/2011
Due date:
% Done:

0%

Estimated time:

Description

Hello!

It would be great if Postgres connection class provided high-level notifying system, based on Postgres NOTIFY.

It could look like:

template<T>
WSignal<dbo::ptr<T> > listen();

template<T>
void notify(dbo::ptr<T>);

This can be used to notify other sessions (inside or outside this process or PC).

Applications seem to use not sqlite3, but postgres in production, and this notifying system seems useful for production applications.

Maybe these methods should be methods of Session or WServer...

This idea was inspired by WServer::post, which can be used for Dbo object update notifying.

BR

Actions #1

Updated by Koen Deforche over 14 years ago

Hey,

I like the suggestion. I think we need to implement it, it looks like a fun feature, and should be done by using WServer::post().

I think we need to add a utiliy class in Wt that implements this that implements this on behalf of one or more Dbo::Session classes (typically one per listening application), and internally keeps track of interested sessions/listeners. It needs a dedicated database connection, and thread (libpq's API for this is synchronous and requires polling, but they suggest you can select() on the connection). We should thus provide basic support for this in the SqlConnection class.

e.g.

class WDboReactor : public WObject
{
public:
  WDboReactor(SqlConnection *connection);

  void notify(const std::string& message);

  template <typename T>
  std::string encodeMessage(const std::string& event, const Wt::Dbo::ptr<T>& object);

  template <typename T>
  bool decodeMessage(const std::string& message, std::string& event, Wt::Dbo::ptr<T>& object);

  void addListener(WObject *object);
  void removeListener(WObject *object);

  Signal<WObject *object, std::string>& notified(); // emitted within the same application as the object lives, using WServer::post().
};

I would suggest to have both a Dbo::ptr<> and a string as parameters.

Regards,

koen

Actions #2

Updated by Matthias Van Ceulebroeck almost 2 years ago

  • Description updated (diff)
  • Assignee set to Romain Mardulyn
Actions #3

Updated by Romain Mardulyn almost 2 years ago

  • Status changed from New to InProgress
Actions #4

Updated by Romain Mardulyn almost 2 years ago

  • Status changed from InProgress to Review
  • Assignee deleted (Romain Mardulyn)
Actions #5

Updated by Matthias Van Ceulebroeck over 1 year ago

  • Target version set to 4.12.0
Actions #6

Updated by Matthias Van Ceulebroeck about 1 year ago

  • Assignee set to Matthias Van Ceulebroeck
Actions #7

Updated by Matthias Van Ceulebroeck about 1 year ago

  • Target version changed from 4.12.0 to 4.13.0
Actions #8

Updated by Romain Mardulyn 3 months ago

  • Target version changed from 4.13.0 to 4.14.0
Actions #9

Updated by emil de keyser about 1 month ago

  • Assignee changed from Matthias Van Ceulebroeck to emil de keyser
Actions #10

Updated by emil de keyser about 1 month ago

  • Status changed from Review to InProgress
  • Assignee changed from emil de keyser to Romain Mardulyn
Actions #11

Updated by Romain Mardulyn 30 days ago

  • Status changed from InProgress to Review
  • Assignee changed from Romain Mardulyn to emil de keyser
Actions #12

Updated by Romain Mardulyn 30 days ago

  • Status changed from Review to Resolved
  • Assignee changed from emil de keyser to Romain Mardulyn
Actions #13

Updated by emil de keyser 24 days ago

  • Status changed from Resolved to InProgress
Actions #14

Updated by Romain Mardulyn 19 days ago

  • Status changed from InProgress to Review
  • Assignee changed from Romain Mardulyn to emil de keyser
Actions #15

Updated by emil de keyser 17 days ago

  • Status changed from Review to Resolved
  • Assignee changed from emil de keyser to Romain Mardulyn
Actions #16

Updated by Romain Mardulyn 12 days ago

  • Status changed from Resolved to Implemented @Emweb
Actions #17

Updated by Romain Mardulyn 2 days ago

  • Status changed from Implemented @Emweb to Closed
Actions

Also available in: Atom PDF