Skip to content

Commit

Permalink
Implement base driver.Connection type
Browse files Browse the repository at this point in the history
Implements the topology.connection and topology.Connection types.

GODRIVER-930

Change-Id: If3c133b754028b8e832aa198b285593f6f2efbfc
  • Loading branch information
skriptble committed Apr 25, 2019
1 parent 976cd7c commit 3e5f96b
Show file tree
Hide file tree
Showing 11 changed files with 958 additions and 43 deletions.
9 changes: 9 additions & 0 deletions x/mongo/driver/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package driver // import "go.mongodb.org/mongo-driver/x/mongo/driver"
import (
"context"

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

Expand All @@ -25,4 +26,12 @@ type Connection interface {
Description() description.Server
Close() error
ID() string
Address() address.Address
}

// ErrorProcessor implementations can handle processing errors, which may modify their internal state.
// If this type is implemented by a Server, then Operation.Execute will call it's ProcessError
// method after it decodes a wire message.
type ErrorProcessor interface {
ProcessError(error)
}
16 changes: 16 additions & 0 deletions x/mongo/driverlegacy/topology/DESIGN.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Topology Package Design
This document outlines the design for this package.

## Connection
Connections are handled by two main types and an auxiliary type. The two main types are `connection`
and `Connection`. The first holds most of the logic required to actually read and write wire
messages. Instances can be created with the `newConnection` method. Inside the `newConnection`
method the auxiliary type, `initConnection` is used to perform the connection handshake. This is
required because the `connection` type does not fully implement `driver.Connection` which is
required during handshaking. The `Connection` type is what is actually returned to a consumer of the
`topology` package. This type does implement the `driver.Connection` type, holds a reference to a
`connection` instance, and exists mainly to prevent accidental continued usage of a connection after
closing it.

The connection implementations in this package are conduits for wire messages but they have no
ability to encode, decode, or validate wire messages. That must be handled by consumers.
Loading

0 comments on commit 3e5f96b

Please sign in to comment.