Skip to content

Commit 76bc82c

Browse files
author
Divjot Arora
committed
GODRIVER-1405 Remove topology.WithConnectionAppName (#377)
1 parent 116d850 commit 76bc82c

File tree

6 files changed

+34
-19
lines changed

6 files changed

+34
-19
lines changed

mongo/client.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -337,9 +337,6 @@ func (c *Client) configure(opts *options.ClientOptions) error {
337337
serverOpts = append(serverOpts, topology.WithServerAppName(func(string) string {
338338
return appName
339339
}))
340-
connOpts = append(connOpts, topology.WithConnectionAppName(func(string) string {
341-
return appName
342-
}))
343340
}
344341
// Compressors & ZlibLevel
345342
var comps []string

mongo/integration/client_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,8 @@ func TestClient(t *testing.T) {
351351
SetAppName(testAppName)
352352
appNameMtOpts := mtest.NewOptions().
353353
ClientOptions(appNameDialerOpts).
354-
Topologies(mtest.Single)
354+
Topologies(mtest.Single).
355+
Auth(false) // Can't run with auth because the proxy dialer won't work with TLS enabled.
355356
mt.RunOpts("app name is always sent", appNameMtOpts, func(mt *mtest.T) {
356357
err := mt.Client.Ping(mtest.Background, mtest.PrimaryRp)
357358
assert.Nil(mt, err, "Ping error: %v", err)

x/mongo/driver/drivertest/channel_conn.go

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,3 +75,35 @@ func MakeReply(doc bsoncore.Document) []byte {
7575
dst = append(dst, doc...)
7676
return bsoncore.UpdateLength(dst, idx, int32(len(dst[idx:])))
7777
}
78+
79+
// GetCommandFromQueryWireMessage returns the command sent in an OP_QUERY wire message.
80+
func GetCommandFromQueryWireMessage(wm []byte) (bsoncore.Document, error) {
81+
var ok bool
82+
_, _, _, _, wm, ok = wiremessage.ReadHeader(wm)
83+
if !ok {
84+
return nil, errors.New("could not read header")
85+
}
86+
_, wm, ok = wiremessage.ReadQueryFlags(wm)
87+
if !ok {
88+
return nil, errors.New("could not read flags")
89+
}
90+
_, wm, ok = wiremessage.ReadQueryFullCollectionName(wm)
91+
if !ok {
92+
return nil, errors.New("could not read fullCollectionName")
93+
}
94+
_, wm, ok = wiremessage.ReadQueryNumberToSkip(wm)
95+
if !ok {
96+
return nil, errors.New("could not read numberToSkip")
97+
}
98+
_, wm, ok = wiremessage.ReadQueryNumberToReturn(wm)
99+
if !ok {
100+
return nil, errors.New("could not read numberToReturn")
101+
}
102+
103+
var query bsoncore.Document
104+
query, wm, ok = wiremessage.ReadQueryQuery(wm)
105+
if !ok {
106+
return nil, errors.New("could not read query")
107+
}
108+
return query, nil
109+
}

x/mongo/driver/examples/server_monitoring/main.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,6 @@ func main() {
2020
address.Address("localhost:27017"),
2121
nil,
2222
topology.WithHeartbeatInterval(func(time.Duration) time.Duration { return 2 * time.Second }),
23-
topology.WithConnectionOptions(
24-
func(opts ...topology.ConnectionOption) []topology.ConnectionOption {
25-
return append(opts, topology.WithConnectionAppName(func(string) string { return "server monitoring test" }))
26-
},
27-
),
2823
)
2924
if err != nil {
3025
log.Fatalf("could not start server: %v", err)

x/mongo/driver/topology/connection_options.go

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -83,15 +83,6 @@ func withServerDescriptionCallback(callback func(description.Server), opts ...Co
8383
// ConnectionOption is used to configure a connection.
8484
type ConnectionOption func(*connectionConfig) error
8585

86-
// WithConnectionAppName sets the application name which gets sent to MongoDB when it
87-
// first connects.
88-
func WithConnectionAppName(fn func(string) string) ConnectionOption {
89-
return func(c *connectionConfig) error {
90-
c.appName = fn(c.appName)
91-
return nil
92-
}
93-
}
94-
9586
// WithCompressors sets the compressors that can be used for communication.
9687
func WithCompressors(fn func([]string) []string) ConnectionOption {
9788
return func(c *connectionConfig) error {

x/mongo/driver/topology/topology_options.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ func WithConnString(fn func(connstring.ConnString) connstring.ConnString) Option
6565
var connOpts []ConnectionOption
6666

6767
if cs.AppName != "" {
68-
connOpts = append(connOpts, WithConnectionAppName(func(string) string { return cs.AppName }))
6968
c.serverOpts = append(c.serverOpts, WithServerAppName(func(string) string { return cs.AppName }))
7069
}
7170

0 commit comments

Comments
 (0)