Skip to content
This repository has been archived by the owner on Sep 14, 2020. It is now read-only.

Pass a context to every kopf call/handler #347

Open
2 tasks done
krish7919 opened this issue Apr 12, 2020 · 4 comments
Open
2 tasks done

Pass a context to every kopf call/handler #347

krish7919 opened this issue Apr 12, 2020 · 4 comments
Labels
question Further information is requested

Comments

@krish7919
Copy link

krish7919 commented Apr 12, 2020

Question

I would like to embed kopf in an application to perform some extra cluster functions as a response to events.

I can always use a global variable.
Actually, I have to go the embedding way as I want to build wrappers to take some custom arguments as input, validate them, form connection strings, and then start the kopf asyncio loop. Plus I have to pass these params around as every handler would need them.

This should be a pretty common ask, and I am not sure how is that done currently.

Checklist

Keywords

"kopf pass context to handlers" on Google and in docs.

@krish7919 krish7919 added the question Further information is requested label Apr 12, 2020
@nolar
Copy link
Contributor

nolar commented Apr 15, 2020

@krish7919 Just to clarify: do you mean an arbitrary object of arbitrary class, which is passed through the call stack from the owning application down to the handlers (all of them), right? Something like a memo kwarg (per-resource container for arbitrary keys/fields), but global and of external origin?

@krish7919
Copy link
Author

Precisely. In Go, this is the context, or a struct with the values required.

@mnaser
Copy link

mnaser commented Apr 17, 2020

This is something that's interesting for our usage too, especially when we're constantly trying to connect to the Kuberentes API..

@eshepelyuk
Copy link

This issue also may be related to my question in #367

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

4 participants