Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GODRIVER-2965 Internalize description package #1621

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

prestonvasquez
Copy link
Collaborator

GODRIVER-2965

Summary

Internalize the logic in the description package.

Background & Motivation

Most of the "description" package does not need to be part of the public API. The few parts that do can be merged into the most appropriate package(s).

@prestonvasquez prestonvasquez changed the base branch from v1 to master April 26, 2024 19:47
@mongodb-drivers-pr-bot mongodb-drivers-pr-bot bot added the priority-3-low Low Priority PR for Review label Apr 26, 2024
Copy link

API Change Report

./event

incompatible changes

##ServerDescriptionChangedEvent.NewDescription: changed from ./mongo/description.Server to ServerDescription
##ServerDescriptionChangedEvent.PreviousDescription: changed from ./mongo/description.Server to ServerDescription
##ServerHeartbeatSucceededEvent.Reply: changed from ./mongo/description.Server to ServerDescription
##TopologyDescriptionChangedEvent.NewDescription: changed from ./mongo/description.Topology to TopologyDescription
##TopologyDescriptionChangedEvent.PreviousDescription: changed from ./mongo/description.Topology to TopologyDescription

compatible changes

ServerDescription: added
TopologyDescription: added

./mongo/description

incompatible changes

package removed

./x/mongo/driver

incompatible changes

##CursorResponse.Desc: changed from ./mongo/description.Server to ./x/mongo/driver/description.Server
##Deployment.Kind: changed from func() ./mongo/description.TopologyKind to func() ./x/mongo/driver/description.TopologyKind
##Deployment.SelectServer: changed from func(context.Context, ./mongo/description.ServerSelector) (Server, error) to func(context.Context, ./x/mongo/driver/description.ServerSelector) (Server, error)
##Error.RetryableWrite: changed from func(./mongo/description.VersionRange) bool to func(./x/mongo/driver/description.VersionRange) bool
##Error.TopologyVersion: changed from ./mongo/description.TopologyVersion to ./x/mongo/driver/description.TopologyVersion
##HandshakeInformation.Description: changed from ./mongo/description.Server to ./x/mongo/driver/description.Server
##Operation.CommandFn: changed from func([]byte, ./mongo/description.SelectedServer) ([]byte, error) to func([]byte, ./x/mongo/driver/description.SelectedServer) ([]byte, error)
##Operation.Selector: changed from ./mongo/description.ServerSelector to ./x/mongo/driver/description.ServerSelector
##ResponseInfo.ConnectionDescription: changed from ./mongo/description.Server to ./x/mongo/driver/description.Server
##SingleConnectionDeployment.Kind: changed from func() ./mongo/description.TopologyKind to func() ./x/mongo/driver/description.TopologyKind
##SingleConnectionDeployment.SelectServer: changed from func(context.Context, ./mongo/description.ServerSelector) (Server, error) to func(context.Context, ./x/mongo/driver/description.ServerSelector) (Server, error)
##SingleServerDeployment.Kind: changed from func() ./mongo/description.TopologyKind to func() ./x/mongo/driver/description.TopologyKind
##SingleServerDeployment.SelectServer: changed from func(context.Context, ./mongo/description.ServerSelector) (Server, error) to func(context.Context, ./x/mongo/driver/description.ServerSelector) (Server, error)
##Subscription.Updates: changed from <-chan ./mongo/description.Topology to <-chan ./x/mongo/driver/description.Topology
##WriteCommandError.Retryable: changed from func(
./mongo/description.VersionRange) bool to func(
./x/mongo/driver/description.VersionRange) bool
##WriteConcernError.TopologyVersion: changed from *./mongo/description.TopologyVersion to *./x/mongo/driver/description.TopologyVersion

./x/mongo/driver/auth

incompatible changes

##HandshakeOptions.PerformAuthentication: changed from func(./mongo/description.Server) bool to func(./x/mongo/driver/description.Server) bool

./x/mongo/driver/description

compatible changes

package added

./x/mongo/driver/drivertest

incompatible changes

