-
Notifications
You must be signed in to change notification settings - Fork 38
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
[#284] link events and pre events, improve README #285
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Please apply grammar and spell changes to the entirety of the README changes regardless of where they were noticed (i.e. I only marked each issue once or twice).
- Please add tests for the linked events functionality.
@@ -75,6 +75,48 @@ These three concepts have a specific meaning in the context of sumo_db. | |||
TO implement an adapter, you must implement two behaviors: `sumo_backend` and | |||
`sumo_store`. | |||
|
|||
## Events | |||
|
|||
Sumo throws events when things happen. An Event has this structure: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
throws -> dispatches
- `Event` is the type of the event. | ||
- `Args` extra data sent. | ||
|
||
Those are the current supported events: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
supported types of events
(to match the paragraph above)
|
||
Those are the current supported events: | ||
|
||
- `pre_persisted` just before persisting some entity. This event has the entity we want to persist as an `Args`. It is throw on this function: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
throw -> dispatched
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as an Args
-> as Args
|
||
- `pre_persisted` just before persisting some entity. This event has the entity we want to persist as an `Args`. It is throw on this function: | ||
- `sumo:persist/2` | ||
- `persisted` just after persisting some entity. This event hast the persisted entity as an `Args` It is throw on this function: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a note stating that it keeps the same EventId as the corresponding pre_persisted
- `sumo:persist/2` | ||
- `persisted` just after persisting some entity. This event hast the persisted entity as an `Args` It is throw on this function: | ||
- `sumo:persist/2` | ||
- `pre_delete_all` just before deleting all entities for one model. This event has no `Args`. It is throw on this function: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
one model -> a model
- `schema_created` just after creating a sumo schema. This event has no `Args`. It is throw on this function: | ||
- `sumo:create_schema/2` | ||
|
||
Sumo allows users to add their own `gen_event`'s in order to handle those events. In order to add them Users have to configure sumo properly. In the `config` file we can add them like this under `sumo_db` configuration: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
allows -> requires
@@ -41,6 +46,7 @@ dispatch(DocName, Event, Args) -> | |||
ok; | |||
EventManagers -> | |||
lists:foreach(fun(EventManager) -> | |||
gen_event:notify(EventManager, {DocName, Event, Args}) | |||
EventId = make_ref(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will not work… EventId
must be preserved between linked instances of pre_
and regular events
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oops you are right...
[close #284]