Summary
Add explicit resource cleanup lifecycle (AutoCloseable / close()) to ScalekitClient and ScalekitAuthClient for correctness in non-singleton / short-lived usage scenarios.
Background
Flagged in PR #64 (#64 (comment)) during the HTTP connection eviction and gRPC keepalive fix.
Currently, ScalekitClient is intentionally used as a long-lived application-lifetime singleton, so OS reclaims resources on JVM exit. However, explicit lifecycle management is a best practice for SDK clients and would support:
- Short-lived or scoped usage (e.g., in tests or serverless contexts)
- Integration with DI frameworks (Spring, Guice) that manage bean lifecycles
- Preventing resource retention in container environments with multiple reloads
Tasks
Requested by
@Avinash-Kamath
Summary
Add explicit resource cleanup lifecycle (
AutoCloseable/close()) toScalekitClientandScalekitAuthClientfor correctness in non-singleton / short-lived usage scenarios.Background
Flagged in PR #64 (#64 (comment)) during the HTTP connection eviction and gRPC keepalive fix.
Currently,
ScalekitClientis intentionally used as a long-lived application-lifetime singleton, so OS reclaims resources on JVM exit. However, explicit lifecycle management is a best practice for SDK clients and would support:Tasks
ScalekitAuthClientimplementAutoCloseable; addclose()that callshttpClient.close()and shuts down the underlyingPoolingHttpClientConnectionManagerManagedChannelinstance in a private field inScalekitClientinstead of a local variableScalekitClientimplementAutoCloseable; addclose()that shuts down the gRPC channel and closes the auth clientRequested by
@Avinash-Kamath