Skip to content

Commit

Permalink
Upgrade GrottoPress/pond shard to v2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
akadusei committed Apr 16, 2024
1 parent b4a7b2f commit 5af470a
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 8 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [Unreleased] -

### Changed
- Upgrade `GrottoPress/pond` shard to v2.0

## [0.19.0] - 2024-02-21

### Changed
Expand Down
2 changes: 1 addition & 1 deletion shard.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ dependencies:
version: ~> 0.4.0
pond:
github: GrottoPress/pond
version: ~> 1.0
version: ~> 2.0
redis:
github: jgaskins/redis
version: ~> 0.8.0
Expand Down
2 changes: 1 addition & 1 deletion src/spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ module Mel
end

def sync(task : Task?)
task.try &.run.try { |fiber| Pond.drain(fiber) }
Pond.drain { |pond| task.try &.run(pond) }
end
end
6 changes: 2 additions & 4 deletions src/worker.cr
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,7 @@ module Mel
end

private def run_pending_tasks(pond)
Task.find_pending(-1).try do |tasks|
tasks.each &.run(force: true).try { |fiber| pond << fiber }
end
Task.find_pending(-1).try &.each &.run(pond, force: true)
end

private def run_tasks(pond)
Expand All @@ -71,7 +69,7 @@ module Mel

while state.started?
Task.find_lte(Time.local, batch_size(pond), delete: nil).try do |tasks|
tasks.each &.run(force: true).try { |fiber| pond << fiber }
tasks.each &.run(pond, force: true)
end

sleep jittered_poll_interval
Expand Down
4 changes: 2 additions & 2 deletions src/worker/task.cr
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
require "./task/**"

abstract class Mel::Task
def run(*, force = false) : Fiber?
def run(pond : Pond, *, force = false) : Fiber?
return log_not_due unless force || due?
do_before_run

self.attempts += 1
set_run_time

spawn(name: id) do
pond.fill(name: id) do
log_running
job.run
rescue error
Expand Down

0 comments on commit 5af470a

Please sign in to comment.