Code Monkey home page Code Monkey logo

Comments (7)

krasio avatar krasio commented on May 27, 2024 2

Maybe you can enqueue the second job from inside the first job, once all work is done?
Something like

defmodule Worker1 do
  def perform(arg1, arg2) do
    # do some work
    Verk.enqueue(%Verk.Job{queue: :default, class: "Worker2", args: [some, args], max_retry_count: 5})
  end
end

from verk.

mbaeuerle avatar mbaeuerle commented on May 27, 2024 1

Thanks for your suggestions.
In our case the jobs are triggered by events which should be handled in the order they arrive. So unfortunately it is not possible to enqueue the next job when the first one has finished.
So maybe verk is not quite the right tool for this use case and it's better to use some kind of event queue / event bus.

from verk.

edgurgel avatar edgurgel commented on May 27, 2024

@krasio's suggestion would be the ideal. If jobs are linked one job can start another job once it's done.

And even if there was such feature, if the first job from the queue fails and goes to the retry set, should the second job be started? In this case it's better to start jobs only if their dependencies were achieved as @krasio suggested.

from verk.

mbaeuerle avatar mbaeuerle commented on May 27, 2024

Do you think there is much work to do to use verk as a basis to achieve the sorted job behavior?

from verk.

keyan avatar keyan commented on May 27, 2024

It isn't entirely clear to me how you would want Verk to behave in that case, but it sounds like it would be quite complicated to achieve given the current implementation. Right now Verk job processing control is entirely based on FIFO queue logic.

Imagine the following situation:

  • Job A is enqueued
  • Job A is dequeued but fails during processing, it is added to the retry queue
  • Job B is enqueued (we want this to run only after A)
  • Job C is enqueued (this is independent of jobs A/B and should run FIFO)

How can we know which jobs need to run when? Or that job C doesn't need to wait on other jobs? Or which job B is waiting on? When job A fails does it prevent all further jobs from executing indefinitely?

from verk.

edgurgel avatar edgurgel commented on May 27, 2024

Yeah as @keyan said it's not just a sorted behaviour but a sort of dependency between jobs or something like this.

from verk.

mbaeuerle avatar mbaeuerle commented on May 27, 2024

Yeah you are both right, it's not quite easy. The approach we will give a try which works without modification of verk itself is to

  • limit the queue to one worker
  • Now the processing order is guaranteed unless there is a failure and retries
  • To failure we implement the retry logic in the worker itself and only when the event was dispatched the worker finishes the job and processes the next one

from verk.

Related Issues (20)

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.