Changing sidekiq job urgency

If you’ve ever used Topic List Previews, you may have noticed there’s a delay before the Topic List image preview includes the preview image.

The topic list image seems to be dependent on the sidekiq job PullHotlinkedImages which is why these plugin/themes won’t work without sidekiq running.

Recently I’ve been trying to persuade a Facebook group to move over to Discourse and whilst there are many (many!) reasons you’d do so, one of the features I like about Facebook is the almost instant image Preview you get when posting a link.

So i’m trying to increase the frequency of the PullHotlinkedImages so that TLP generates the Topic image asap so you don’t have to wait the usual 1 to 5 minutes for it to happen.

However, despite attempting to override the jobs code in my plugin.rb like so, the job still runs in the ‘low’ queue.

Any ideas?

after_initialize do

  Jobs.module_eval do

    class PullHotlinkedImages < Jobs::Base
      sidekiq_options queue: 'critical'

      def initialize

No errors in the logs, no issue starting up discourse (No errors in the console).

Am I making a newb error?

Is there a better way to override the job urgency?

PS And yes, I know I’m messing with a carefully balanced system here, but I’d still like to experiment with how far I can stress the server.

The PullHotlinkedImages isn’t about “almost instant image preview” but about “downloading images that are hosted elsewhere so that they don’t disappear”.

1 Like

Ah, so is topic.image_url available sooner? Have I misunderstood how/when that is available?

The topic.image_url is set in CookedPostProcessor which is called in the ProcessPost job which is immediately triggered in PostCreator.

So if you have at least one image in your post, it should immediately (give or take a few seconds) show up at topic.image_url.

4 Likes

Thanks I’ll take another look at the delay I was experiencing. Perhaps I totally misread it. Cheers!

Turns out this is a “bug” in TLP (which overrides and adds some methods to CookedPostProcessor) and I believe I’ve found the culprit. Fix TBD.

Thanks @zogstrip for encouraging me to pursue that direction.

3 Likes