##(*ChannelConn).Description: changed from func() ./mongo/description.Server to func() ./x/mongo/driver/description.Server
##ChannelConn.Desc: changed from ./mongo/description.Server to ./x/mongo/driver/description.Server

./x/mongo/driver/mnet

incompatible changes

##Describer.Description: changed from func() ./mongo/description.Server to func() ./x/mongo/driver/description.Server
NewConnection: changed from func(interface{ReadWriteCloser; Describer}) *Connection to func(interface{ReadWriteCloser; Describer}) *Connection

./x/mongo/driver/operation

incompatible changes

##(*AbortTransaction).ServerSelector: changed from func(./mongo/description.ServerSelector) *AbortTransaction to func(./x/mongo/driver/description.ServerSelector) *AbortTransaction
##(*Aggregate).ServerSelector: changed from func(./mongo/description.ServerSelector) *Aggregate to func(./x/mongo/driver/description.ServerSelector) *Aggregate
##(*Command).ServerSelector: changed from func(./mongo/description.ServerSelector) *Command to func(./x/mongo/driver/description.ServerSelector) *Command
##(*CommitTransaction).ServerSelector: changed from func(./mongo/description.ServerSelector) *CommitTransaction to func(./x/mongo/driver/description.ServerSelector) *CommitTransaction
##(*Count).ServerSelector: changed from func(./mongo/description.ServerSelector) *Count to func(./x/mongo/driver/description.ServerSelector) *Count
##(*Create).ServerSelector: changed from func(./mongo/description.ServerSelector) *Create to func(./x/mongo/driver/description.ServerSelector) *Create
##(*CreateIndexes).ServerSelector: changed from func(./mongo/description.ServerSelector) *CreateIndexes to func(./x/mongo/driver/description.ServerSelector) *CreateIndexes
##(*CreateSearchIndexes).ServerSelector: changed from func(./mongo/description.ServerSelector) *CreateSearchIndexes to func(./x/mongo/driver/description.ServerSelector) *CreateSearchIndexes
##(*Delete).ServerSelector: changed from func(./mongo/description.ServerSelector) *Delete to func(./x/mongo/driver/description.ServerSelector) *Delete
##(*Distinct).ServerSelector: changed from func(./mongo/description.ServerSelector) *Distinct to func(./x/mongo/driver/description.ServerSelector) *Distinct
##(*DropCollection).ServerSelector: changed from func(./mongo/description.ServerSelector) *DropCollection to func(./x/mongo/driver/description.ServerSelector) *DropCollection
##(*DropDatabase).ServerSelector: changed from func(./mongo/description.ServerSelector) *DropDatabase to func(./x/mongo/driver/description.ServerSelector) *DropDatabase
##(*DropIndexes).ServerSelector: changed from func(./mongo/description.ServerSelector) *DropIndexes to func(./x/mongo/driver/description.ServerSelector) *DropIndexes
##(*DropSearchIndex).ServerSelector: changed from func(./mongo/description.ServerSelector) *DropSearchIndex to func(./x/mongo/driver/description.ServerSelector) *DropSearchIndex
##(*EndSessions).ServerSelector: changed from func(./mongo/description.ServerSelector) *EndSessions to func(./x/mongo/driver/description.ServerSelector) *EndSessions
##(*Find).ServerSelector: changed from func(./mongo/description.ServerSelector) *Find to func(./x/mongo/driver/description.ServerSelector) *Find
##(*FindAndModify).ServerSelector: changed from func(./mongo/description.ServerSelector) *FindAndModify to func(./x/mongo/driver/description.ServerSelector) *FindAndModify
##(*Hello).Result: changed from func(./mongo/address.Address) ./mongo/description.Server to func(./mongo/address.Address) ./x/mongo/driver/description.Server
##(Hello).TopologyVersion: changed from func(./mongo/description.TopologyVersion) Hello to func(./x/mongo/driver/description.TopologyVersion) *Hello
##(*Insert).ServerSelector: changed from func(./mongo/description.ServerSelector) *Insert to func(./x/mongo/driver/description.ServerSelector) *Insert
##(*ListCollections).ServerSelector: changed from func(./mongo/description.ServerSelector) *ListCollections to func(./x/mongo/driver/description.ServerSelector) *ListCollections
##(*ListDatabases).ServerSelector: changed from func(./mongo/description.ServerSelector) *ListDatabases to func(./x/mongo/driver/description.ServerSelector) *ListDatabases
##(*ListIndexes).ServerSelector: changed from func(./mongo/description.ServerSelector) *ListIndexes to func(./x/mongo/driver/description.ServerSelector) *ListIndexes
##(*Update).ServerSelector: changed from func(./mongo/description.ServerSelector) *Update to func(./x/mongo/driver/description.ServerSelector) *Update
##(*UpdateSearchIndex).ServerSelector: changed from func(./mongo/description.ServerSelector) *UpdateSearchIndex to func(./x/mongo/driver/description.ServerSelector) *UpdateSearchIndex

