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

feat: Add support for hooks. #126

Merged
merged 19 commits into from
Mar 28, 2024
Merged

Conversation

kinyoklion
Copy link
Member

Second PR.

This connects hooks to the ldclient.

It does not add the Ex methods to any interface, and it does not add AddHooks to any interface.

stage ldmigration.Stage,
) (ldmigration.Stage, interfaces.LDMigrationOpTracker, error)

func TestMigrationVariation(t *testing.T) {
Copy link
Member Author

Choose a reason for hiding this comment

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

Re-worked these tests to be parameterized so they could be ran against MigrationVariation and MigrationVariationEx.

ldclient.go Outdated
"github.com/launchdarkly/go-server-sdk/v7/subsystems"
"github.com/launchdarkly/go-server-sdk/v7/subsystems/ldstoreimpl"
)

// Version is the SDK version.
const Version = internal.SDKVersion

const boolVarFuncName = "LDClient.BoolVariation"
Copy link
Contributor

Choose a reason for hiding this comment

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

Can surround this with a giant const block

ldclient.go Outdated
// has no off variation.
//
// For more information, see the Reference Guide: https://docs.launchdarkly.com/sdk/features/evaluating#go
func (client *LDClient) BoolVariationEx(
Copy link
Contributor

Choose a reason for hiding this comment

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

If the Ex methods are only differentiated by taking a Context, would you consider BoolVariationCtx instead as the convention?

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 considered Context and Ctx which I think make sense if your original function didn't also take a thing called Context. When I started calling them it seemed a little strange.

We could also add functional options right now as well, which would make them different, but I cannot think of any options to actually add. So they would be placeholder.

I could change to Ctx if you prefer.

Copy link
Contributor

Choose a reason for hiding this comment

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

To my Go-brain, Ctx seems intuitive and I would prefer it. If I was unfamiliar with the LD concept of context I'd immediately know this took a context.Context.

Copy link
Contributor

Choose a reason for hiding this comment

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

Side note: I think it'd be good to explain what the context is used for here. Like, the programmer might think "Ok, this takes a context, it must be a long running operation. Therefore if I want to end evaluation early, I should call context.Cancel()`.

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 did make a try at this, then I wondered if it would be a problem. If we decide we want to use the context for something, will it become a problem.

Maybe it wouldn't be a problem to specifically say that cancelling a context does not cancel an evaluation. Versus saying specifically what we use it for.

Base automatically changed from rlamb/implement-hook-types to feat/hooks March 28, 2024 22:07
@kinyoklion kinyoklion marked this pull request as ready for review March 28, 2024 22:13
@kinyoklion kinyoklion requested a review from a team March 28, 2024 22:13
@kinyoklion kinyoklion merged commit f93d96c into feat/hooks Mar 28, 2024
@kinyoklion kinyoklion deleted the rlamb/add-hooks-to-client branch March 28, 2024 22:54
kinyoklion added a commit that referenced this pull request Apr 3, 2024
Second PR.

This connects hooks to the ldclient.

It does not add the `Ex` methods to any interface, and it does not add
`AddHooks` to any interface.

---------

Co-authored-by: Casey Waldren <cwaldren@launchdarkly.com>
@github-actions github-actions bot mentioned this pull request Apr 3, 2024
kinyoklion added a commit that referenced this pull request Apr 3, 2024
🤖 I have created a release *beep* *boop*
---


##
[7.3.0](v7.2.0...v7.3.0)
(2024-04-03)

This release introduces a Hooks API. Hooks are collections of
user-defined callbacks that are executed by the SDK at various points of
interest. You can use them to augment the SDK with metrics or tracing.

### Features

* Add support for hooks.
([#126](#126))
([929ef8b](929ef8b))
* Implement supporting types for hooks.
([#125](#125))
([7f06147](7f06147))

---
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>
Co-authored-by: Ryan Lamb <4955475+kinyoklion@users.noreply.github.com>
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.

2 participants