Sha256: 23b478f0eb6aadb0f565fc9bc8d2e75078b15704200b0c50241863f850fea66d

Contents?: true

Size: 1 KB

Versions: 8

Compression:

Stored size: 1 KB

Contents

module Gorynich
  module Head
    module ActiveJob
      extend ::ActiveSupport::Concern

      included do
        attr_reader :current_uri, :current_tenant

        def serialize
          super.merge(uri: Gorynich::Current.uri, tenant: Gorynich::Current.tenant)
        end

        def deserialize(job_data)
          super
          @current_uri = job_data.fetch(:uri)
          @current_tenant = job_data.fetch(:tenant)
        end

        def retry_job(**_options)
          Gorynich.with(current_tenant, uri: current_uri) do |_current|
            super
          end
        end

        around_perform do |job, block|
          Gorynich.with(
            job.current_tenant || Gorynich::Current.tenant,
            uri: job.current_uri || Gorynich::Current.uri
          ) do |_current|
            block.call
          end
        end

        around_enqueue do |_job, block|
          Gorynich.with_database(Gorynich.instance.default) do
            block.call
          end
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
gorynich-1.3.4.273062 lib/gorynich/head/active_job.rb
gorynich-1.3.3.231946 lib/gorynich/head/active_job.rb
gorynich-1.3.2.231715 lib/gorynich/head/active_job.rb
gorynich-1.3.1.213701 lib/gorynich/head/active_job.rb
gorynich-1.3.0.213297 lib/gorynich/head/active_job.rb
gorynich-1.2.3.198656 lib/gorynich/head/active_job.rb
gorynich-1.2.2.198643 lib/gorynich/head/active_job.rb
gorynich-1.2.1.184916 lib/gorynich/head/active_job.rb