Skip to content

Commit

Permalink
Address PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
nimf committed Nov 21, 2023
1 parent e508221 commit 4a218e9
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 54 deletions.
14 changes: 7 additions & 7 deletions grpcgcp/gcp_multiendpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,15 @@ type contextMEKey int

var meKey contextMEKey

// NewMEContext returns a new Context that carries Multiendpoint name meName.
func NewMEContext(ctx context.Context, meName string) context.Context {
return context.WithValue(ctx, meKey, meName)
// NewMEContext returns a new Context that carries Multiendpoint name.
func NewMEContext(ctx context.Context, name string) context.Context {
return context.WithValue(ctx, meKey, name)
}

// FromMEContext returns the MultiEndpoint name stored in ctx, if any.
func FromMEContext(ctx context.Context) (string, bool) {
meName, ok := ctx.Value(meKey).(string)
return meName, ok
name, ok := ctx.Value(meKey).(string)
return name, ok
}

// GCPMultiEndpoint holds the state of MultiEndpoints-enabled gRPC client connection.
Expand Down Expand Up @@ -224,7 +224,7 @@ func (sm *monitoredConn) monitor() {
currentState = sm.conn.GetState()
// Inform all multiendpoints.
for _, me := range sm.gme.mes {
me.SetEndpointAvailable(sm.endpoint, currentState == connectivity.Ready)
me.SetEndpointAvailability(sm.endpoint, currentState == connectivity.Ready)
}
}
}
Expand Down Expand Up @@ -320,7 +320,7 @@ func (gme *GCPMultiEndpoint) UpdateMultiEndpoints(meOpts *GCPMultiEndpointOption
for e, mc := range gme.pools {
s := mc.conn.GetState()
for _, me := range gme.mes {
me.SetEndpointAvailable(e, s == connectivity.Ready)
me.SetEndpointAvailability(e, s == connectivity.Ready)
}
}
return nil
Expand Down
12 changes: 6 additions & 6 deletions grpcgcp/multiendpoint/multiendpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@ type MultiEndpoint interface {
// getting an outdated current endpoint.
Current() string

// SetEndpointAvailable informs MultiEndpoint when an endpoint becomes available or unavailable.
// SetEndpointAvailability informs MultiEndpoint when an endpoint becomes available or unavailable.
// This may change the current endpoint.
SetEndpointAvailable(e string, avail bool)
SetEndpointAvailability(e string, avail bool)

// SetEndpoints updates a list of endpoints:
// - remove obsolete endpoints
Expand Down Expand Up @@ -244,16 +244,16 @@ func (me *multiEndpoint) switchFromTo(f, t *endpoint) {
})
}

// SetEndpointAvailable updates the state of an endpoint.
func (me *multiEndpoint) SetEndpointAvailable(e string, avail bool) {
// SetEndpointAvailability updates the state of an endpoint.
func (me *multiEndpoint) SetEndpointAvailability(e string, avail bool) {
me.Lock()
defer me.Unlock()
me.setEndpointAvailable(e, avail)
me.setEndpointAvailability(e, avail)
me.maybeUpdateCurrent()
}

// Must be run under me.Lock.
func (me *multiEndpoint) setEndpointAvailable(e string, avail bool) {
func (me *multiEndpoint) setEndpointAvailability(e string, avail bool) {
ee, ok := me.endpoints[e]
if !ok {
return
Expand Down
Loading

0 comments on commit 4a218e9

Please sign in to comment.