Skip to content

Conversation

@kinyoklion
Copy link
Member

No description provided.

@kinyoklion kinyoklion marked this pull request as ready for review May 31, 2023 21:05
.Build();

auto builder = ContextBuilder(context);
if (auto updater = builder.Kind("user")) {
Copy link
Member Author

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.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice!

Copy link
Contributor

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?

Copy link
Member Author

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 =
Copy link
Member Author

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.

Copy link
Contributor

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?

Copy link
Member Author

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.

Copy link
Contributor

@mmrj mmrj left a 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.
Copy link
Contributor

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 ?

Copy link
Member Author

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.

Copy link
Member Author

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.)

Comment on lines +200 to +202
* Start updating an existing kind.
*
* @param kind The kind to start updating.
Copy link
Contributor

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

Comment on lines -83 to +97
* 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.
Copy link
Contributor

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.

Copy link
Member Author

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.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both are kinds though.

Copy link
Contributor

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")) {
Copy link
Contributor

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")) {
Copy link
Contributor

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 =
Copy link
Contributor

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?

@kinyoklion kinyoklion merged commit 5e18616 into main May 31, 2023
@kinyoklion kinyoklion deleted the rlamb/context-ergonomics branch May 31, 2023 21:31
@github-actions github-actions bot mentioned this pull request May 31, 2023
cwaldren-ld pushed a commit that referenced this pull request May 31, 2023
🤖 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>
This was referenced May 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants