Webhook / Integration Event bus (#499)

* First bash at an event bus for webhooks and integrations

* Refactoring

* poc

* Revert too wide ranging changes
Move to two-queues
This commit is contained in:
Tom Moor
2018-01-13 10:46:29 -08:00
committed by GitHub
parent 33261ba7c7
commit 9d441fc51a
11 changed files with 121 additions and 15 deletions

View File

@ -1,11 +1,12 @@
// @flow
import _ from 'lodash';
import slug from 'slug';
import randomstring from 'randomstring';
import { DataTypes, sequelize } from '../sequelize';
import { asyncLock } from '../redis';
import events from '../events';
import Document from './Document';
import Event from './Event';
import _ from 'lodash';
// $FlowIssue invalid flow-typed
slug.defaults.mode = 'rfc3986';
@ -93,6 +94,20 @@ Collection.associate = models => {
});
};
// Hooks
Collection.addHook('afterCreate', model =>
events.add({ name: 'collections.create', model })
);
Collection.addHook('afterDestroy', model =>
events.add({ name: 'collections.delete', model })
);
Collection.addHook('afterUpdate', model =>
events.add({ name: 'collections.update', model })
);
// Instance methods
Collection.prototype.getUrl = function() {