T1: the seat settle applies a delayed nak with the bus's own delay (ADR 0664 §1, issue 1748)
Claude-Session: https://claude.ai/code/session_01JG73KEq4zoDfM9WtYpcQgZ
This commit is contained in:
@@ -147,11 +147,27 @@ const (
|
||||
SettleNak = "nak" // handed back, to be delivered again at once
|
||||
SettleTerm = "term" // dropped
|
||||
SettleProgress = "progress" // still being worked: its acknowledgement wait starts again
|
||||
// SettleNakAfter hands the message back to be delivered again after a delay: the bus's own redelivery, so no part
|
||||
// keeps a timer for a step given again (novox/hq ADR 0664 §1; issue 1748). SeatSettleAfter gives it.
|
||||
SettleNakAfter = "nak-after"
|
||||
)
|
||||
|
||||
// SeatSettle gives the message module pulled under id its fate. A message pulled for another module, or settled
|
||||
// already, is refused.
|
||||
func (c *Conn) SeatSettle(module, id, fate string) error {
|
||||
return c.settle(module, id, fate, 0)
|
||||
}
|
||||
|
||||
// SeatSettleAfter hands the message module pulled under id back to be delivered again after delay (SettleNakAfter),
|
||||
// counting one more delivery. A delay of 0 or below is refused and settles nothing.
|
||||
func (c *Conn) SeatSettleAfter(module, id string, delay time.Duration) error {
|
||||
if delay <= 0 {
|
||||
return fmt.Errorf("a message given again after a delay needs a delay above 0, not %s", delay)
|
||||
}
|
||||
return c.settle(module, id, SettleNakAfter, delay)
|
||||
}
|
||||
|
||||
func (c *Conn) settle(module, id, fate string, delay time.Duration) error {
|
||||
seatPulls.mu.Lock()
|
||||
p, ok := seatPulls.held[id]
|
||||
if ok && p.module != module {
|
||||
@@ -173,9 +189,11 @@ func (c *Conn) SeatSettle(module, id, fate string) error {
|
||||
return p.msg.Term()
|
||||
case SettleProgress:
|
||||
return p.msg.InProgress()
|
||||
case SettleNakAfter:
|
||||
return p.msg.NakWithDelay(delay)
|
||||
}
|
||||
seatPulls.mu.Lock()
|
||||
seatPulls.held[id] = p // an unknown fate settles nothing
|
||||
seatPulls.mu.Unlock()
|
||||
return fmt.Errorf("a pulled message's fate is ack, nak, term or progress, not %q", fate)
|
||||
return fmt.Errorf("a pulled message's fate is ack, nak, nak-after, term or progress, not %q", fate)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user