Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use postpone.ContextWithValues() for Close on failure cases #10

Merged
merged 2 commits into from
Aug 31, 2021

Conversation

pperiyasamy
Copy link
Member

Signed-off-by: Periyasamy Palanisamy periyasamy.palanisamy@est.tech

Description

Issue link

How Has This Been Tested?

  • Added unit testing to cover
  • Tested manually
  • Tested by integration testing
  • Have not tested

Types of changes

  • Bug fix
  • New functionallity
  • Documentation
  • Refactoring
  • CI

@@ -56,16 +57,21 @@ func (c *kernelClient) Request(ctx context.Context, request *networkservice.Netw
if err != nil || request.GetConnection().GetNextPathSegment() != nil {
return conn, err
}
postponeCtxFunc := postpone.ContextWithValues(ctx)

Choose a reason for hiding this comment

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

I suppose that it would be better to use the following pattern:

postponeCtxFunc := postpone.ContextWithValues(ctx) // 1. first store ctx
conn, err := next.Request() // 2. after make Request
if err != nil {
    ...
    return nil, err
}
// 3. at this moment we most probably have stored context with timeout enough to make
//    a Close, because it was enough for making a Request

Copy link
Member Author

Choose a reason for hiding this comment

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

@Bolodya1997 yes, I see your point, made the changes now.

Signed-off-by: Periyasamy Palanisamy <periyasamy.palanisamy@est.tech>
Signed-off-by: Periyasamy Palanisamy <periyasamy.palanisamy@est.tech>
@pperiyasamy pperiyasamy merged commit 225673e into networkservicemesh:main Aug 31, 2021
@pperiyasamy pperiyasamy deleted the ctx-postpone branch August 31, 2021 10: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.

2 participants