Skip to content
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

Merged
merged 2 commits into from
Oct 13, 2016

Conversation

ferigis
Copy link
Member

@ferigis ferigis commented Oct 13, 2016

[close #284]

Copy link
Member

@elbrujohalcon elbrujohalcon left a 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:
Copy link
Member

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:
Copy link
Member

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:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

throw -> dispatched

Copy link
Member

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:
Copy link
Member

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:
Copy link
Member

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:
Copy link
Member

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(),
Copy link
Member

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

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oops you are right...

@elbrujohalcon elbrujohalcon merged commit f89fae6 into master Oct 13, 2016
@ferigis ferigis deleted the ferigis.284.link_events_with_preevents branch October 14, 2016 11:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Link events and pre_events
2 participants