Skip to content

Conversation

@patrickfreed
Copy link
Contributor

SWIFT-314

This PR updates the ServerDescription initializer to rely on BSONDecoder to decode ismaster responses instead of directly accessing the command response document.

This ticket originally sought to add graceful error handling to SDAM monitoring event construction, but without access to a logger, there really isn't anything more we can do right now. To that end, I added a number of TODO comments indicating that, once we add support for a logger, we can log when encountering errors.

@patrickfreed patrickfreed changed the title SWIFT-314 Use BSONDecoder to construct ServerDescription SWIFT-314 Use BSONDecoder to decode isMaster responses in SDAM monitoring Feb 12, 2020
// we have to copy because libmongoc owns the pointer.
let isMaster = Document(copying: mongoc_server_description_ismaster(description))

self.lastWriteDate = isMaster["lasWrite"]?.documentValue?["lastWriteDate"]?.dateValue
Copy link
Contributor Author

Choose a reason for hiding this comment

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

"lasWrite"

whoops

Copy link
Contributor

Choose a reason for hiding this comment

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

compelling argument for using Codable 🙂

@patrickfreed patrickfreed marked this pull request as ready for review February 12, 2020 23:35
@patrickfreed patrickfreed requested a review from kmahar February 12, 2020 23:35
@patrickfreed patrickfreed merged commit fcb54e2 into master Feb 13, 2020
@patrickfreed patrickfreed deleted the SWIFT-314/ismaster-parsing branch February 13, 2020 16:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants