-
Notifications
You must be signed in to change notification settings - Fork 3
feat: Allow for easier creation of contexts from existing contexts. #130
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
Conversation
| .Build(); | ||
|
|
||
| auto builder = ContextBuilder(context); | ||
| if (auto updater = builder.Kind("user")) { |
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.
@mmrj Adding "state" and "sneaky" to the context.
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.
nice!
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.
could I also do:
updater->Set("city", "Winnemucca")
and overwrite the Reno value?
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.
Yes.
| .Set("city", "Reno") | ||
| .Build(); | ||
|
|
||
| auto updated_context = |
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.
@mmrj Adding an "org" to the context.
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.
nice. Do I need to call IdentifyAsync with updated_context after this?
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.
Yes, this just makes a context. You need to identify with that context to get flag values for it.
mmrj
left a comment
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.
Semantics of using this LGTM. I left a couple of questions and some nits on the comments, but nothing blocking.
| } | ||
|
|
||
| /** | ||
| * Start adding a kind to the context. |
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.
Wording nit: I think you are adding a new context with the specified kind to the builder ?
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.
I don't know. I don't really think we are, or that if we are it isn't meaningful.
builder.Set("address", "111 Street")
I am adding an address to my context?
The address isn't an "address" though. It is a string, which I have added to my context with the name "address".
A kind is just the key for a set of attributes in a context, which we also happen to call a context.
I think we are adding a kind.
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 kind happens to be a context, like the address happens to be a string, or the name is a string.)
| * Start updating an existing kind. | ||
| * | ||
| * @param kind The kind to start updating. |
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.
same as above, I think you're updating the existing context with the given kind
| * the contents of the builder are moved into the created context. | ||
| * Start updating an existing kind. | ||
| * | ||
| * After the context is build, then this builder, and any kind builders | ||
| * associated with it, should no longer be used. | ||
| * @param kind The kind to start updating. |
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.
same here
I think the reason I find the current wording a little confusing is because in the UI a context kind is an entity that you can create and define (Contexts list --> Kind tab --> Create kind). It's separate from any context where it's used, and this is definitely not working with that.
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.
Yeah, adding a "org" to a context is different than adding an "org" to your launchdarky account. The "org" you put into a context has attributes, and you cannot even make it without any attributes.
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.
Both are kinds though.
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.
Yeah I think got hung up on the two uses of "kind":
- the entity you add to your LD account, can (but don't have to) use when defining a new context in the SDK, and can get a list of using the REST API, etc.
- the thing that, as you say above, happens to be a context, like the address happens to be a string, or the name is a string
| .Build(); | ||
|
|
||
| auto builder = ContextBuilder(context); | ||
| if (auto updater = builder.Kind("user")) { |
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.
nice!
| .Build(); | ||
|
|
||
| auto builder = ContextBuilder(context); | ||
| if (auto updater = builder.Kind("user")) { |
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.
could I also do:
updater->Set("city", "Winnemucca")
and overwrite the Reno value?
| .Set("city", "Reno") | ||
| .Build(); | ||
|
|
||
| auto updated_context = |
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.
nice. Do I need to call IdentifyAsync with updated_context after this?
🤖 I have created a release *beep* *boop* --- <details><summary>launchdarkly-cpp-client: 0.2.0</summary> ## [0.2.0](launchdarkly-cpp-client-v0.1.0...launchdarkly-cpp-client-v0.2.0) (2023-05-31) ### Features * add AllFlags C binding ([#128](#128)) ([9aa0794](9aa0794)) * Add C bindings for data source status. ([#124](#124)) ([d175abb](d175abb)) * Add c bindings for FlagNotifier. ([#119](#119)) ([11a7f61](11a7f61)) * add Version method to obtain SDK version ([#122](#122)) ([1003117](1003117)) ### Dependencies * The following workspace dependencies were updated * dependencies * launchdarkly-cpp-internal bumped from 0.1.0 to 0.1.1 * launchdarkly-cpp-common bumped from 0.1.0 to 0.2.0 </details> <details><summary>launchdarkly-cpp-common: 0.2.0</summary> ## [0.2.0](launchdarkly-cpp-common-v0.1.0...launchdarkly-cpp-common-v0.2.0) (2023-05-31) ### Features * add AllFlags C binding ([#128](#128)) ([9aa0794](9aa0794)) * Add C bindings for data source status. ([#124](#124)) ([d175abb](d175abb)) * Add c bindings for FlagNotifier. ([#119](#119)) ([11a7f61](11a7f61)) * Allow for easier creation of contexts from existing contexts. ([#130](#130)) ([5e18616](5e18616)) ### Bug Fixes * rename C iterator bindings to follow new/free pattern ([#129](#129)) ([24dff9a](24dff9a)) </details> <details><summary>launchdarkly-cpp-internal: 0.1.1</summary> ### Dependencies * The following workspace dependencies were updated * dependencies * launchdarkly-cpp-common bumped from 0.1.0 to 0.2.0 </details> --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
No description provided.