PushProx icon indicating copy to clipboard operation
PushProx copied to clipboard

move the client logic out of main pkg so it can be reused.

Open SagiROosto opened this issue 1 year ago • 4 comments

Summary

This PR refactors the Prometheus Pushprox client to move its core logic outside the main package, enabling it to be reused as a library in other projects. The primary motivation behind this change is to allow projects to integrate the proxy client directly into existing components, reducing the resource footprint significantly compared to running it as a standalone Docker container or binary.

Motivation

The original implementation of the Pushprox client was designed to run as a dedicated Docker container or a binary. While this works well in many scenarios, it introduces unnecessary overhead for projects that already have a metrics or health component and simply need to integrate the proxy client.

In my use case—likely shared by many others, especially in resource-constrained environments such as IoT devices—this overhead is critical. Running the client as part of an existing component saves resources and simplifies deployment without sacrificing functionality.

Changes

  • Extracted the core logic of the Pushprox client into a separate, reusable package.
  • Added context to the client so it can be easily cancelled and stopped by caller decision.

Benefits

  • Reusability: Developers can import the Pushprox client logic directly into their applications, avoiding the need for an additional Docker container or binary process.
  • Reduced Resource Footprint: In environments where resources are limited (e.g., IoT devices), integrating the client directly into existing components minimizes overhead.
  • Flexibility: Projects can now tailor the client's behavior to fit their specific needs, enhancing adaptability across diverse use cases.
  • Backward Compatibility: The original containerized and binary workflows remain intact, ensuring no disruption for existing users. In fact, no actual logical change was made to anyone uses the current workflow/client.

Impact

  • No breaking changes for users leveraging the existing Docker or binary setup.
  • Adds a new pathway for integrating the Pushprox client, expanding the utility of the project.

SagiROosto avatar Nov 26 '24 14:11 SagiROosto

hey @SuperQ, can you take a look?

SagiROosto avatar Jan 09 '25 11:01 SagiROosto

Happy Birthday to the PR 🎂🥳 @SuperQ can you help progressing this PR and hopefully merge if the PR OK?

SagiROosto avatar Nov 26 '25 10:11 SagiROosto

Seems mostly fine. A couple questions.

SuperQ avatar Nov 26 '25 11:11 SuperQ

@SuperQ yea you got a point I reverted these odd changes and now it simply work as expected

SagiROosto avatar Nov 27 '25 14:11 SagiROosto