on master help sign in
#1 complete first-pass implementation of asynchronous notifications
commitc08df8154a086113659b4eae2dd2a0289b9d1bd0 authorAgentM <agentm@themactionfaction.com> dateMon 1 Feb 2016, 16:12 (11 years ago) parent722fd24
2 files changed+29−4
README.markdown+4−3 docs/using_notifications.markdown+25−1
README.markdown+4−3
@@ -32,10 +32,11 @@ Project:M36 supports multiple frontends which target different audiences.
32321. [Adding New Data Types](docs/new_datatypes.markdown)
33331. [ACID Database Properties](docs/acid_assessment.markdown)
34341. [Serving Remote ProjectM36 Databases](docs/server_mode.markdown)
35−
35+1. [Using Notifications](docs/using_notifications.markdown)
36+
3637## Development
3738
38−Project:M36 is developed in Haskell and compiled with GHC.
39+Project:M36 is developed in Haskell and compiled with GHC.
3940
4041Important modules:
4142
@@ -53,4 +54,4 @@ Other modules include:
5354* relational expression cost-based optimizer
5455* relational error enumeration
5556* import of CSV as a relation and export of a relation to CSV
56−* import of TutorialD from files
57+* import of TutorialD from files
docs/using_notifications.markdown+25−1
@@ -62,4 +62,28 @@ TutorialD (master): :commit
6262TutorialD (master): Notification received "steve_change": ...
6363```
6464
65−The notification contains the result from the evaluated report relational expression.
65+The asynchronously-received notification contains the result from the evaluated report relational expression. The expression, in this case, is the result of the report expression evaluated against the parent transactoin
66+
67+```
68+TutorialD (master): Notification received "steve_change":
69+Project (AttributeNames (fromList ["address"])) (Restrict (AttributeEqualityPredicate "name" (NakedAtomExpr Atom "Steve")) (RelationVariable "person"))
70+┌────────┐
71+│address │
72+├────────┤
73+│Main St.│
74+└────────┘
75+```
76+
77+## Notifications with ProjectM36.Client
78+
79+First, implement a ```NotificationCallback``` function to perform an IO action when an asynchronous notification is received from the DBMS. Note that this function will not be called on any specific thread; specifically, the callback is *not* triggered by calling into ProjectM36.Client functions.
80+
81+Each ProjectM36 Connection can only have one callback and it cannot be changed after Connection creation.
82+
83+Then, create a DatabaseExpr using the AddNotification constructor:
84+
85+```
86+AddNotification <notification name::Text> <change expression::RelationalExpr> <report expression::RelationalExpr>
87+```
88+
89+and execute it using ```executeDatabaseContextExpr```. In order for a notification to take effect, it must be committed as well.