PostHog / posthog-go

Official PostHog Go library
MIT License
20 stars 17 forks source link

Add Feature Flags #2

Closed yakkomajuri closed 3 years ago

yakkomajuri commented 3 years ago

WIP because it's missing tests and could probably use some cleaning up given I'm not a Go dev by trade :D Errors also need better descriptors, etc.

Everything works though with manual testing.

What this does

Mostly just adds feature flags, but also fixes broken tests and a few minor issues here and there.

No refactor here though, there's probably a few things that could benefit from it.

Approach

Everything follows the proposed spec: https://github.com/PostHog/posthog.com/pull/1455

What's unique to Go specifically is the approach to the poller. It leverages a goroutine to run the poller concurrently and send some messages back and forth via channels for reloading and shutting down.

The mutex here is actually not needed but it seems to be best practice in the Go community to add it in for future-proofing if another goroutine is ever introduced that updates the same value.

To Do

yakkomajuri commented 3 years ago

All addressed @fuziontech