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

Support merging an ld_context and an ld_multi_context #126

Open
brentjanderson opened this issue May 15, 2024 · 1 comment
Open

Support merging an ld_context and an ld_multi_context #126

brentjanderson opened this issue May 15, 2024 · 1 comment
Assignees
Labels
enhancement New feature or request

Comments

@brentjanderson
Copy link

Is your feature request related to a problem? Please describe.

I'd like to be able to use :ldclient_context.new_multi_from/1 with a mixed list of :ldclient_context.context() and :ldclient_context.multi_context().

Presently, you end up with a multi context that looks something like this:

contexts = [
  :ldclient_context.new_from_map(%{kind: "some-context", key: "some-context-key"}),
  :ldclient_context.new_from_map(%{kind: "user", key: "some-user-key"}),
]

multi_context = :ldclient_context.new_multi_from(contexts)

more_contexts = [
  multi_context,
  :ldclient_context.new_from_map(%{kind: "another-context", key: "foobar"})
]

bad_context = :ldclient_context.new_multi_from(more_contexts)

# I would hope that bad_context would look something like this:

%{
  :kind => "multi",
  "some-context" => %{key: "some-account-key"},
  "another-context" => %{key: "foobar"},
  "user" => %{key: "some-user-key"}
} == bad_context # This equality check fails

# Unfortunately, it looks like this:

%{
  :kind => "multi",
  "multi" => %{
    "some-context" => %{key: "some-context"},key
    "user" => %{key: "some-user-key"}
  },
  "another-context" => %{key: "foobar"}
} == bad_context

Describe the solution you'd like
I'd like to be able to combine a mixed list of LD Contexts & Multi contexts into a single, well-formatted LD multi context.

Describe alternatives you've considered
I have a workaround that handles building a list of LD Contexts and then merging them all at once, but running at the library level would be more convenient.

Additional context
N/A

@cwaldren-ld
Copy link
Contributor

Hi @brentjanderson, that is a reasonable request. We'll consider how to handle this and get back to you.

Filed internally as 244385.

@cwaldren-ld cwaldren-ld added the enhancement New feature or request label May 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants