dmitriid
Oban.insert waits for the job to complete instead of returning immediately
{:oban, "~> 2.15"}
I’m experiencing a weird behaviour with Oban.insert. When I call it, it waits until the enqueued job finishes, and only then returns with %Oban.Job{state="completed"}. My understanding is that it should just enqueue the job, and return immediately.
The queue config:
config :my_app, Oban,
repo: Quire.Repo,
plugins: [{Oban.Plugins.Pruner, max_age: 300}, {Oban.Plugins.Reindexer, schedule: "@weekly"}],
queues: [
default: 10,
image_resize: 10,
]
The worker:
defmodule MyApp.ImageResize do
use Oban.Worker, queue: :image_resize
@impl Oban.Worker
def perform(%Oban.Job{args: %{"media_id" => media_id}}) do
# logic to resize images, including retrieveing data from the db, writing data to db etc.
end
end
Getting this into Oban:
%{media_id: "x"} |> MyApp.ImageResize.new() |> Oban.insert()
This last line waits until the entirety of the job completes before returning. I believe this isn’t right?
Moreover:
%{media_id: "x"} |> MyApp.ImageResize.new(schedule_in: 5) |> Oban.insert()
Still starts the job immediately, and waits for it to finish.
Edit:
> Application.get_env(:my_app, Oban)
[
repo: MyApp.Repo,
plugins: [
{Oban.Plugins.Pruner, [max_age: 300]},
{Oban.Plugins.Reindexer, [schedule: "@weekly"]}
],
queues: [default: 10, image_resize: 10],
testing: :inline
]
Marked As Solved
benwilson512
Author of Craft GraphQL APIs in Elixir with Absinthe
That testing inline option is why this is happening. Are you setting that in config.exs and not test.exs?
2
Also Liked
dmitriid
Argh.
I did indeed have that as separate line in config.exs, and didnt’ notice it
And now it works as expected
1
Popular in Questions
I will often find my self writing things similar to:
case some_value do
nil -> something()
"" -> something()
_ -> somethi...
New
Hi,
I have to write a raw query for one of my project. But till now I have used ecto queries and don’t have much experience writing raw ...
New
Hello everyone,
I try to use an Javascript Event Handler in my root.html.leex file.
Therefore I created a function in the app.js file: ...
New
I have a phoenix application from which a user can download multiple(5-6) files of size 1MB. I couldn’t find anything related to sending ...
New
Hi,
is there any work on GUI with Elixir, that is similar to Electron/Javascript? My idea is to bundle Phoenix and BEAM into a single se...
New
Hey all,
I discovered Elixir and I love it. I always wanted to learn a functional programming and I intended to go for Haskell, but afte...
New
How to handle excepions in elixir?
Suppose i have A, B, C ,D, E modules. and each module has get() function.
A.get() method will call t...
New
Hi everyone,
I was playing with phoenix liveView but I run into an issue. I have a form and want to validate each input text when the te...
New
I have a server on AWS, and was running a load test using artillery. When looking at the Phoenix dashboard I see the Ports going to 100% ...
New
Hi, I’m just starting to build a side-project with Elixir and Phoenix and doing some basic test with Elixir alone.
What strikes me is th...
New
Other popular topics
lets say i have a sample like
a = 20; b = 10;
if (a > b) do
{:ok, "a"}
end
if (a < b) do
{:ok, b}
end
if (a == b) do
{:ok, "equa...
New
We have an ECS cluster with 4 services, where each task joins a single cluster, via discovery ECS discovery service.
Currently when I de...
New
Hello everyone,
I try to use an Javascript Event Handler in my root.html.leex file.
Therefore I created a function in the app.js file: ...
New
Hi guys, i’m new in the Elixir world, and i have to say, that i love it!
i’m having some problem to understand anonymous functions with ...
New
After calling mix ecto.create I get this error:
17:00:32.162 [error] GenServer #PID<0.412.0> terminating
** (Postgrex.Error) FATAL...
New
Hey all,
I discovered Elixir and I love it. I always wanted to learn a functional programming and I intended to go for Haskell, but afte...
New
Hey,
Just curious what are the main benefits of Elixir compared to Clojure?
When is Elixir more useful than Clojure and vice versa?
Th...
New
Hi there,
I am working with Ecto-Postgresql and I need to call all of the records from a specific table but the table has 40,000 records...
New
We’ve put together this wiki for Phoenix LiveView - please feel free to add any info you feel is worth including.
What is Phoenix LiveV...
New
I have a server on AWS, and was running a load test using artillery. When looking at the Phoenix dashboard I see the Ports going to 100% ...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #advent-of-code
- #elixirconf-us
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #performance









