-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Conversation
errors are piped to parent when parent instantiates a context with: WithErrorLog
exercise inheritance through error logging context
// 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) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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()
I think I can make this simpler. But it's lower priority than Helping to get the net stuff merged into master is my priority. |
609a71b
to
5fafaa4
Compare
This commit... is a second attempt at: #68 partially addresses: #66 is the result of discussion at: https://gist.github.com/perfmode/f2951c1ed3a02c484d0b
see #108 |
This commit... is a second attempt at: #68 partially addresses: #66 is the result of discussion at: https://gist.github.com/perfmode/f2951c1ed3a02c484d0b
This commit... is a second attempt at: #68 partially addresses: #66 is the result of discussion at: https://gist.github.com/perfmode/f2951c1ed3a02c484d0b
chore: remove unnecessary dependency
chore: remove unnecessary dependency
chore: remove unnecessary dependency
chore: remove unnecessary dependency
This new interface is a drop-in replacement for the go.net.context.
It adds an error logging method:
TODO: