Skip to content

Commit

Permalink
client: remove deprecated WithServiceConfig DialOption (#6800)
Browse files Browse the repository at this point in the history
  • Loading branch information
dfawley authored Nov 15, 2023
1 parent 42fdcc4 commit 232054a
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 527 deletions.
35 changes: 0 additions & 35 deletions clientconn.go
Original file line number Diff line number Diff line change
Expand Up @@ -255,22 +255,6 @@ func DialContext(ctx context.Context, target string, opts ...DialOption) (conn *
cc.dopts.bs = backoff.DefaultExponential
}

if cc.dopts.scChan != nil {
// Blocking wait for the initial service config.
select {
case sc, ok := <-cc.dopts.scChan:
if ok {
cc.sc = &sc
cc.safeConfigSelector.UpdateConfigSelector(&defaultConfigSelector{&sc})
}
case <-ctx.Done():
return nil, ctx.Err()
}
}
if cc.dopts.scChan != nil {
go cc.scWatcher()
}

// This creates the name resolver, load balancer, blocking picker etc.
if err := cc.exitIdleMode(); err != nil {
return nil, err
Expand Down Expand Up @@ -746,25 +730,6 @@ func (cc *ClientConn) Connect() {
cc.balancerWrapper.exitIdleMode()
}

func (cc *ClientConn) scWatcher() {
for {
select {
case sc, ok := <-cc.dopts.scChan:
if !ok {
return
}
cc.mu.Lock()
// TODO: load balance policy runtime change is ignored.
// We may revisit this decision in the future.
cc.sc = &sc
cc.safeConfigSelector.UpdateConfigSelector(&defaultConfigSelector{&sc})
cc.mu.Unlock()
case <-cc.ctx.Done():
return
}
}
}

// waitForResolvedAddrs blocks until the resolver has provided addresses or the
// context expires. Returns nil unless the context expires first; otherwise
// returns a status error based on the context.
Expand Down
14 changes: 0 additions & 14 deletions dialoptions.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ type dialOptions struct {
block bool
returnLastError bool
timeout time.Duration
scChan <-chan ServiceConfig
authority string
binaryLogger binarylog.Logger
copts transport.ConnectOptions
Expand Down Expand Up @@ -251,19 +250,6 @@ func WithDecompressor(dc Decompressor) DialOption {
})
}

// WithServiceConfig returns a DialOption which has a channel to read the
// service configuration.
//
// Deprecated: service config should be received through name resolver or via
// WithDefaultServiceConfig, as specified at
// https://github.com/grpc/grpc/blob/master/doc/service_config.md. Will be
// removed in a future 1.x release.
func WithServiceConfig(c <-chan ServiceConfig) DialOption {
return newFuncDialOption(func(o *dialOptions) {
o.scChan = c
})
}

// WithConnectParams configures the ClientConn to use the provided ConnectParams
// for creating and maintaining connections to servers.
//
Expand Down
15 changes: 0 additions & 15 deletions test/end2end_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,6 @@ type test struct {
clientNopCompression bool
unaryClientInt grpc.UnaryClientInterceptor
streamClientInt grpc.StreamClientInterceptor
sc <-chan grpc.ServiceConfig
clientInitialWindowSize int32
clientInitialConnWindowSize int32
perRPCCreds credentials.PerRPCCredentials
Expand Down Expand Up @@ -760,10 +759,6 @@ func (d *nopDecompressor) Type() string {
func (te *test) configDial(opts ...grpc.DialOption) ([]grpc.DialOption, string) {
opts = append(opts, grpc.WithDialer(te.e.dialer), grpc.WithUserAgent(te.userAgent))

if te.sc != nil {
opts = append(opts, grpc.WithServiceConfig(te.sc))
}

if te.clientCompression {
opts = append(opts,
grpc.WithCompressor(grpc.NewGZIPCompressor()),
Expand Down Expand Up @@ -1103,20 +1098,10 @@ func testServiceConfigSetup(t *testing.T, e env) *test {
return te
}

func newBool(b bool) (a *bool) {
return &b
}

func newInt(b int) (a *int) {
return &b
}

func newDuration(b time.Duration) (a *time.Duration) {
a = new(time.Duration)
*a = b
return
}

func (s) TestGetMethodConfig(t *testing.T) {
te := testServiceConfigSetup(t, tcpClearRREnv)
defer te.tearDown()
Expand Down
Loading

0 comments on commit 232054a

Please sign in to comment.