Skip to content

Commit

Permalink
GODRIVER-2965 Internalize description package (mongodb#1621)
Browse files Browse the repository at this point in the history
Co-authored-by: Matt Dale <9760375+matthewdale@users.noreply.github.com>
  • Loading branch information
prestonvasquez and matthewdale committed Jun 5, 2024
1 parent 8f7b20f commit bfe610f
Show file tree
Hide file tree
Showing 99 changed files with 2,735 additions and 2,747 deletions.
58 changes: 58 additions & 0 deletions event/description.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
// Copyright (C) MongoDB, Inc. 2024-present.
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may
// not use this file except in compliance with the License. You may obtain
// a copy of the License at http://www.apache.org/licenses/LICENSE-2.0

package event

import (
"time"

"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/mongo/address"
"go.mongodb.org/mongo-driver/tag"
)

// ServerDescription contains information about a node in a cluster. This is
// 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 {
Addr address.Address
Arbiters []string
Compression []string // compression methods returned by server
CanonicalAddr address.Address
ElectionID bson.ObjectID
IsCryptd bool
HelloOK bool
Hosts []string
Kind string
LastWriteTime time.Time
MaxBatchCount uint32
MaxDocumentSize uint32
MaxMessageSize uint32
MaxWireVersion int32
MinWireVersion int32
Members []address.Address
Passives []string
Passive bool
Primary address.Address
ReadOnly bool
ServiceID *bson.ObjectID // Only set for servers that are deployed behind a load balancer.
SessionTimeoutMinutes *int64
SetName string
SetVersion uint32
Tags tag.Set
TopologyVersionProcessID bson.ObjectID
TopologyVersionCounter int64
}

// TopologyDescription contains information about a MongoDB cluster.
type TopologyDescription struct {
Servers []ServerDescription
SetName string
Kind string
SessionTimeoutMinutes *int64
CompatibilityErr error
}
11 changes: 5 additions & 6 deletions event/monitoring.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (

"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/mongo/address"
"go.mongodb.org/mongo-driver/mongo/description"
)

// CommandStartedEvent represents an event generated when a command is sent to a server.
Expand Down Expand Up @@ -120,8 +119,8 @@ type PoolMonitor struct {
type ServerDescriptionChangedEvent struct {
Address address.Address
TopologyID bson.ObjectID // A unique identifier for the topology this server is a part of
PreviousDescription description.Server
NewDescription description.Server
PreviousDescription ServerDescription
NewDescription ServerDescription
}

// ServerOpeningEvent is an event generated when the server is initialized.
Expand All @@ -139,8 +138,8 @@ type ServerClosedEvent struct {
// TopologyDescriptionChangedEvent represents a topology description change.
type TopologyDescriptionChangedEvent struct {
TopologyID bson.ObjectID // A unique identifier for the topology this server is a part of
PreviousDescription description.Topology
NewDescription description.Topology
PreviousDescription TopologyDescription
NewDescription TopologyDescription
}

// TopologyOpeningEvent is an event generated when the topology is initialized.
Expand All @@ -162,7 +161,7 @@ type ServerHeartbeatStartedEvent struct {
// ServerHeartbeatSucceededEvent is an event generated when the heartbeat succeeds.
type ServerHeartbeatSucceededEvent struct {
Duration time.Duration
Reply description.Server
Reply ServerDescription
ConnectionID string // The address this heartbeat was sent to with a unique identifier
Awaited bool // If this heartbeat was awaitable
}
Expand Down
Loading

0 comments on commit bfe610f

Please sign in to comment.