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

Separate env and kafka packages #183

Merged
merged 12 commits into from
Jul 25, 2024
Merged

Separate env and kafka packages #183

merged 12 commits into from
Jul 25, 2024

Conversation

chris-martin
Copy link
Contributor

@chris-martin chris-martin commented Jul 25, 2024

We've discussed breaking up freckle-app but not in much concrete detail, so this may be more a proposal than necessarily a finished task. Often I find I just have to start working on something like this to figure out where the right splits are.

I think one fairly sure goal is to be able to stop installing Kafka on services that don't need it, so I took a look at how coupled our Kafka modules are to the rest of freckle-app and tried pulling it out into a freckle-kafka package. I guess it could depend on freckle-app, but I went a step further here and completely decoupled them so neither depends on the other.

Probably a separate repository would be warranted, but doing the refactor all in this repo is easy. Didn't give much thought to the package names, can change them to whatever folks prefer. Modules names could also be reconsidered.

The dependencies of the kafka code on the rest of freckle-app were:

  • Freckle.App.Prelude - this was easily replaced by Relude.
  • Freckle.App.Env - to write definitions for environment variable parsers; this includes our own Timeout type, which makes dropping down to the underlying envparse library not an attractive option. This prompted an additional package, freckle-env, which in this PR freckle-app reexports to avoid any change for users.
  • Freckle.App.Exception - this was replaced by dropping down to the underlying annotated-exception library, though I copied the definition of annotatedExceptionMessageFrom into freckle-kafka.
  • Yesod.Core.Lens - Inlined trivial lens definitions envL and siteL.
  • Freckle.App.OpenTelemetry - dropped down to the underlying hs-opentelemetry-sdk package, with producerSpanArguments and consumerSpanArguments being trivial inlines.
  • Freckle.App.Async - I avoided these dependencies by pushing the forking responsibility onto downstream users, though the changes to upgrade are trivial. produceKeyedOnAsync just applies void . async, and runConsumer just applies withTraceContext . immortalCreateLogged. These are noted in the changelog.

@chris-martin chris-martin requested review from pbrisbin and z0isch July 25, 2024 17:53
@chris-martin chris-martin force-pushed the chris/kafka-2 branch 2 times, most recently from cdfb2a9 to c299cc8 Compare July 25, 2024 18:00
Copy link
Member

@pbrisbin pbrisbin left a comment

Choose a reason for hiding this comment

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

I like it.

  • freckle-env, I'd really like to get away from this. Freckle.App.Env was created at a time envparse lacked a lot of things, so much so the the module fully implemented everything. Since then we've replaced its internals with envparse plus some things, and started working to upstream those things to envparse. I wonder if they'd accept everything we have here. Until such time, I think freckle-env a fine enough name. The only other thing that comes to mind is envparse-extra, which piggy backs on the convention of wai-extra or conduit-extra.
  • freckle-kafka since you've made this entirely independent, it probably makes sense to not call this freckle-, but I don't really know what other distinguishing features it has 🤔

@chris-martin
Copy link
Contributor Author

I wonder if they'd accept everything we have here.

I'll try a little. supki/envparse#24

@chris-martin chris-martin merged commit 2e7185b into main Jul 25, 2024
6 checks passed
@chris-martin chris-martin deleted the chris/kafka-2 branch July 25, 2024 19:00
This was referenced Jul 25, 2024
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