Closed nishnik closed 7 years ago
@nishnik How about we add webhook in .env file and get it from there in place of hard coding it in LocalSettings.php
Hey @nishnik, thanks for the PR! Unfortunately this extension can't be used as-is, because the post to Slack's API happens synchronously on the request path, which can be quite slow (of the order of seconds), which drives up the page save latency. Also, if the post fails, the page save appears to fail (but actually succeeds, if I remember correctly) which isn't great.
The solution we used previously was to take the post to Slack out of the request path, by using a redis-backed job queue (example). I'd be happy to help you set that up, or discuss any other solution you can think of.
That makes sense.
Is there some way to check a table update in MySQL and create a trigger for this (I couldn't find any), though a way I can think of is to check the mysql database every minute (or 5 minutes) for an update (via a cron job) and post to slack (if there is an update). This way we are independent of the wiki making even one request for any notification.
Otherwise we can go with the redis thing.
We should keep our discussions on github only for future references.
MySQL does support triggers, although that might be too powerful/low-level for our use case. We'd need a separate service listening to the trigger and processing updates anyway.
Your point about the wiki making requests on the write path is correct, but Redis is designed to be very fast for exactly these kinds of use cases. I'd expect it to take <0.1ms to respond. Redis also has the advantage of being easy to reason about and use if we want to add more asynchronous side effects to wiki actions in the future.
If we go the way of implementing a job queue on redis, then the steps would look like:
What do you think? Also, agree with keeping discussions on Github.
I was trying to work on it. Got a redis container working: Initialy I was trying to install from scratch as in DigitalOcean guides, but then this worked:
FROM redis:alpine
COPY redis.conf /usr/local/etc/redis/redis.conf
I am stuck in the second part, could you give me some hint on how to do it. (Modifying the slack extension)
After which I think I would create one more container, install python in it and use the batman to post messages ?
Could you push your changes on your branch, so I can take a look?
Here's a dump of the code we were previously using, that will help you along. I think we were using the phpredis library, which is installable from pecl. Make sure to read it carefully and understand what it's doing – it could definitely use some cleanup.
I think we want to copy the source of this extension into our repo, and maintain it ourselves. This will save us from having to write the extension from scratch, which involves a lot of boilerplate.
Yes, the third container can be a "jobs" container, where we put any miscellaneous jobs.
@nishnik ping on this
Done in #22, thanks!
ping @amrav I am using https://www.mediawiki.org/wiki/Extension:SlackNotifications
Before deploying one has to enter the webhook only, shared in slack.