Skip to content

Commit

Permalink
Upgrade GrottoPress/mel shard to v0.22
Browse files Browse the repository at this point in the history
  • Loading branch information
akadusei committed Aug 6, 2024
1 parent df8071e commit 9a9d53f
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 19 deletions.
2 changes: 1 addition & 1 deletion config/defense.cr
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ end

private class Store < Defense::RedisStore
# Reusing the redis connection pool from *Mel*
def initialize(@redis = Mel.redis)
def initialize(@redis = Mel.settings.store.as(Mel::Redis).client)
end
end

Expand Down
2 changes: 1 addition & 1 deletion config/email.cr
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ BaseEmail.configure do |settings|
ENV["SMTP_PORT"].to_i
)

settings.deliver_later_strategy = Mel::Carbon::DeliverLaterStrategy.new
settings.deliver_later_strategy = Mel::Carbon::DeliverLater.new
else
settings.adapter = Carbon::DevAdapter.new
settings.deliver_later_strategy = DevDeliverLaterStrategy.new
Expand Down
10 changes: 5 additions & 5 deletions config/mel.cr
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
require "mel/worker"

Mel.configure do |settings|
settings.batch_size = ENV["JOBS_BATCH_SIZE"].to_i
settings.poll_interval = ENV["JOBS_POLL_INTERVAL"].to_i.seconds
settings.redis_url = ENV["REDIS_URL"]
# settings.redis_key_prefix = "penny"
settings.store = Mel::Redis.new(ENV["REDIS_URL"], :penny)
settings.timezone = App.settings.timezone
settings.worker_id = ENV["WORKER_ID"].to_i

Expand All @@ -28,7 +25,10 @@ if LuckyEnv.test?
settings.worker_id = 1
settings.batch_size = -1
settings.poll_interval = 1.millisecond
settings.redis_key_prefix = "penny:spec"
settings.store = Mel::Redis.new(
settings.store.as(Mel::Redis).client,
"penny:spec"
)
end
end

Expand Down
4 changes: 2 additions & 2 deletions shard.lock
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ shards:

mel:
git: https://github.com/grottopress/mel.git
version: 0.20.0
version: 0.22.0

pawn:
git: https://github.com/grottopress/pawn.git
Expand Down Expand Up @@ -154,7 +154,7 @@ shards:

splay_tree_map:
git: https://github.com/wyhaines/splay_tree_map.cr.git
version: 0.2.2
version: 0.3.0

unslash:
git: https://github.com/grottopress/unslash.git
Expand Down
5 changes: 4 additions & 1 deletion shard.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,10 @@ dependencies:
version: ~> 0.2.0
mel:
github: GrottoPress/mel
version: ~> 0.20.0
version: ~> 0.22.0
redis:
github: jgaskins/redis
version: ~> 0.8.0
shield:
github: GrottoPress/shield
version: ~> 1.0
Expand Down
2 changes: 1 addition & 1 deletion src/actions/api__private/health/show.cr
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@
# end

# private def verify_redis_connection
# Mel.redis.run({"PING"})
# Mel.settings.store.as(Mel::Redis).client.run({"PING"})
# end
# end
2 changes: 1 addition & 1 deletion src/actions/health/show.cr
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ class Health::Show < BrowserAction
end

private def verify_redis_connection
Mel.redis.run({"PING"})
Mel.settings.store.as(Mel::Redis).client.run({"PING"})
end
end
2 changes: 1 addition & 1 deletion src/app.cr
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ require "halo"
require "shield"
require "unslash"
require "i18n"
require "mel"
require "mel/redis"
require "defense"
require "fella"

Expand Down
12 changes: 6 additions & 6 deletions src/worker.cr
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
require "mel/worker"
require "mel"

require "./app"

Habitat.raise_if_missing_settings!

exit if LuckyEnv.development?

Mel.redis.multi do |redis|
Mel.transaction do |store|
DeleteBearerLoginsJob.run_every(
1.week,
redis: redis,
store: store,
id: "delete-bearer-logins-weekly"
)

DeleteEmailConfirmationsJob.run_every(
1.week,
redis: redis,
store: store,
id: "delete-email-confirmations-weekly"
)

DeleteLoginsJob.run_every(
1.week,
redis: redis,
store: store,
id: "delete-logins-weekly"
)

DeletePasswordResetsJob.run_every(
1.week,
redis: redis,
store: store,
id: "delete-password-resets-weekly"
)
end
Expand Down

0 comments on commit 9a9d53f

Please sign in to comment.