Detached context

Hi,

I need a way to create a new context out of http.request.context but without inheriting the cancelation/deadline like bits. The reason is because I use this derived child context in DB queries and HTTP client requests. If the actual http.request.context is cancelled/timed out etc. my DB queries and HTTP client requests die too - obviously! How do I achieve this?

Thanks

Why do you want them to continue?

If you don’t want to inherit the deadline bits, do you just want to make context-scoped variables available? If not, then can you explain what you’re trying to do? If so, do you know what the keys are ahead of time? You could create a new context and then load it up with the values of the first one to effectively “remove” the cancelation parts.

@skillian

If you don’t want to inherit the deadline bits, do you just want to make context-scoped variables available?

Yes

If so, do you know what the keys are ahead of time?

Yes

You could create a new context and then load it up with the values of the first one to effectively “remove” the cancelation parts.

This would be a solution and I thought about it as well but same time I thought there would be some kind of magical method hidden somewhere that I could use. e.g. newCtx := currentCtx.BlahBlah()

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.