@@ -30,7 +30,8 @@ defmodule Oban.Plugins.Reindexer do
3030
3131 * `:schedule` — a cron expression that controls when to reindex. Defaults to `"@midnight"`.
3232
33- * `:timeout` - time in milliseconds to wait for each query call to finish. Defaults to 15 seconds.
33+ * `:timeout` - the time to wait for each query call to finish, as either an integer number of
34+ milliseconds, or an `Oban.Period` tuple like `{15, :seconds}`. Defaults to 15 seconds.
3435
3536 * `:timezone` — which timezone to use when evaluating the schedule. To use a timezone other than
3637 the default of "Etc/UTC" you *must* have a timezone database like [tz][tz] installed and
@@ -43,7 +44,7 @@ defmodule Oban.Plugins.Reindexer do
4344
4445 use GenServer
4546
46- alias Oban . { Cron , Peer , Plugin , Repo , Validation }
47+ alias Oban . { Cron , Peer , Period , Plugin , Repo , Validation }
4748 alias __MODULE__ , as: State
4849
4950 require Logger
@@ -52,8 +53,8 @@ defmodule Oban.Plugins.Reindexer do
5253 Plugin . option ( )
5354 | { :indexes , [ String . t ( ) ] }
5455 | { :schedule , String . t ( ) }
56+ | { :timeout , Period . t ( ) }
5557 | { :timezone , Calendar . time_zone ( ) }
56- | { :timeout , timeout ( ) }
5758
5859 defstruct [
5960 :conf ,
@@ -72,7 +73,11 @@ defmodule Oban.Plugins.Reindexer do
7273 def start_link ( opts ) do
7374 { name , opts } = Keyword . pop ( opts , :name )
7475
75- GenServer . start_link ( __MODULE__ , struct! ( State , opts ) , name: name )
76+ state = struct! ( State , opts )
77+
78+ GenServer . start_link ( __MODULE__ , % { state | timeout: Period . to_milliseconds ( state . timeout ) } ,
79+ name: name
80+ )
7681 end
7782
7883 @ impl Plugin
@@ -82,7 +87,7 @@ defmodule Oban.Plugins.Reindexer do
8287 name: :any ,
8388 indexes: { :list , :string } ,
8489 schedule: :schedule ,
85- timeout: : timeout,
90+ timeout: { :or , [ : timeout, :period ] } ,
8691 timezone: :timezone
8792 )
8893 end
0 commit comments