Git Product home page Git Product logo

activejob-status's People

Contributors

ahorek avatar dennisvandehoef avatar fsateler avatar ghaydarov avatar inkstak avatar jeanne-b- avatar olleolleolle avatar vala avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

activejob-status's Issues

Can't update progress or total when the Status is initialized with a job id string

Commit 82c062b sets the progress and total on the job itself as well as setting it in the storage object.

The Status object can either be initialized with the job argument as an ActiveJob instance or with the id (string type) of an instance. This method fails if the Status is initialized with the id since strings do not have a progress attribute/setter.

For example:

job = MyJob.perform_later

status1 = ActiveJob::Status.get(job)
status1[:progress] = 1  # this succeeds because the @job instance variable refers to the job itself

status2 = ActiveJob::Status.get(job.job_id)
status2[:progress] = 1 # this fails because the @job instance variable refers to the id of the job (a string):
                       # NoMethodError Exception: undefined method `progress' for "XXXXXXXXXXXXXXXXXXXX":String

The expected outcome is that setting the progress or total values of a Status instance should work the same no matter how the status instance is initialized (ie. the old behaviour from before this commit).

Add separate expiry to completed jobs

Currently, it seems that we have expires_in which apply to all jobs no matter that are complete or not. If a job is complete, in most cases they maybe needed for shorted time than jobs that are in progress, scheduled, failed etc.

What do you think of an option like: completed_job_expires_in in config so that we can set it separately for completed jobs and remove them in a diff timeframe from the queue if completed.?

We could probably default it and make it optional.

Return progress with only one call to cache store

The Status.progress method performs two calls to Storage.read and so two calls to the cache store.

class Status

  def read
    @storage.read(@job)
  end

  def progress
    read[:progress].to_f / read[:total].to_f
  end 

it could be returned with one single call.

Search by Job name

I have a use case for a job to be searchable by the name of a job. Say MyAwesomeJob.

By that, I want to remove a job from the queue or act on it somehow.

One thought came to my mind is to restructure how we store that data in redis, maybe add it to the key or even make a nested structure to include job name too.

Other one is maybe search by the value and somehow scan for job name, not sure if it's possible with redis.

@inkstak any suggestion on this, how I can accomplish this?

Thanks

0.2.0 is broken on Ruby 3

hey, I want to report that the new version breaks Ruby 3.0 support

      ArgumentError: wrong number of arguments (given 0, expected 1)
           /usr/local/rvm/gems/ruby-3.0.0-railsexpress/gems/activejob-status-0.2.0/lib/activejob-status/status.rb:22:in `update'
           /usr/local/rvm/gems/ruby-3.0.0-railsexpress/gems/activejob-status-0.2.0/lib/activejob-status.rb:17:in `block (2 levels) in <module:Status>'

ActiveJob::Status::Status#update method definition has been changed

def update(message, **options)

but keyword arguments aren't automatically converted into a hash, so this call fails since Ruby 3.0
before_enqueue { |job| job.status.update(status: :queued) }

see https://www.ruby-lang.org/en/news/2019/12/12/separation-of-positional-and-keyword-arguments-in-ruby-3-0/

@inkstak ? could you take a look?

Using retry_on will skips rescue_from to set status as failed

The method retry_on from ActiveJob is using rescue_from.
If a job was enqueued from a retry and failed for the last time, It will be kept as working instead of failure.

I am using the ActiveJob adapter for Sneakers, but this looks that will happen with any adapter.

I will try to work on a solution but for now I am doing this inside my Job

  def perform(params)
# DOING 
    rescue Exception => e
      status.update(status: 'failed')
      raise e
    end

Allow to_json on ActiveStatus:Status:Status

I was trying to do this in a controller:

def status
  status = ActiveJob::Status.get(params[:job])
  render json: status.to_json
end

But it was not working, I've discovered I had to do status.read.to_json. I could also fix it by adding to_json to line 3 of status.rb. I think that should be added, or maybe add some documentation for ActiveStatus::Status::Status.read.

NoMethodError: undefined method `without' for {:expires_in=>1800, :throttle_interval=>0, :includes=>[:status]}:Hash

Hi there! After upgrading to version 0.4.1 I'm faced with the following error:

NoMethodError: undefined method `without' for {:expires_in=>1800, :throttle_interval=>0, :includes=>[:status]}:Hash
Did you mean?  with_options

@storage = ActiveJob::Status::Storage.new(options.without(:includes))

Shouldn't the correct method be except? I'm not found references to this method without for the Hash class.

Thanks.

Cant get the status and progress reporting to work

My code within my controller looks like this:

   include ActiveJob::Status

    job = MyJob.perform_later(response[:access_token])

    status = ActiveJob::Status.get(job.job_id)

    # Need to work out if the job has finished
    while !status.completed? do
      sleep(10)
      status = ActiveJob::Status.get(job.job_id)
      debug('status', status)
      debug('completed', status.completed?)
      debug('progress', status.progress)
    end

which gives:

** status = --- !ruby/object:ActiveJob::Status::Status
job: b6422d6f-7c98-400e-a709-9718443ce1da

** completed = false
** progress = NaN

The status never moves to completed even when the Job has run.

Within MyJob I am doing:

      progress.total = source_urls.count

and then within my loop

        progress.increment

        debug('progress', progress)

which gives:

progress = --- !ruby/object:ActiveJob::Status::Progress
job: &1 !ruby/object:GeniJob
  arguments:
  - 8VkXh0ifrm4U79Se5oUTIjPWw3tVdlbieIaRcHwr
  job_id: b6422d6f-7c98-400e-a709-9718443ce1da
  queue_name: default
  priority: 
  executions: 1
  exception_executions: {}
  timezone: Brisbane
  provider_job_id: 911bd9f17d730ae61213e8b6
  serialized_arguments: 
  locale: en
  enqueued_at: '2021-03-31T01:57:34Z'
  status: !ruby/object:ActiveJob::Status::Status
    job: *1
  progress: !ruby/object:ActiveJob::Status::Progress
    job: *1
    total: 32
    progress: 31
total: 32
progress: 31

So you can see that the progress is incrementing within the Job but not visible to the Controller.

What am I doing wrong?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.