hyperledger-labs / fabric-smart-client

The Fabric Smart Client is a new Fabric Client that lets you focus on the business processes and simplifies the development of Fabric-based distributed application.
Apache License 2.0
51 stars 52 forks source link

Persistence notifiers #575

Open alexandrosfilios opened 4 months ago

alexandrosfilios commented 4 months ago

Currently, in order to subscribe to transaction status changes, we need to add a listener to the commit pipeline. Then every time a FSC node commits a transaction, this will also trigger all subscribers. However, for replicated nodes, only one of them will successfully commit the transaction, and all others will not be notified. Hence, all functionality that depends on these notifications will not be triggered. As a more generic solution, we can have notifiers for any type of table by extending the persistence interfaces with two methods:

// Subscribes to delete's, insert's and update's of column fields
Subscribe(callback func(operation string, values map[string]string)) error
// Unsubscribes the listener
Unsubscribe() error

Since we have multiple persistence implementations, these will have to be supported for the following:

For the first 3 cases, the approach will be similar to the current approach, where after each commit operation we also call a notifier. This approach will work, because these implementations do not support replication anyway. For the Postgres case, we need to use the Postgres notifiers, so that also all other replicas receive the notification.