Skip to content

Commit 4940827

Browse files
committed
refactor for readibility x2
1 parent 26923a2 commit 4940827

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

hitless/errors.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ var (
1818

1919
// Configuration validation errors
2020
ErrInvalidHandoffRetries = errors.New("hitless: MaxHandoffRetries must be between 1 and 10")
21-
ErrInvalidHandoffState = errors.New("hitless: Conn is in invalid state for handoff")
2221
)
2322

2423
// Integration errors
@@ -35,3 +34,12 @@ var (
3534
var (
3635
ErrInvalidNotification = errors.New("hitless: invalid notification format")
3736
)
37+
38+
// connection handoff errors
39+
var (
40+
// ErrConnectionMarkedForHandoff is returned when a connection is marked for handoff
41+
// and should not be used until the handoff is complete
42+
ErrConnectionMarkedForHandoff = errors.New("hitless: connection marked for handoff")
43+
// ErrConnectionInvalidHandoffState is returned when a connection is in an invalid state for handoff
44+
ErrConnectionInvalidHandoffState = errors.New("hitless: connection is in invalid state for handoff")
45+
)

hitless/pool_hook.go

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ func (ph *PoolHook) performConnectionHandoffWithPool(ctx context.Context, conn *
355355

356356
newEndpoint := conn.GetHandoffEndpoint()
357357
if newEndpoint == "" {
358-
return false, ErrInvalidHandoffState
358+
return false, ErrConnectionInvalidHandoffState
359359
}
360360

361361
retries := conn.IncrementAndGetHandoffRetries(1)
@@ -445,8 +445,7 @@ func (ph *PoolHook) createEndpointDialer(endpoint string) func(context.Context)
445445
func (ph *PoolHook) Shutdown(ctx context.Context) error {
446446
ph.shutdownOnce.Do(func() {
447447
close(ph.shutdown)
448-
449-
// No timers to clean up with on-demand workers
448+
// workers will exit when they finish their current request
450449
})
451450

452451
// Wait for workers to complete
@@ -463,7 +462,3 @@ func (ph *PoolHook) Shutdown(ctx context.Context) error {
463462
return ctx.Err()
464463
}
465464
}
466-
467-
// ErrConnectionMarkedForHandoff is returned when a connection is marked for handoff
468-
// and should not be used until the handoff is complete
469-
var ErrConnectionMarkedForHandoff = errors.New("connection marked for handoff")

0 commit comments

Comments
 (0)