10000 Backend events · Issue #52 · preaction/Yancy · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Backend events #52

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

Closed
preaction opened this issue Jan 27, 2019 · 2 comments
Closed

Backend events #52

preaction opened this issue Jan 27, 2019 · 2 comments
8000

Comments

@preaction
Copy link
Owner
preaction commented Jan 27, 2019

Every backend should emit events in the following circumstances:

  • before_create - Before an item is created so that the event handler can edit it or prevent it (by throwing an exception)
  • after_create - After an item is created, given the success/fail of the create and the ID of the item (if successful)
  • before_set - Before an item is updated so that the event handler can edit it or prevent it (by throwing an exception)
  • after_set - After an item is updated, given the success/fail of the set and the ID of the item
  • before_delete - Before an item is deleted so the event handler can prevent it (by throwing an exception)
  • after_delete - After an item is deleted, given the success/fail of the delete and the ID of the item

Backends should inherit from Mojo::EventEmitter. Events can be added to the backend by using the standard Mojo::EventEmitter methods. These events should be documented in Yancy::Backend.

The documentation should explain that the events will only be handled by the worker that handles the request. So these events cannot be used, by themselves, to broadcast updates to other clients unless all the clients are connected to the same worker, or some kind of messaging system is used (like Mercury).

@preaction preaction mentioned this issue Jan 27, 2019
5 tasks
@preaction
Copy link
Owner Author

Instead of requiring all backends to support this which may only be used in limited circumstances, we should make this a role that users can apply to their backend object before configuring the Yancy plugin. This opens up new avenues of functionality, so I should also blog about it.

@preaction
Copy link
Owner Author

This feature is a good idea, but would be better implemented in Yancy::Model, which can be connected to any backend. But also, using Yancy::Model is itself a way to get these hooks to do whatever you want.

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

No branches or pull requests

1 participant
0