(To the question of how to include my comment in the answer ... we will use this opportunity to state it.)
I don’t know the details of what your plugin needs to do in order to “synchronize” with a third-party service, but I’m going to assume that the plugin basically extracts some temporary data that your network application then uses in some way.
Since the synchronization or fetch process occasionally fails, and your web application relies on modern data, you want the “synchronization” launch process to be performed manually. This is currently the only way to do this from the module itself, which means that you need to run some kind of code on all speakers that others have pointed out are currently not possible.
What I did in a previous similar scenario (fetching analytics from an external service) is simple:
- Submitting and customizing your Heroku app using Redis
- Write a rake command that simply executes the code (which is otherwise triggered by the plugin) to retrieve the data, and then writes that data to the cache
- If you usually load data into the application, first try to extract from the cache (and skip the cache, just run the same code again - it simply means that the data has expired from the cache before it is updated)
Then I went ahead and used the simple Heroku scheduler to execute the specified rake task every n minutes, to try to keep the data updated fresh and always in the cache (the cache expired a little less than n minutes) and reduce the number of instances when data is being sampled . I could set the cache to expire never or more than n, but this was not critical.
Thus, if I wanted to make sure that the latest analytics was displayed, all I had to do was either: a) connect to Redis and remove the item from the cache or (easier), b) just heroku run rake task .
Again, this works if you simply retrieve data that should be accessible to all speakers.
This obviously does not work the other way around. For example, if you have a centralized service that you want to send metrics from time to time (for example, the time spent on a request), based on each operation. I can’t come up with a simple and elegant way to do this with Heroku (except in real time with all the overhead that entails).
source share