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

Proposal: Extract main package logic into a dedicated function #931

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

xico42
Copy link

@xico42 xico42 commented Oct 9, 2024

In the use case for the company I work for, the krakend plugins are built in docker.

The final artifact used for deploying krakend is a docker image containing the krakend binary plus the custom plugins. So in this scenario, I could have a better control of dependencies versions by building both krakend and my custom plugins together.

As an example of how this could be useful, we have an internal library that we would like to use in our custom plugins. However, that library had defined OTEL version to 1.29, and we couldn't use it because the krakend binary has it fixed at 1.28.

We would probably have 2 options for this. The first one could be building krakend by ourselves, making it sure that both the plugins and krakend share the exact same version, by building them together and putting them in the same go module. The second approach would be downgrading the dependency specification in our internal library.

The second option imposes a challenge, because those are 2 different repos, so we reached for the first one (buildling both the plugins and krakend together).

To make this possible, all we had to do is copy/sync the contents of main.go. But this involves making sure that our "main.go" version is always compatible with future versions of krakend.

By moving that logic into an importable function, this process is greatly simplified.

The main function of the main package that builds the krakend binary
contains too much logic, witch makes it a bit harder for users to build
krakend by themselves.

This commit extracts the orchestration done by the main function into
`krakend.Main`. This way, the main package is greatly simplified, making
it easier for clients to build the krakend binary.
@xico42
Copy link
Author

xico42 commented Oct 9, 2024

As a side note, I could recall other toolings that have a similar approach:

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.

1 participant