diff --git a/Gemfile b/Gemfile index 692fac3..42f9853 100644 --- a/Gemfile +++ b/Gemfile @@ -47,6 +47,12 @@ gem 'email_validator' # pg_search builds ActiveRecord named scopes that take advantage of PostgreSQL’s full text search gem 'pg_search' +# A Ruby client library for Redis +gem 'redis' + +# Simple, efficient background processing for Ruby +gem 'sidekiq' + # scheduler for Ruby (at, in, cron and every jobs) gem 'rufus-scheduler' diff --git a/Gemfile.lock b/Gemfile.lock index a4b50aa..bac6941 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -299,6 +299,10 @@ GEM rbs (2.8.4) rdoc (6.10.0) psych (>= 4.0.0) + redis (5.3.0) + redis-client (>= 0.22.0) + redis-client (0.23.2) + connection_pool regexp_parser (2.10.0) reline (0.6.0) io-console (~> 0.5) @@ -351,6 +355,11 @@ GEM securerandom (0.4.1) shoulda-matchers (6.4.0) activesupport (>= 5.2.0) + sidekiq (7.3.7) + connection_pool (>= 2.3.0) + logger + rack (>= 2.2.4) + redis-client (>= 0.22.2) simplecov (0.22.0) docile (~> 1.1) simplecov-html (~> 0.11) @@ -444,6 +453,7 @@ DEPENDENCIES puma rack-cors rails + redis responders rspec-rails rspec_junit_formatter @@ -451,6 +461,7 @@ DEPENDENCIES rufus-scheduler sdoc shoulda-matchers + sidekiq simplecov solargraph spring diff --git a/config/initializers/redis.rb b/config/initializers/redis.rb new file mode 100644 index 0000000..48c1bb4 --- /dev/null +++ b/config/initializers/redis.rb @@ -0,0 +1,9 @@ +# Fetch environment variables with defaults if not set +redis_url = ENV.fetch('REDIS_URL', 'redis://localhost') +redis_port = ENV.fetch('REDISPORT', '6379') + +# Combine URL and port (adjust the path/DB as needed) +full_redis_url = "#{redis_url}/0" + +# Initialize Redis using the constructed URL +$redis = Redis.new(url: full_redis_url) diff --git a/config/initializers/sidekiq.rb b/config/initializers/sidekiq.rb new file mode 100644 index 0000000..48408f7 --- /dev/null +++ b/config/initializers/sidekiq.rb @@ -0,0 +1,14 @@ +# Fetch environment variables with defaults if not set +redis_url = ENV.fetch('REDIS_URL', 'redis://localhost') +redis_port = ENV.fetch('REDISPORT', '6379') + +# Combine URL and port (adjust the path/DB as needed) +full_redis_url = "#{redis_url}/0" + +Sidekiq.configure_server do |config| + config.redis = { url: full_redis_url } +end + +Sidekiq.configure_client do |config| + config.redis = { url: full_redis_url } +end