./x/mongo/driver/session

incompatible changes

##(*Client).ApplyCommand: changed from func(./mongo/description.Server) error to func(./x/mongo/driver/description.Server) error
Client.PinnedServer: removed
##NewPool: changed from func(<-chan ./mongo/description.Topology) *Pool to func(<-chan ./x/mongo/driver/description.Topology) *Pool
##./x/mongo/driver/mnet.Describer.Description: changed from func() ./mongo/description.Server to func() ./x/mongo/driver/description.Server

compatible changes

Client.PinnedServerAddr: added

./x/mongo/driver/topology

incompatible changes

##(*Connection).Description: changed from func() ./mongo/description.Server to func() ./x/mongo/driver/description.Server
##(*SelectedServer).Description: changed from func() ./mongo/description.SelectedServer to func() ./x/mongo/driver/description.SelectedServer
##(*Server).Description: changed from func() ./mongo/description.Server to func() ./x/mongo/driver/description.Server
##(*Server).SelectedDescription: changed from func() ./mongo/description.SelectedServer to func() ./x/mongo/driver/description.SelectedServer
##(*Topology).Description: changed from func() ./mongo/description.Topology to func() ./x/mongo/driver/description.Topology
##(*Topology).FindServer: changed from func(./mongo/description.Server) (*SelectedServer, error) to func(./x/mongo/driver/description.Server) (*SelectedServer, error)
##(*Topology).Kind: changed from func() ./mongo/description.TopologyKind to func() ./x/mongo/driver/description.TopologyKind
##(*Topology).SelectServer: changed from func(context.Context, ./mongo/description.ServerSelector) (./x/mongo/driver.Server, error) to func(context.Context, ./x/mongo/driver/description.ServerSelector) (./x/mongo/driver.Server, error)
##SelectedServer.Kind: changed from ./mongo/description.TopologyKind to ./x/mongo/driver/description.TopologyKind
##ServerSelectionError.Desc: changed from ./mongo/description.Topology to ./x/mongo/driver/description.Topology
##ServerSubscription.C: changed from <-chan ./mongo/description.Server to <-chan ./x/mongo/driver/description.Server
##SupportedWireVersions: changed from ./mongo/description.VersionRange to ./x/mongo/driver/description.VersionRange
##updateTopologyCallback: changed from func(./mongo/description.Server) ./mongo/description.Server to func(./x/mongo/driver/description.Server) ./x/mongo/driver/description.Server

// created from hello command responses. If the value of the Kind field is
// LoadBalancer, only the Addr and Kind fields will be set. All other fields
// will be set to the zero value of the field's type.
type ServerDescription struct {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ServerDescription holds data from the handshake, parsed from driverutil.NewDescriptionServer.

IsCryptd bool
HelloOK bool
Hosts []string
Kind string
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Return a string that can be compared to the the enumeration in the experimental description package. E.g:

if strings.ToLower(server.Kind) == strings.ToLower(description.ServerKindMongos.String()) {
    // Do something
}

@@ -116,7 +117,7 @@ type Client struct {

pool *Pool
TransactionState TransactionState
PinnedServer *description.Server
PinnedServerAddr *address.Address
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only value used on PinnedServer is the address.

@prestonvasquez prestonvasquez marked this pull request as ready for review April 26, 2024 20:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority-3-low Low Priority PR for Review
Projects
None yet
1 participant