daybreak 0.2.3 → 0.2.4

Sign up to get free protection for your applications and to get access to all the features.
data/.travis.yml CHANGED
@@ -7,6 +7,7 @@ rvm:
7
7
  - jruby-19mode
8
8
  - rbx-18mode
9
9
  - rbx-19mode
10
+ - ree
10
11
  env:
11
12
  matrix:
12
13
  - "TASK=test"
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2012 ProPublica
1
+ Copyright (c) 2012 - 2013 ProPublica
2
2
 
3
3
  MIT License
4
4
 
data/README CHANGED
@@ -5,8 +5,8 @@
5
5
 
6
6
  Daybreak is a simple key value store for ruby. It has user defined persistence,
7
7
  and all data is stored in a table in memory so ruby niceties are available.
8
- Daybreak is faster than any other ruby options like pstore and dbm.
8
+ Daybreak is faster than any other ruby options like pstore or dbm.
9
9
 
10
10
  $ gem install daybreak
11
11
 
12
- You find a detailed documentation at http://propublica.github.com/daybreak.
12
+ You can find detailed documentation at http://propublica.github.com/daybreak.
data/lib/daybreak/db.rb CHANGED
@@ -257,7 +257,7 @@ module Daybreak
257
257
  # @private
258
258
  def self.exit_handler
259
259
  loop do
260
- db = @@databases_mutex.synchronize { @@databases.first }
260
+ db = @@databases_mutex.synchronize { @@databases.shift }
261
261
  break unless db
262
262
  warn "Daybreak database #{db.file} was not closed, state might be inconsistent"
263
263
  begin
@@ -138,26 +138,29 @@ module Daybreak
138
138
 
139
139
  # Worker thread
140
140
  def worker
141
- loop do
142
- case record = first
143
- when Hash
144
- # Write batch update
145
- write(dump(record))
146
- @size += record.size
147
- when nil
141
+ while (record = first)
142
+ tries = 0
143
+ begin
144
+ if Hash === record
145
+ # Write batch update
146
+ write(dump(record))
147
+ @size += record.size
148
+ else
149
+ # Write single record
150
+ record[1] = @serializer.dump(record.last) if record.size > 1
151
+ write(@format.dump(record))
152
+ @size += 1
153
+ end
154
+ rescue Exception => ex
155
+ tries += 1
156
+ warn "Daybreak worker, try #{tries}: #{ex.message}"
157
+ tries <= 3 ? retry : raise
158
+ ensure
148
159
  pop
149
- break
150
- else
151
- # Write single record
152
- record[1] = @serializer.dump(record.last) if record.size > 1
153
- write(@format.dump(record))
154
- @size += 1
155
160
  end
156
- pop
157
161
  end
158
162
  rescue Exception => ex
159
- warn "Daybreak worker: #{ex.message}"
160
- retry
163
+ warn "Daybreak worker terminated: #{ex.message}"
161
164
  end
162
165
 
163
166
  # Write data to output stream and advance @pos
@@ -1,5 +1,5 @@
1
1
  module Daybreak
2
2
  # Version string updated using SemVer
3
3
  # @api public
4
- VERSION = '0.2.3'
4
+ VERSION = '0.2.4'
5
5
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: daybreak
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.2.3
5
+ version: 0.2.4
6
6
  platform: ruby
7
7
  authors:
8
8
  - Jeff Larson
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2013-01-21 00:00:00.000000000 Z
13
+ date: 2013-02-02 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  version_requirements: !ruby/object:Gem::Requirement