Skip to content
This repository has been archived by the owner on Oct 19, 2021. It is now read-only.

Add kinto changes listener #13

Merged
merged 15 commits into from
Nov 12, 2018
Merged

Add kinto changes listener #13

merged 15 commits into from
Nov 12, 2018

Conversation

glasserc
Copy link
Contributor

@glasserc glasserc commented Nov 9, 2018

Fixes #12.

We're going to introduce a new listener for kinto-changes, and that
will probably be the more important one for our use case, but it's
still worth keeping the old one around in case it's of use to someone.
Copy link
Contributor

@leplatrem leplatrem left a comment

Choose a reason for hiding this comment

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

I'm surprised! I would have expected a simple exclude_match setting!

Since we called it «kinto changes», can't we assume kinto-changes would be installed? And maybe read the kinto.changes.resources setting? This way we could just have an exclude param, like we have kinto.history.exclude_resources

if resource_name == 'bucket':
resource_bucket = matchdict['id']
else:
resource_bucket = matchdict.get('bucket_id')
Copy link
Contributor

Choose a reason for hiding this comment

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

This key is probably always present no?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I guess so. In principle, we have other resources that don't belong in buckets, although kinto-changes doesn't watch them.

resource_collection = matchdict.get('collection_id')

if resource_bucket and resource_bucket != record_bucket:
continue
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't this go before line 56?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Why? In my mind, it was "Fetch bucket/collection from the resource, then check if the record matches".

@glasserc
Copy link
Contributor Author

Following up from a discussion I had with Mat. If you first come to this PR, you might expect a clean/elegant exclude_changes setting that filters events generically, something like Kinto/kinto#1499. But the tricky part here is that we don't necessarily want to filter all events from the monitor/changes collection. Instead, we want to look inside those events, understand them as kinto-changes events, figure out what collections they represent changes to, and exclude some of those. This makes everything a bit more complicated/encapsulation-violating. I tried to document why in the docstrings/README but maybe I could have been more clear; in which case don't hesitate to make suggestions.

Another thing that came up when discussing this is whether we really need to have two listeners. Megaphone is pretty limited in scope to Firefox and Mozilla, and the only use case we have for it right now is the monitor/changes collection, so why bother keeping the CollectionTimestampListener? I agree with this point -- having just one listener makes things easier to configure and deploy -- so I'll merge them together (although probably keep the KintoChangesListener name).

Copy link
Contributor

@leplatrem leplatrem left a comment

Choose a reason for hiding this comment

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

👍 thanks

@glasserc
Copy link
Contributor Author

Another point that came up during discussion is that this plugin doesn't really care what's in the kinto-changes configuration. We don't match the match_kinto_changes parameter to the kinto.changes.resources in any way. There's no value in consulting the kinto.changes.resources configuration because we have to check against the complete resource we were told in any case.

@glasserc glasserc merged commit 772b8d1 into Kinto:master Nov 12, 2018
@glasserc glasserc deleted the add-kinto_changes_listener branch November 12, 2018 16:17
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants