support milestone and thrash rotation signals
This commit is contained in:
@@ -161,8 +161,14 @@ func (c *Coordinator) rotate(ctx context.Context, hard float64) {
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
reason := "threshold"
|
||||
if signal, ok := a.(herdr.RotationSignal); ok {
|
||||
if r, signalErr := signal.RotationSignal(ctx, session); signalErr == nil && r != "" {
|
||||
reason = r
|
||||
}
|
||||
}
|
||||
occupancy, err := a.Occupancy(session)
|
||||
if err != nil || occupancy < hard {
|
||||
if err != nil || (occupancy < hard && reason == "threshold") {
|
||||
continue
|
||||
}
|
||||
if boundary, ok := a.(herdr.TurnBoundary); ok {
|
||||
@@ -178,7 +184,7 @@ func (c *Coordinator) rotate(ctx context.Context, hard float64) {
|
||||
if ref == "" {
|
||||
continue
|
||||
}
|
||||
b, _ := json.Marshal(map[string]string{"handoff_ref": ref, "reason": "threshold"})
|
||||
b, _ := json.Marshal(map[string]string{"handoff_ref": ref, "reason": reason})
|
||||
e := domain.Event{ID: domain.NewID(), Type: "TaskReleased", TaskID: taskID, Version: task.Version + 1, Payload: b}
|
||||
if c.Store.Append(e) == nil {
|
||||
c.mu.Lock()
|
||||
|
||||
Reference in New Issue
Block a user