Why use Stream.each instead of Oban.insert_all in AshOban

In AshOban why we use Stream.each instead of using Oban.insert_all

file: lib/transformers/define_schedulers.ex

quote location: :keep do
          defp insert(stream) do
            count =
              stream
              |> Stream.each(&Oban.insert!/1)
              |> Enum.count()

            AshOban.debug(
              "Scheduled #{count} jobs for trigger #{unquote(inspect(resource))}.#{unquote(trigger.name)}",
              unquote(trigger.debug?)
            )

            :ok
          end
        end

We only use that if you don’t have Oban pro, because it’s only supported by Oban pro AFAIK.

1 Like

I tried to check using Oban.insert_all even if I am not using in pro version and it is working. But maybe I am wrong for this one. Will double check again.

1 Like

Interesting! It may have changed at some point, or perhaps I’m the one that is wrong :heart:

1 Like

Insert all was definitively a pro only feature before

Interesting, because we are not using pro version as of today but we are able to use the insert_all function.

Since 0.9.0 lol wat. Maybe me and zach are just a pair of hallucinating llms.

Isn’t there a thing were uniqueness of jobs is not guaranteed with insert_all in non pro?

So, yeah, the link shows the info box about uniquness and ash_oban uses uniquness that’s why we insert one by one

No, Oban.insert_all has always existed in both versions. However, unique only works for insert_all in Pro.

Ah, so that’s why we did that then :smiley: that is a performance improvement you can only get by upgrading to Pro in that case (which I highly suggest doing).

1 Like