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:
- I have a Rails app and a separate worker (different process) for Sidekiq.
- 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
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, thelast_runcan't be updated within the worker.the use case:
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_storeconfig.b) requires a work around.
-> it would be nice if the persistence strategy is configurable. I imagine it as follows:
config.all_good.store = :dborconfig.all_good.store = :cachewith
:cacheit would use the existingcache_storeclass. with a:dbsetting, it could work as follows:this would require an abstraction of the store