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

feat(util:context) adds extended context interface #68

Closed
wants to merge 20 commits into from
Closed

Conversation

btc
Copy link
Contributor

@btc btc commented Sep 14, 2014

This new interface is a drop-in replacement for the go.net.context.

It adds an error logging method:

LogError(error)

TODO:

  • expose functionality that allows caller to handle logged errors

@btc btc added the status/in-progress In progress label Sep 14, 2014
@btc btc self-assigned this Sep 14, 2014
Brian Tiger Chow added 3 commits September 14, 2014 01:01
@btc btc added codereview and removed status/in-progress In progress labels Sep 14, 2014
// wrap() wraps |ctx| to extend its interface and turns |f| into a CancelFunc
func wrap(ctx goctx.Context, f goctx.CancelFunc) (*wrappedContext, CancelFunc) {
w := &wrappedContext{Context: ctx, errLogChan: make(chan error)}
return w, CancelFunc(f)
Copy link
Member

Choose a reason for hiding this comment

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

Im naive to the uses of contexts, but why do we return the cancelFunc?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The cancelFunc can be used to manually cancel the context.

ctx, f := context.WithCancel(parent)
go operation(ctx)
// decide to cancel operation
f()

@btc
Copy link
Contributor Author

btc commented Sep 15, 2014

I think I can make this simpler.

But it's lower priority than net, so I'll move this back to the backlog and address it again when it's closer to the top of the PQ.

Helping to get the net stuff merged into master is my priority.

@btc btc removed the codereview label Sep 15, 2014
btc pushed a commit that referenced this pull request Sep 23, 2014
This commit...

is a second attempt at: #68

partially addresses: #66

is the result of discussion at:

    https://gist.github.com/perfmode/f2951c1ed3a02c484d0b
@btc
Copy link
Contributor Author

btc commented Sep 23, 2014

see #108

@btc btc closed this Sep 23, 2014
btc pushed a commit that referenced this pull request Sep 23, 2014
This commit...

is a second attempt at: #68

partially addresses: #66

is the result of discussion at:

    https://gist.github.com/perfmode/f2951c1ed3a02c484d0b
btc pushed a commit that referenced this pull request Sep 24, 2014
This commit...

is a second attempt at: #68

partially addresses: #66

is the result of discussion at:

    https://gist.github.com/perfmode/f2951c1ed3a02c484d0b
@btc btc deleted the ipfs-context branch October 22, 2014 23:06
@btc btc removed their assignment Mar 30, 2015
@aschmahmann aschmahmann mentioned this pull request Sep 22, 2020
72 tasks
laurentsenta pushed a commit to laurentsenta/kubo that referenced this pull request Feb 25, 2022
chore: remove unnecessary dependency
laurentsenta pushed a commit to laurentsenta/kubo that referenced this pull request Feb 25, 2022
laurentsenta pushed a commit to laurentsenta/kubo that referenced this pull request Mar 4, 2022
laurentsenta pushed a commit to laurentsenta/kubo that referenced this pull request Mar 4, 2022
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