Class: Tupelo::PersistentArchiver
- Includes:
- Funl::HistoryClient
- Defined in:
- lib/tupelo/tuplets/persistent-archiver.rb,
lib/tupelo/tuplets/persistent-archiver.rb,
lib/tupelo/tuplets/persistent-archiver/worker.rb
Defined Under Namespace
Classes: ForkRequest, Worker
Constant Summary collapse
- ZERO_TOLERANCE =
How many tuples with count=0 do we permit before cleaning up?
1000
Constants inherited from Client
Client::TUPELO_META_KEY, Client::TUPELO_SUBSPACE_TAG
Instance Attribute Summary collapse
-
#server ⇒ Object
readonly
Returns the value of attribute server.
-
#server_thread ⇒ Object
readonly
Returns the value of attribute server_thread.
Attributes inherited from Client
Instance Method Summary collapse
- #handle_conn(conn) ⇒ Object
-
#initialize(server, **opts) ⇒ PersistentArchiver
constructor
A new instance of PersistentArchiver.
- #make_worker ⇒ Object
- #run ⇒ Object
- #start ⇒ Object
- #stop ⇒ Object
Methods inherited from Client
#inspect, #log, #make_queue, #make_scheduler, #or, #trace_loop, #tracing?
Methods included from Client::Api
#abort, #define_subspace, #notifier, #pulse_nowait, #pulse_wait, #read_all, #read_nowait, #read_wait, #subspace, #take, #take_nowait, #trans_class, #transaction, #use_subspaces!, #write_nowait, #write_wait
Constructor Details
#initialize(server, **opts) ⇒ PersistentArchiver
Returns a new instance of PersistentArchiver.
19 20 21 22 |
# File 'lib/tupelo/tuplets/persistent-archiver.rb', line 19 def initialize server, **opts super arc: nil, tuplespace: Tupelo::PersistentArchiver::Tuplespace, **opts @server = server end |
Instance Attribute Details
#server ⇒ Object (readonly)
Returns the value of attribute server.
13 14 15 |
# File 'lib/tupelo/tuplets/persistent-archiver.rb', line 13 def server @server end |
#server_thread ⇒ Object (readonly)
Returns the value of attribute server_thread.
14 15 16 |
# File 'lib/tupelo/tuplets/persistent-archiver.rb', line 14 def server_thread @server_thread end |
Instance Method Details
#handle_conn(conn) ⇒ Object
76 77 78 79 80 81 82 83 84 |
# File 'lib/tupelo/tuplets/persistent-archiver.rb', line 76 def handle_conn conn log.debug {"accepted #{conn.inspect}"} begin worker << ForkRequest.new(conn) rescue => ex log.error ex raise end end |
#make_worker ⇒ Object
45 46 47 |
# File 'lib/tupelo/tuplets/persistent-archiver.rb', line 45 def make_worker Tupelo::PersistentArchiver::Worker.new self end |
#run ⇒ Object
62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/tupelo/tuplets/persistent-archiver.rb', line 62 def run loop do ## nonblock_accept? Thread.new(server.accept) do |conn| handle_conn conn end ## periodically send worker request to dump space to file? end rescue => ex log.error ex raise end |
#start ⇒ Object
49 50 51 52 53 54 55 |
# File 'lib/tupelo/tuplets/persistent-archiver.rb', line 49 def start ## load from file? super # start worker thread @server_thread = Thread.new do run end end |
#stop ⇒ Object
57 58 59 60 |
# File 'lib/tupelo/tuplets/persistent-archiver.rb', line 57 def stop server_thread.kill if server_thread super # stop worker thread end |