summaryrefslogtreecommitdiff
path: root/lib/tapicero_daemon.rb
diff options
context:
space:
mode:
authorAzul <azul@riseup.net>2013-09-12 09:57:45 +0200
committerAzul <azul@riseup.net>2013-09-12 09:57:45 +0200
commit37f87300c9804bdad66d730b676715e242b9ca42 (patch)
tree7fa746846c2a127812d28d58cc5f0abd04cf180d /lib/tapicero_daemon.rb
parent929fcdea37f92f6b175482c6e0d1b8ff3229854f (diff)
use CouchRest::Database#changes, store and retrieve seq
This commit bundles a few different changes: * we now use the CouchRest::Database#changes stream instead of our own * we store and read the last sequence number so on a restart we can start where we left * we now have a UserDatabase class rather than the CouchDatabaseCreator. It also knows about it's name and we create an instance of it per database we want to create. It's also more flexible when the databases already exist.
Diffstat (limited to 'lib/tapicero_daemon.rb')
-rw-r--r--lib/tapicero_daemon.rb13
1 files changed, 8 insertions, 5 deletions
diff --git a/lib/tapicero_daemon.rb b/lib/tapicero_daemon.rb
index 52e60e3..a5e41eb 100644
--- a/lib/tapicero_daemon.rb
+++ b/lib/tapicero_daemon.rb
@@ -10,12 +10,15 @@ require 'tapicero'
module Tapicero
puts " * Observing #{Config.couch_host_without_password}"
puts " * Tracking #{Config.users_db_name}"
- stream = CouchStream.new(Config.couch_host + '/' + Config.users_db_name)
- users = CouchChanges.new(stream)
- creator = CouchDatabaseCreator.new(Config.couch_host)
+ # stream = CouchStream.new(Config.couch_host + '/' + Config.users_db_name)
+ db = CouchRest.new(Config.couch_host).database(Config.users_db_name)
+ users = CouchChanges.new(db, Config.seq_file)
+
users.created do |hash|
- puts "Created user " + hash[:id]
- creator.create(Config.db_prefix + hash[:id], Config.security)
+ puts "Created user " + hash['id']
+ db = UserDatabase.new(Config.couch_host, Config.db_prefix + hash['id'])
+ db.create
+ db.secure(Config.security)
end
users.listen