Repository: grpc/grpc-go
File: internal/xds/bootstrap/bootstrap.go (Go)

Code before:
// not invoke the watchers' OnResourceDoesNotExist() method when a resource is
// deleted, nor will it remove the existing resource value from its cache.
func (sc *ServerConfig) ServerFeaturesIgnoreResourceDeletion() bool {
	for _, sf := range sc.serverFeatures {
		if sf == serverFeaturesIgnoreResourceDeletion {
			return true
		}
	}
	return false
}

// CredsDialOption returns the first supported transport credentials from the
// configuration, as a dial option.
func (sc *ServerConfig) CredsDialOption() grpc.DialOption {
	return sc.credsDialOption
}

// DialerOption returns the first supported Dialer function that specifies how
// to dial the xDS server from the configuration, as a dial option.
func (sc *ServerConfig) DialerOption() grpc.DialOption {
	return sc.dialerOption
}

// Cleanups returns a collection of functions to be called when the xDS client
// for this server is closed. Allows cleaning up resources created specifically
// for this server.
func (sc *ServerConfig) Cleanups() []func() {
	return sc.cleanups
}

// Equal reports whether sc and other are considered equal.
func (sc *ServerConfig) Equal(other *ServerConfig) bool {
	switch {
	case sc == nil && other == nil:
		return true
	case (sc != nil) != (other != nil):
		return false
	case sc.serverURI != other.serverURI:
		return false
	case !slices.EqualFunc(sc.channelCreds, other.channelCreds, func(a, b ChannelCreds) bool { return a.Equal(b) }):
		return false
	case !slices.Equal(sc.serverFeatures, other.serverFeatures):
		return false
	case !sc.selectedCreds.Equal(other.selectedCreds):
		return false
	}
	return true
}

// String returns the string representation of the ServerConfig.
func (sc *ServerConfig) String() string {

Review comment (suggestion):
Hmm ... I'm thinking if we should just have a method to return a slice of dial options from this type:

```golang
func (sc *ServerConfig) DialOptions() []grpc.DialOption {
	// return a slice of dial options that contains the creds dial option and optionally one for the dialer
}
```

With this approach, the transport can be oblivious to the dial options, and tomorrow if another dial option needs to be added here, then the transport won't have to change.

Code after:
// not invoke the watchers' OnResourceDoesNotExist() method when a resource is
// deleted, nor will it remove the existing resource value from its cache.
func (sc *ServerConfig) ServerFeaturesIgnoreResourceDeletion() bool {
	for _, sf := range sc.serverFeatures {
		if sf == serverFeaturesIgnoreResourceDeletion {
			return true
		}
	}
	return false
}

// CredsDialOption returns the first supported transport credentials from the
// configuration, as a dial option.
func (sc *ServerConfig) CredsDialOption() grpc.DialOption {
	return sc.credsDialOption
}

// DialerOption returns the Dialer function that specifies how to dial the xDS
// server determined by the first supported credentials from the configuration,
// as a dial option.
//
// TODO(https://github.com/grpc/grpc-go/issues/7661): change ServerConfig type
// to have a single method that returns all configured dial options.
func (sc *ServerConfig) DialerOption() grpc.DialOption {
	return sc.dialerOption
}

// Cleanups returns a collection of functions to be called when the xDS client
// for this server is closed. Allows cleaning up resources created specifically
// for this server.
func (sc *ServerConfig) Cleanups() []func() {
	return sc.cleanups
}

// Equal reports whether sc and other are considered equal.
func (sc *ServerConfig) Equal(other *ServerConfig) bool {
	switch {
	case sc == nil && other == nil:
		return true
	case (sc != nil) != (other != nil):
		return false
	case sc.serverURI != other.serverURI:
		return false
	case !slices.EqualFunc(sc.channelCreds, other.channelCreds, func(a, b ChannelCreds) bool { return a.Equal(b) }):
		return false
	case !slices.Equal(sc.serverFeatures, other.serverFeatures):
		return false
	case !sc.selectedCreds.Equal(other.selectedCreds):
		return false
	}
	return true