File tree Expand file tree Collapse file tree 2 files changed +20
-0
lines changed
Expand file tree Collapse file tree 2 files changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -62,12 +62,20 @@ def initialize
6262 @housekeeping_interval = 3
6363 @housekeeping_heartbeat_interval = 5
6464 @housekeeping_claim_ttl_seconds = 120
65+ @subscribers = [ ]
66+ end
67+
68+ def subscribe ( callable = nil , &block )
69+ callable ||= block
70+ @subscribers << callable
71+ self
6572 end
6673
6774 def setup!
6875 return if @setup
6976
7077 @backend . setup! ( self ) if @backend . respond_to? ( :setup! )
78+ @subscribers . each { |s | s . call ( self ) }
7179 @setup = true
7280 end
7381
Original file line number Diff line number Diff line change 6767 expect ( config . executor ) . to be_a ( Sourced ::AsyncExecutor )
6868 end
6969
70+ describe 'subscribers' do
71+ it 'triggers subscribers on #setup!' do
72+ executor_class = nil
73+ config . subscribe do |c |
74+ executor_class = c . executor . class
75+ end
76+ config . executor = :thread
77+ config . setup!
78+ expect ( executor_class ) . to eq ( Sourced ::ThreadExecutor )
79+ end
80+ end
81+
7082 describe '#executor=()' do
7183 specify ':async' do
7284 config . executor = :async
You can’t perform that action at this time.
0 commit comments