Class: Kaal::Backend::NullAdapter

Inherits:
Adapter
  • Object
show all
Defined in:
lib/kaal/backend/adapter.rb

Overview

Null backend adapter that always succeeds (useful for development/testing).

This adapter provides a no-op implementation: it always returns true for acquire and does nothing on release. Use this when you want to run the scheduler without distributed coordination (e.g., single-node development).

Examples:

Using the null adapter

Kaal.configure do |config|
  config.backend = Kaal::Backend::NullAdapter.new
end

Instance Method Summary collapse

Methods inherited from Adapter

#definition_registry, #delayed_store

Instance Method Details

#acquire(_key, _ttl) ⇒ Boolean

Always returns true (lock always “acquired”).

Parameters:

  • _key (String)

    unused

  • _ttl (Integer)

    unused

Returns:

  • (Boolean)

    always true



121
122
123
# File 'lib/kaal/backend/adapter.rb', line 121

def acquire(_key, _ttl) # rubocop:disable Naming/PredicateMethod
  true
end

#release(_key) ⇒ Boolean

No-op implementation (nothing to release).

Parameters:

  • _key (String)

    unused

Returns:

  • (Boolean)

    always true



130
131
132
# File 'lib/kaal/backend/adapter.rb', line 130

def release(_key) # rubocop:disable Naming/PredicateMethod
  true
end

#with_lock(_key) { ... } ⇒ Object

Execute the block without any actual locking (always succeeds).

Parameters:

  • key (String)

    unused

  • ttl (Integer)

    unused

Yields:

  • executes the block immediately

Returns:

  • (Object)

    the result of the block



141
142
143
# File 'lib/kaal/backend/adapter.rb', line 141

def with_lock(_key, **)
  yield
end