keypup-io / cloudtasker

Background jobs for Ruby using Google Cloud Tasks
MIT License
153 stars 38 forks source link

Cloudtasker enqueuing is broken in Rails 7.2.1 #125

Closed tostart-pickagreatname closed 2 months ago

tostart-pickagreatname commented 2 months ago

Rails 7.2.1 requires that queues implement the enqueue_after_transaction_commit? method.

The impact of not having this method and upgrading to 7.2.1 is that all job enqueuing fails.

This method is described in https://github.com/rails/rails/commit/e922c59207c406d51541622690737783e0ec338e

This commit also introduced ActiveJob::QueueAdapters::AbstractAdapter which all rails queues now inherit from.

In the future, the best path would be to have CloudtaskerAdapter inherit from AbstractAdapter, to avoid new methods breaking job enqueuing.

At this time, however, its default behaviour could simply be implemented.

tostart-pickagreatname commented 2 months ago

I attempted to open a PR for this but do not have permissions.

The change I am recommending is in two files: lib/active_job/queue_adapters/cloudtasker_adapter.rb would have

      # Determines if enqueuing will check and wait for an associated transaction completes before enqueuing
      #
      # @return [Boolean] True always as this is the default from QueueAdapters::AbstractAdapter
      def enqueue_after_transaction_commit?
        true
      end

and spec/active_job/queue_adapters/cloudtasker_adapter_spec.rb would have

    describe '#enqueue_after_transaction_commit?' do
      it 'returns true' do
        expect(adapter.enqueue_after_transaction_commit?).to be true
      end
    end