Skip to content

Unable to process jobs outside of ActiveJob #57

@robinvdvleuten

Description

@robinvdvleuten

We're using Faktory in a setup where Rails handles the API and a couple of backend processes are written in Go. These backend processes are receiving their work through a Faktory instance.

In Rails we are pushing new jobs by utilizing (or misusing?) the ActiveJob classes. This allows us to have custom Faktory configuration per job (like queue name etc). But the Faktory adapter for ActiveJob wraps the name of the job before sending it to Faktory (ActiveJob::QueueAdapters::FaktoryAdapter::JobWrapper) so in Go we cannot register the correct handler for it. So currently we have a middleware "unwrapping" the name of the job;

class Faktory::Middleware::Unwrap
  class Client
    def call(payload, _pool)
      wrapped_job_klass = payload.dig('custom', 'wrapped')
      if wrapped_job_klass
        payload['jobtype'] = wrapped_job_klass
        payload['custom'] = payload['custom'].except('wrapped')
      end
      yield
    end
  end
end

I can imagine that more developers will run into this and it does not feel right with Faktory's strength to be a polyglot job processing framework. Thus it would be great to be able to configure the "wrapping" on Faktory itself instead of depending on custom middleware.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions