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

Pass a context to every kopf call/handler #347

Closed
2 tasks done
kopf-archiver bot opened this issue Aug 18, 2020 · 1 comment · Fixed by #667
Closed
2 tasks done

Pass a context to every kopf call/handler #347

kopf-archiver bot opened this issue Aug 18, 2020 · 1 comment · Fixed by #667
Labels
archive question Further information is requested

Comments

@kopf-archiver
Copy link

kopf-archiver bot commented Aug 18, 2020

An issue by krish7919 at 2020-04-12 12:34:48+00:00
Original URL: zalando-incubator/kopf#347
 

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.


Commented by nolar at 2020-04-15 21:17:39+00:00
 

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?


Commented by krish7919 at 2020-04-15 21:33:47+00:00
 

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


Commented by mnaser at 2020-04-17 21:05:10+00:00
 

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


Commented by eshepelyuk at 2020-05-17 03:16:03+00:00
 

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

@kopf-archiver kopf-archiver bot closed this as completed Aug 18, 2020
@kopf-archiver kopf-archiver bot changed the title [archival placeholder] Pass a context to every kopf call/handler Aug 19, 2020
@kopf-archiver kopf-archiver bot added the question Further information is requested label Aug 19, 2020
@kopf-archiver kopf-archiver bot reopened this Aug 19, 2020
@nolar nolar closed this as completed in #667 Feb 5, 2021
@nolar
Copy link
Owner

nolar commented Feb 25, 2021

Pre-released in kopf>=1.30.0rc1, docs: https://kopf.readthedocs.io/en/latest/memos/

Includes cross-handler data exchange (incl. cross-resource-&-operator-handlers) and arbitrary structs for embedded operators.

FYI, @krish7919, @mnaser.

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

Successfully merging a pull request may close this issue.

1 participant