H1 integration bound: the runner follows a membership without dropping a call
On every membership of a module, HandleCalled stopped each subscription of a tool and subscribed again on the same subjects; a call the bus routed in that window was dropped by the client in silence, and its caller waited the runner's whole bound (30 s). On the build node this was the 30 s of TestAReplacedBundlesOldToolStaysGoneOnTheNextMembership and of TestTheLedgerRepairsAreToolsOfEveryLedgerOwner, and most of the integration level's 72 s. Now a membership keeps every subscription whose subject and queue it still names, subscribes the new ones, and only then stops those it no longer names (make before break). The test asks the served tool once after each of five memberships, with the tests' own call bound of 2 s (principle 11); it fails without the change. The runtime tests' call helper and the ledger listing wait that bound, not the runner's 30 s. Builds: design 47 H §774, H-A-158; principle 11
This commit is contained in:
@@ -740,25 +740,35 @@ func (c *Conn) HandleCalled(key string, h CalledHandler) (func(), error) {
|
||||
"those of the modules it follows", c.self, key)
|
||||
}
|
||||
var mu sync.Mutex
|
||||
var stops []func()
|
||||
stops := map[Served]func(){}
|
||||
stopped := false
|
||||
// **Make before break** (novox/hq design 47 H, H-A-158): a membership issued again keeps every subscription
|
||||
// whose subject and queue it still names, subscribes those it newly names, and only then stops those it no
|
||||
// longer names — a call the bus routes while the membership is followed is never dropped in silence.
|
||||
serve := func() {
|
||||
mu.Lock()
|
||||
defer mu.Unlock()
|
||||
if stopped {
|
||||
return
|
||||
}
|
||||
for _, s := range stops {
|
||||
s()
|
||||
}
|
||||
stops = nil
|
||||
named := map[Served]bool{}
|
||||
for _, s := range c.servedOn(module, tool) {
|
||||
named[s] = true
|
||||
if _, kept := stops[s]; kept {
|
||||
continue
|
||||
}
|
||||
if stop, err := c.answerBoth(s.Subject, s.Queue, h); err == nil {
|
||||
stops = append(stops, stop)
|
||||
stops[s] = stop
|
||||
} else {
|
||||
c.Logf("[mesh-tools] cannot serve %s on %s: %v", key, s.Subject, err)
|
||||
}
|
||||
}
|
||||
for s, stop := range stops {
|
||||
if !named[s] {
|
||||
stop()
|
||||
delete(stops, s)
|
||||
}
|
||||
}
|
||||
}
|
||||
serve()
|
||||
// Its stop drops the membership handler too: a handler left behind would bind the stopped tool again
|
||||
@@ -773,10 +783,10 @@ func (c *Conn) HandleCalled(key string, h CalledHandler) (func(), error) {
|
||||
mu.Lock()
|
||||
defer mu.Unlock()
|
||||
stopped = true
|
||||
for _, s := range stops {
|
||||
s()
|
||||
for s, stop := range stops {
|
||||
stop()
|
||||
delete(stops, s)
|
||||
}
|
||||
stops = nil
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user