Skip to content

Database backed checks #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
simon-isler opened this issue Mar 11, 2025 · 0 comments
Open

Database backed checks #2

simon-isler opened this issue Mar 11, 2025 · 0 comments

Comments

@simon-isler
Copy link

simon-isler commented Mar 11, 2025

hey @rameerez, nice gem! I especially like the DSL 🙌🏼

I saw that so far, the timestamps (e.g. last_run) are stored using a cache. This can be problematic for example when you run Sidekiq in a different process. Unless the app uses a shared cache between the processes, the last_run can't be updated within the worker.

the use case:

  1. I have a Rails app and a separate worker (different process) for Sidekiq.
  2. I then want to monitor the health of the process running in the worker

solutions I can come up with:
a) use a shared cache (solid_cache -> db-backed, redis_cache_store, ...)
b) patch the configuration layer to persist the timestamps with a db

a) is already possible. One can simply override the cache_store config.
b) requires a work around.

-> it would be nice if the persistence strategy is configurable. I imagine it as follows:
config.all_good.store = :db or config.all_good.store = :cache

with :cache it would use the existing cache_store class. with a :db setting, it could work as follows:

class HealthCheck < ApplicationRecord
  before_create :ensure_singularity

  validates :last_run, presence: true

  def self.instance
    first_or_create!(last_run: Time.current)
  end

  private

  def ensure_singularity
    raise StandardError, 'There can be only one instance' if HealthCheck.any?
  end
end

this would require an abstraction of the store

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant