Skip to content

[WIP] Create function like TestOnBorrow that includes context#442

Open
MorrisLaw wants to merge 1 commit intogomodule:masterfrom
MorrisLaw:add-context-test-on-borrow
Open

[WIP] Create function like TestOnBorrow that includes context#442
MorrisLaw wants to merge 1 commit intogomodule:masterfrom
MorrisLaw:add-context-test-on-borrow

Conversation

@MorrisLaw
Copy link
Copy Markdown

This is an initial PR to address issue #439

Copy link
Copy Markdown
Collaborator

@stevenh stevenh left a comment

Choose a reason for hiding this comment

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

I'm not sure this can ever be of use if I'm honest as this is setup on the pool so the ctx with a timeout, which would be the desired use, will expire and resulting in all future calls failing.


// TestOnBorrowWithContext is the same as TestOnBorrow, but includes
// the context.
TestOnBorrowWithContext func(c Conn, t time.Time, ctx context.Context) error
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Context should always be the first parameter, I would also drop the With so its just TestOnBorrowContext as per Dial and DailContext

@MorrisLaw
Copy link
Copy Markdown
Author

the ctx with a timeout, which would be the desired use, will expire and resulting in all future calls failing.

I agree @stevenh , seems kind of pointless then... Should we just close this PR out?

@stevenh
Copy link
Copy Markdown
Collaborator

stevenh commented Apr 10, 2020

Closing based on timeout and other feedback.

@dcormier
Copy link
Copy Markdown
Contributor

I'm not sure this can ever be of use if I'm honest as this is setup on the pool so the ctx with a timeout, which would be the desired use, will expire and resulting in all future calls failing.

But wouldn't it be called with the context.Context passed to GetContext? I haven't dug into the code, but I would assume that's when TestOnBorrow would be called, so the context used should be correct. And if the context is canceled or timed out, then it should still be correct.

@stevenh
Copy link
Copy Markdown
Collaborator

stevenh commented Apr 13, 2020

I take it back, @dcormier is correct, reopening.

@stevenh stevenh reopened this Apr 13, 2020
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