launchdarkly / go-server-sdk

LaunchDarkly Server-side SDK for Go
Other
40 stars 17 forks source link

feat: Implement supporting types for hooks. #125

Closed kinyoklion closed 3 months ago

kinyoklion commented 3 months ago

This PR should be reviewed before other hooks PRs.

This PR adds supporting types for hooks, but does not use them from the client.

kinyoklion commented 3 months ago

I am going to make a couple changes.

  1. Skip execution when no hooks registered.
  2. ldvalue.CopyArbitraryValue(defaultValue) is allocating. If I run the benchmark with that line I get 1 alloc per op. If I remove it I get 0. So I need to look at that. Removed the need for this.
kinyoklion commented 3 months ago

I am going to make a couple changes.

  1. Skip execution when no hooks registered.
  2. ~ldvalue.CopyArbitraryValue(defaultValue) is allocating. If I run the benchmark with that line I get 1 alloc per op. If I remove it I get 0. So I need to look at that.~ Removed the need for this.

I am not sure there would actually be any tangible benefit to 1, at least with the ability to dynamically register hooks.

In node I was able to avoid the micro-task queue, but in Go I would incur the lock to check regardless and that would be the most expensive part.