Giter Site home page Giter Site logo

Comments (6)

edgurgel avatar edgurgel commented on May 20, 2024

Yeah, I agree that Verk should be able to start without Redis and keep retrying to reconnect etc. Your solution seems to be the way to go 👍

from verk.

lpil avatar lpil commented on May 20, 2024

I'm unsure about this one. Given the init callback is about making guarantees about the readiness of the system should we consider Werk ready if it does not have a connected Redis instance? It seems like a fairly fundamental dependancy.

from verk.

keyan avatar keyan commented on May 20, 2024

@lpil I understand your point and perhaps we should just leave it at that.

It might help to explain where I hit this issue at first. I have a webserver which has added Verk to its supervision tree but only uses Verk to enqueue tasks to Redis in the Resque/Verk format. There is a separate processor application that is responsible for dequeueing and processing those tasks. While I understand why it makes sense for the processor to crash if it cannot cannot to Redis, I would rather the webserver be able to start and serve traffic while it continues to retry connecting.

Maybe the premise is flawed here? It might be non-standard usage of the library and thus it doesn't make sense to build around support for the use case. I am not sure.

from verk.

lpil avatar lpil commented on May 20, 2024

It seems that Verk doesn't require the application to be started in order to enqueue a job.

verk/lib/verk.ex

Lines 53 to 59 in d0f07c1

def enqueue(%Job{jid: jid, queue: queue} = job, redis) do
job = %Job{job | enqueued_at: Time.now |> DateTime.to_unix}
case Redix.command(redis, ["LPUSH", "queue:#{queue}", Poison.encode!(job)]) do
{:ok, _} -> {:ok, jid}
{:error, reason} -> {:error, reason}
end
end

You could just call that function and pass in the pid/atom of your own Redis instance. :)

from verk.

edgurgel avatar edgurgel commented on May 20, 2024

@keyan for your specific use case you could pass a connection to Verk.enqueue. So simply handling the connection on your side would do the job.

def enqueue(job, redis \ Verk.Redis)

Ok so Verk supports losing connectivity with Redis after it has started but it won't start without it.

I'm not sure if this "inconsistency" is bad or good...

from verk.

lpil avatar lpil commented on May 20, 2024

I've been doing some thinking and reading and I think that now I agree with you. Werk can reasonably guarantee that it is in a state where it could accept jobs, though not that it has somewhere to accept them from. :)

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.