stubborn_queue 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cd521876afe1fe93b9c321a2e327d6febafbffca
4
- data.tar.gz: 4ec69ba695ae13d3ae15ab0be2f97a20c46f1b3f
3
+ metadata.gz: 90d2f50ebe095942f263c570074d6d874accd2ab
4
+ data.tar.gz: ef596e963efd4eb7af78db84bad371be416cefe5
5
5
  SHA512:
6
- metadata.gz: 9711271fa224a1a5790fc96d902da9909585ec4a0feeaa46984582e43df7067dd88ebcd912cfd42160df91ae6522017b1795ed1f824699e6e05c8efad3a97e50
7
- data.tar.gz: ef3826b2a010680d2b0bcf4b9a164b8ef4d5f6e15505b0d585d0e426561316ea48ca64ebfddcf473cdbd3a60c1553902ec470c464f0bdcbb71661f6cbd226b13
6
+ metadata.gz: 7363f71ae7068065e8fb30f17fffeaf2249708dbfd20404e56b193624637f1cb22f3ddb2288c0881961ba259598a04af2908c4a8c9f35352d98b968f8a1e7792
7
+ data.tar.gz: d26598c7182860bd7550a27c21d25c3b5b4c0929ad7025463e4e0e4f0af3905569b3710b7e75adbcafe4c3aca4816ad190968839cf17acaa5b192c64426ca644
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- stubborn_queue (0.1.0)
4
+ stubborn_queue (1.0.0)
5
5
  bundler
6
6
  daybreak
7
7
  moneta
data/README.md CHANGED
@@ -1,3 +1,24 @@
1
+ # stubborn_queue
2
+
3
+ Sometimes you want to make sure that stuff on your queue gets done. This stubborn queue will insist that something isn't done until you tell it otherwise. Unfinished items get requeued after a specified amount of time because you didn't do it right. I store the data in file to avoid dependencies outside of Ruby itself.
4
+
5
+ ## Usage
6
+
7
+ ```ruby
8
+ important_data = StubbornQueue.new name: 'important_data', timeout: 60
9
+ length = important_data.enqueue 'top secret!'
10
+ id = important_data.dequeue
11
+ data = important_data.lookup id
12
+ do_something_with data
13
+ important_data.finish id
14
+ ```
15
+
16
+ If `do_something_with` takes longer than 60 seconds, it'll assume that you crashed out and requeue it for another worker.
17
+
18
+ ## Heads up!
19
+
1
20
  This is in no way inherently thread- or process-safe. It's built for one process owning one queue file and not interacting with it asynchronously.
2
21
 
3
- Huge props to [Chris Olstrom](https://github.com/colstrom) who helped me understand the idea and was a good sport when I implemented my own version instead of waiting for him to finish his.
22
+ ## Special thanks
23
+
24
+ Huge props to [Chris Olstrom](https://github.com/colstrom) who helped me understand the idea and was a good sport when I made my own implementation which will probably be extremely similar to his.
@@ -7,7 +7,8 @@ class StubbornQueue
7
7
  def initialize(options = {})
8
8
  @name = options.fetch :name, 'default'
9
9
  @timeout = options.fetch :timeout, 60
10
- @db = Moneta.new :Daybreak, expires: true, file: ".#{@name}.db"
10
+ path = options.fetch :file, ".#{@name}.db"
11
+ @db = Moneta.new :Daybreak, expires: true, file: path
11
12
  end
12
13
 
13
14
  def key_for(type, with_id: 0)
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |gem|
2
2
  gem.name = 'stubborn_queue'
3
- gem.version = '1.0.0'
3
+ gem.version = '1.1.0'
4
4
  gem.licenses = 'MIT'
5
5
  gem.authors = ['Justin Scott']
6
6
  gem.email = 'jvscott@gmail.com'
@@ -5,7 +5,8 @@ require 'stubborn_queue'
5
5
  context 'queueing' do
6
6
  setup do
7
7
  @timeout = 1
8
- @queue = StubbornQueue.new name: 'test', timeout: @timeout
8
+ @path = '/tmp/.testing'
9
+ @queue = StubbornQueue.new name: 'test', timeout: @timeout, file: @path
9
10
  @queue.db.clear
10
11
  @item = 'test_item'
11
12
  end
@@ -30,4 +31,8 @@ context 'queueing' do
30
31
  sleep (@timeout+1)
31
32
  assert_equal 1, @queue.enqueue(@item)
32
33
  end
34
+
35
+ should 'place the DB file at the specified path' do
36
+ assert_equal true, File.exists?(@path)
37
+ end
33
38
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stubborn_queue
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Justin Scott
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-08 00:00:00.000000000 Z
11
+ date: 2015-05-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler