Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
asmyasnikov committed Jul 18, 2024
1 parent a70a04e commit 6499dfa
Show file tree
Hide file tree
Showing 6 changed files with 562 additions and 648 deletions.
8 changes: 4 additions & 4 deletions internal/balancer/balancer.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ type Balancer struct {
discoveryRepeater repeater.Repeater
localDCDetector func(ctx context.Context, endpoints []endpoint.Endpoint) (string, error)

connectionsState atomic.Pointer[connectionsState]
connectionsState atomic.Pointer[state]

mu xsync.RWMutex
onApplyDiscoveredEndpoints []func(ctx context.Context, endpoints []endpoint.Info)
Expand Down Expand Up @@ -152,7 +152,7 @@ func (b *Balancer) applyDiscoveredEndpoints(ctx context.Context, newest []endpoi
}

info := balancerConfig.Info{SelfLocation: localDC}
state := newConnectionsState(connections, b.config.Filter, info, b.config.AllowFallback)
state := newState(connections, b.config.Filter, info, b.config.AllowFallback)

Check failure on line 155 in internal/balancer/balancer.go

View workflow job for this annotation

GitHub Actions / unit (1.20.x, macOS)

cannot use connections (variable of type []conn.Conn) as []endpoint.Endpoint value in argument to newState

Check failure on line 155 in internal/balancer/balancer.go

View workflow job for this annotation

GitHub Actions / unit (1.20.x, macOS)

cannot use connections (variable of type []conn.Conn) as []endpoint.Endpoint value in argument to newState

Check failure on line 155 in internal/balancer/balancer.go

View workflow job for this annotation

GitHub Actions / unit (1.21.x, macOS)

cannot use connections (variable of type []conn.Conn) as []endpoint.Endpoint value in argument to newState

Check failure on line 155 in internal/balancer/balancer.go

View workflow job for this annotation

GitHub Actions / unit (1.21.x, macOS)

cannot use connections (variable of type []conn.Conn) as []endpoint.Endpoint value in argument to newState

Check failure on line 155 in internal/balancer/balancer.go

View workflow job for this annotation

GitHub Actions / experiment (1.22.x, 24.1)

cannot use connections (variable of type []conn.Conn) as []endpoint.Endpoint value in argument to newState

Check failure on line 155 in internal/balancer/balancer.go

View workflow job for this annotation

GitHub Actions / integration (1.21.x, 23.3)

cannot use connections (variable of type []conn.Conn) as []endpoint.Endpoint value in argument to newState

Check failure on line 155 in internal/balancer/balancer.go

View workflow job for this annotation

GitHub Actions / integration (1.21.x, 24.1)

cannot use connections (variable of type []conn.Conn) as []endpoint.Endpoint value in argument to newState

Check failure on line 155 in internal/balancer/balancer.go

View workflow job for this annotation

GitHub Actions / integration (1.22.x, 24.1)

cannot use connections (variable of type []conn.Conn) as []endpoint.Endpoint value in argument to newState

Check failure on line 155 in internal/balancer/balancer.go

View workflow job for this annotation

GitHub Actions / integration (1.22.x, 23.3)

cannot use connections (variable of type []conn.Conn) as []endpoint.Endpoint value in argument to newState

Check failure on line 155 in internal/balancer/balancer.go

View workflow job for this annotation

GitHub Actions / unit (1.22.x, macOS)

cannot use connections (variable of type []conn.Conn) as []endpoint.Endpoint value in argument to newState

Check failure on line 155 in internal/balancer/balancer.go

View workflow job for this annotation

GitHub Actions / unit (1.22.x, macOS)

cannot use connections (variable of type []conn.Conn) as []endpoint.Endpoint value in argument to newState

Check failure on line 155 in internal/balancer/balancer.go

View workflow job for this annotation

GitHub Actions / integration (1.20.x, 23.3)

cannot use connections (variable of type []conn.Conn) as []endpoint.Endpoint value in argument to newState

Check failure on line 155 in internal/balancer/balancer.go

View workflow job for this annotation

GitHub Actions / integration (1.20.x, 24.1)

cannot use connections (variable of type []conn.Conn) as []endpoint.Endpoint value in argument to newState

Check failure on line 155 in internal/balancer/balancer.go

View workflow job for this annotation

GitHub Actions / unit (1.20.x, windows)

cannot use connections (variable of type []conn.Conn) as []endpoint.Endpoint value in argument to newState

Check failure on line 155 in internal/balancer/balancer.go

View workflow job for this annotation

GitHub Actions / unit (1.20.x, windows)

cannot use connections (variable of type []conn.Conn) as []endpoint.Endpoint value in argument to newState

Check failure on line 155 in internal/balancer/balancer.go

View workflow job for this annotation

GitHub Actions / unit (1.22.x, windows)

cannot use connections (variable of type []conn.Conn) as []endpoint.Endpoint value in argument to newState

Check failure on line 155 in internal/balancer/balancer.go

View workflow job for this annotation

GitHub Actions / unit (1.22.x, windows)

cannot use connections (variable of type []conn.Conn) as []endpoint.Endpoint value in argument to newState

Check failure on line 155 in internal/balancer/balancer.go

View workflow job for this annotation

GitHub Actions / unit (1.20.x, ubuntu)

cannot use connections (variable of type []conn.Conn) as []endpoint.Endpoint value in argument to newState

Check failure on line 155 in internal/balancer/balancer.go

View workflow job for this annotation

GitHub Actions / unit (1.20.x, ubuntu)

cannot use connections (variable of type []conn.Conn) as []endpoint.Endpoint value in argument to newState

Check failure on line 155 in internal/balancer/balancer.go

View workflow job for this annotation

GitHub Actions / unit (1.21.x, ubuntu)

cannot use connections (variable of type []conn.Conn) as []endpoint.Endpoint value in argument to newState

Check failure on line 155 in internal/balancer/balancer.go

View workflow job for this annotation

GitHub Actions / unit (1.21.x, ubuntu)

cannot use connections (variable of type []conn.Conn) as []endpoint.Endpoint value in argument to newState

Check failure on line 155 in internal/balancer/balancer.go

View workflow job for this annotation

GitHub Actions / unit (1.22.x, ubuntu)

cannot use connections (variable of type []conn.Conn) as []endpoint.Endpoint value in argument to newState

Check failure on line 155 in internal/balancer/balancer.go

View workflow job for this annotation

GitHub Actions / unit (1.22.x, ubuntu)

cannot use connections (variable of type []conn.Conn) as []endpoint.Endpoint value in argument to newState

Check failure on line 155 in internal/balancer/balancer.go

View workflow job for this annotation

GitHub Actions / unit (1.21.x, windows)

cannot use connections (variable of type []conn.Conn) as []endpoint.Endpoint value in argument to newState

Check failure on line 155 in internal/balancer/balancer.go

View workflow job for this annotation

GitHub Actions / unit (1.21.x, windows)

cannot use connections (variable of type []conn.Conn) as []endpoint.Endpoint value in argument to newState

endpointsInfo := make([]endpoint.Info, len(newest))
for i, e := range newest {
Expand Down Expand Up @@ -319,7 +319,7 @@ func (b *Balancer) wrapCall(ctx context.Context, f func(ctx context.Context, cc
return nil
}

func (b *Balancer) connections() *connectionsState {
func (b *Balancer) connections() *state {
return b.connectionsState.Load()
}

Expand Down Expand Up @@ -351,7 +351,7 @@ func (b *Balancer) getConn(ctx context.Context) (c conn.Conn, err error) {
}
}()

c, failedCount = state.GetConnection(ctx)
c, failedCount = state.Next(ctx)

Check failure on line 354 in internal/balancer/balancer.go

View workflow job for this annotation

GitHub Actions / unit (1.20.x, macOS)

cannot use state.Next(ctx) (value of type endpoint.Endpoint) as conn.Conn value in assignment: endpoint.Endpoint does not implement conn.Conn (missing method Endpoint)

Check failure on line 354 in internal/balancer/balancer.go

View workflow job for this annotation

GitHub Actions / unit (1.20.x, macOS)

cannot use state.Next(ctx) (value of type endpoint.Endpoint) as conn.Conn value in assignment: endpoint.Endpoint does not implement conn.Conn (missing method Endpoint)

Check failure on line 354 in internal/balancer/balancer.go

View workflow job for this annotation

GitHub Actions / unit (1.21.x, macOS)

cannot use state.Next(ctx) (value of type endpoint.Endpoint) as conn.Conn value in assignment: endpoint.Endpoint does not implement conn.Conn (missing method Endpoint)

Check failure on line 354 in internal/balancer/balancer.go

View workflow job for this annotation

GitHub Actions / unit (1.21.x, macOS)

cannot use state.Next(ctx) (value of type endpoint.Endpoint) as conn.Conn value in assignment: endpoint.Endpoint does not implement conn.Conn (missing method Endpoint)

Check failure on line 354 in internal/balancer/balancer.go

View workflow job for this annotation

GitHub Actions / experiment (1.22.x, 24.1)

cannot use state.Next(ctx) (value of type endpoint.Endpoint) as conn.Conn value in assignment: endpoint.Endpoint does not implement conn.Conn (missing method Endpoint)

Check failure on line 354 in internal/balancer/balancer.go

View workflow job for this annotation

GitHub Actions / integration (1.21.x, 23.3)

cannot use state.Next(ctx) (value of type endpoint.Endpoint) as conn.Conn value in assignment: endpoint.Endpoint does not implement conn.Conn (missing method Endpoint)

Check failure on line 354 in internal/balancer/balancer.go

View workflow job for this annotation

GitHub Actions / integration (1.21.x, 24.1)

cannot use state.Next(ctx) (value of type endpoint.Endpoint) as conn.Conn value in assignment: endpoint.Endpoint does not implement conn.Conn (missing method Endpoint)

Check failure on line 354 in internal/balancer/balancer.go

View workflow job for this annotation

GitHub Actions / integration (1.22.x, 24.1)

cannot use state.Next(ctx) (value of type endpoint.Endpoint) as conn.Conn value in assignment: endpoint.Endpoint does not implement conn.Conn (missing method Endpoint)

Check failure on line 354 in internal/balancer/balancer.go

View workflow job for this annotation

GitHub Actions / integration (1.22.x, 23.3)

cannot use state.Next(ctx) (value of type endpoint.Endpoint) as conn.Conn value in assignment: endpoint.Endpoint does not implement conn.Conn (missing method Endpoint)

Check failure on line 354 in internal/balancer/balancer.go

View workflow job for this annotation

GitHub Actions / unit (1.22.x, macOS)

cannot use state.Next(ctx) (value of type endpoint.Endpoint) as conn.Conn value in assignment: endpoint.Endpoint does not implement conn.Conn (missing method Endpoint)

Check failure on line 354 in internal/balancer/balancer.go

View workflow job for this annotation

GitHub Actions / unit (1.22.x, macOS)

cannot use state.Next(ctx) (value of type endpoint.Endpoint) as conn.Conn value in assignment: endpoint.Endpoint does not implement conn.Conn (missing method Endpoint)

Check failure on line 354 in internal/balancer/balancer.go

View workflow job for this annotation

GitHub Actions / integration (1.20.x, 23.3)

cannot use state.Next(ctx) (value of type endpoint.Endpoint) as conn.Conn value in assignment: endpoint.Endpoint does not implement conn.Conn (missing method Endpoint)

Check failure on line 354 in internal/balancer/balancer.go

View workflow job for this annotation

GitHub Actions / integration (1.20.x, 24.1)

cannot use state.Next(ctx) (value of type endpoint.Endpoint) as conn.Conn value in assignment: endpoint.Endpoint does not implement conn.Conn (missing method Endpoint)

Check failure on line 354 in internal/balancer/balancer.go

View workflow job for this annotation

GitHub Actions / unit (1.20.x, windows)

cannot use state.Next(ctx) (value of type endpoint.Endpoint) as conn.Conn value in assignment: endpoint.Endpoint does not implement conn.Conn (missing method Endpoint)

Check failure on line 354 in internal/balancer/balancer.go

View workflow job for this annotation

GitHub Actions / unit (1.20.x, windows)

cannot use state.Next(ctx) (value of type endpoint.Endpoint) as conn.Conn value in assignment: endpoint.Endpoint does not implement conn.Conn (missing method Endpoint)

Check failure on line 354 in internal/balancer/balancer.go

View workflow job for this annotation

GitHub Actions / unit (1.22.x, windows)

cannot use state.Next(ctx) (value of type endpoint.Endpoint) as conn.Conn value in assignment: endpoint.Endpoint does not implement conn.Conn (missing method Endpoint)

Check failure on line 354 in internal/balancer/balancer.go

View workflow job for this annotation

GitHub Actions / unit (1.22.x, windows)

cannot use state.Next(ctx) (value of type endpoint.Endpoint) as conn.Conn value in assignment: endpoint.Endpoint does not implement conn.Conn (missing method Endpoint)

Check failure on line 354 in internal/balancer/balancer.go

View workflow job for this annotation

GitHub Actions / unit (1.20.x, ubuntu)

cannot use state.Next(ctx) (value of type endpoint.Endpoint) as conn.Conn value in assignment: endpoint.Endpoint does not implement conn.Conn (missing method Endpoint)

Check failure on line 354 in internal/balancer/balancer.go

View workflow job for this annotation

GitHub Actions / unit (1.20.x, ubuntu)

cannot use state.Next(ctx) (value of type endpoint.Endpoint) as conn.Conn value in assignment: endpoint.Endpoint does not implement conn.Conn (missing method Endpoint)

Check failure on line 354 in internal/balancer/balancer.go

View workflow job for this annotation

GitHub Actions / unit (1.21.x, ubuntu)

cannot use state.Next(ctx) (value of type endpoint.Endpoint) as conn.Conn value in assignment: endpoint.Endpoint does not implement conn.Conn (missing method Endpoint)

Check failure on line 354 in internal/balancer/balancer.go

View workflow job for this annotation

GitHub Actions / unit (1.21.x, ubuntu)

cannot use state.Next(ctx) (value of type endpoint.Endpoint) as conn.Conn value in assignment: endpoint.Endpoint does not implement conn.Conn (missing method Endpoint)

Check failure on line 354 in internal/balancer/balancer.go

View workflow job for this annotation

GitHub Actions / unit (1.22.x, ubuntu)

cannot use state.Next(ctx) (value of type endpoint.Endpoint) as conn.Conn value in assignment: endpoint.Endpoint does not implement conn.Conn (missing method Endpoint)

Check failure on line 354 in internal/balancer/balancer.go

View workflow job for this annotation

GitHub Actions / unit (1.22.x, ubuntu)

cannot use state.Next(ctx) (value of type endpoint.Endpoint) as conn.Conn value in assignment: endpoint.Endpoint does not implement conn.Conn (missing method Endpoint)

Check failure on line 354 in internal/balancer/balancer.go

View workflow job for this annotation

GitHub Actions / unit (1.21.x, windows)

cannot use state.Next(ctx) (value of type endpoint.Endpoint) as conn.Conn value in assignment: endpoint.Endpoint does not implement conn.Conn (missing method Endpoint)

Check failure on line 354 in internal/balancer/balancer.go

View workflow job for this annotation

GitHub Actions / unit (1.21.x, windows)

cannot use state.Next(ctx) (value of type endpoint.Endpoint) as conn.Conn value in assignment: endpoint.Endpoint does not implement conn.Conn (missing method Endpoint)
if c == nil {
return nil, xerrors.WithStackTrace(
fmt.Errorf("%w: cannot get connection from Balancer after %d attempts", ErrNoEndpoints, failedCount),
Expand Down
179 changes: 0 additions & 179 deletions internal/balancer/connections_state.go

This file was deleted.

Loading

0 comments on commit 6499dfa

Please sign in to comment.