galenwarren commented on pull request #303: URL: https://github.com/apache/flink-statefun/pull/303#issuecomment-1050009350
> I'm concerned that this change prevents us from ever being able to add our own kv pairs to the context Thanks @sjwiesman. I want to make sure I understand your concern properly. The big-picture motivation for this PR is to *enable* one to add kv pairs to the context, e.g.: ``` ctx = statefun.DeriveContext(ctx, context.WithValue(ctx, "key", "value")) ``` ... which would yield a new `statefun.Context` with the pair `key=value` added. By "us", do you mean the library itself, i.e. where the SDK might preload the context with some key/value pairs before calling `Invoke`? If that were done, and `DeriveContext` were called as above, then the resulting context would contain the preloaded key/value pairs plus `key=value`. Is the concern that one could call `DeriveContext` and not pass a `context.Context` that extends the original `statefun.Context` in some way (via `context.WithValue` or some other method), and thereby *remove* preloaded values from the context? That would be possible, but IMO that's really no different than what is possible when using regular `context.Context` instances, i.e. if a function receives a `context.Context` as a parameter, it can pass a completely unrelated `context.Context` downstream -- and "lose" context values -- if it wanted to. I'm not saying that would be a good idea -- it kind of defeats the purpose of context that flows with the function calls -- but it's allowed. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
