Class: Sidekiq::Tasks::Storage::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/sidekiq/tasks/storage/base.rb

Direct Known Subclasses

Redis

Constant Summary collapse

ERROR_MESSAGE_MAX_LENGTH =
255

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(task_name, history_limit: nil) ⇒ Base

Returns a new instance of Base.



9
10
11
12
# File 'lib/sidekiq/tasks/storage/base.rb', line 9

def initialize(task_name, history_limit: nil)
  @task_name = task_name
  @history_limit = history_limit
end

Instance Attribute Details

#history_limitObject (readonly)

Returns the value of attribute history_limit.



7
8
9
# File 'lib/sidekiq/tasks/storage/base.rb', line 7

def history_limit
  @history_limit
end

#task_nameObject (readonly)

Returns the value of attribute task_name.



7
8
9
# File 'lib/sidekiq/tasks/storage/base.rb', line 7

def task_name
  @task_name
end

Instance Method Details

#historyArray<Hash>

This method is abstract.

Subclasses must implement this method.

Returns the execution history for the task.

Returns:

  • (Array<Hash>)

    The execution history entries.

Raises:



28
29
30
# File 'lib/sidekiq/tasks/storage/base.rb', line 28

def history
  raise NotImplementedError, "Storage must implement #history"
end

#last_enqueue_atTime, NilClass

This method is abstract.

Subclasses must implement this method.

Returns the last enqueue time for the task.

Returns:

  • (Time, NilClass)

    The last enqueue time or nil.

Raises:



19
20
21
# File 'lib/sidekiq/tasks/storage/base.rb', line 19

def last_enqueue_at
  raise NotImplementedError, "Storage must implement #last_enqueue_at"
end

#store_enqueue(_jid, _args, user: nil) ⇒ Object

This method is abstract.

Subclasses must implement this method.

Stores enqueue information for the task.

Parameters:

  • jid (String)

    The Sidekiq job ID.

  • args (Hash)

    The arguments passed to the task.

  • user (Hash, NilClass) (defaults to: nil)

    The user who enqueued the task.

Raises:



39
40
41
# File 'lib/sidekiq/tasks/storage/base.rb', line 39

def store_enqueue(_jid, _args, user: nil)
  raise NotImplementedError, "Storage must implement #store_enqueue"
end

#store_execution(_jid, _time_key) ⇒ Object

This method is abstract.

Subclasses must implement this method.

Stores execution time for a specific history entry.

Parameters:

  • jid (String)

    The Sidekiq job ID.

  • time_key (String)

    The time key to store (e.g. "executed_at", "finished_at").

Raises:



49
50
51
# File 'lib/sidekiq/tasks/storage/base.rb', line 49

def store_execution(_jid, _time_key)
  raise NotImplementedError, "Storage must implement #store_execution"
end

#store_execution_error(_jid, _error) ⇒ Object

This method is abstract.

Subclasses must implement this method.

Stores an execution error for a specific history entry.

Parameters:

  • jid (String)

    The Sidekiq job ID.

  • error (Exception)

    The error that occurred during execution.

Raises:



59
60
61
# File 'lib/sidekiq/tasks/storage/base.rb', line 59

def store_execution_error(_jid, _error)
  raise NotImplementedError, "Storage must implement #store_execution_error"
end