Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion mongo/integration/mtest/mongotest.go
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ func (t *T) GetProxiedMessages() []*ProxyMessage {
if t.proxyDialer == nil {
return nil
}
return t.proxyDialer.messages
return t.proxyDialer.Messages()
}

// ClearEvents clears the existing command monitoring events.
Expand Down
13 changes: 13 additions & 0 deletions mongo/integration/mtest/proxy_dialer.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,19 @@ func (p *proxyDialer) storeReceivedMessage(wm []byte, addr string) error {
return nil
}

// Messages returns a slice of proxied messages. This slice is a copy of the messages proxied so far and will not be
// updated for messages proxied after this call.
func (p *proxyDialer) Messages() []*ProxyMessage {
p.Lock()
defer p.Unlock()

copiedMessages := make([]*ProxyMessage, 0, len(p.messages))
for _, msg := range p.messages {
copiedMessages = append(copiedMessages, msg)
}
return copiedMessages
}

// proxyConn is a net.Conn that wraps a network connection. All messages sent/received through a proxyConn are stored
// in the associated proxyDialer and are forwarded over the wrapped connection. Errors encountered when parsing and
// storing wire messages are wrapped to add context, while errors returned from the underlying network connection are
Expand Down