Skip to content

refactor(clickhouse): make retention a readonly constructor property#129

Open
levivannoort wants to merge 1 commit into
mainfrom
feat/retention-ttl
Open

refactor(clickhouse): make retention a readonly constructor property#129
levivannoort wants to merge 1 commit into
mainfrom
feat/retention-ttl

Conversation

@levivannoort

Copy link
Copy Markdown
Contributor

What

Follow-up to #128. Converts the ClickHouse retention config from a getRetention()/setRetention() accessor pair to a promoted public readonly ?int $retention constructor property.

  • Positive-days validation moves into the constructor body (same message, same behavior).
  • The fluent setter is dropped; retention is now set once at construction.

Why

Readonly-after-construction is coroutine-safe — no mid-flight mutation of adapter config. Aligns with the style we're standardizing across codebases.

Notes

Internal $this->retention usage in setup() is unchanged. Retention tests now build the adapter via the constructor and assert on the property.

🤖 Generated with Claude Code

Replace the getRetention/setRetention accessors with a promoted
public readonly ?int constructor property. The positive-days check
moves into the constructor body. Immutable-after-construction is
coroutine-safe; the fluent setter is dropped.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@greptile-apps

greptile-apps Bot commented Jul 8, 2026

Copy link
Copy Markdown

Greptile Summary

This PR completes a follow-up refactor by replacing the getRetention()/setRetention() accessor pair with a public readonly ?int $retention promoted constructor property, making the adapter's retention config immutable after construction. The positive-days validation and the internal $this->retention usage in setup() are both preserved correctly.

  • The private ?int $retention = null field declaration is removed; the promoted constructor property takes its place, and $this->retention references in setup() continue to work as expected.
  • setRetention() and getRetention() are dropped as a breaking change; callers must now pass retention at construction time.
  • Tests are updated to assert on ->retention directly and cover null default, positive value, zero rejection, and negative rejection — all prior edge cases remain tested.

Confidence Score: 5/5

Safe to merge — the change is a clean, well-scoped refactor with no altered runtime behaviour in setup().

The promoted readonly property is assigned before the constructor body runs, so the validation guard ($retention < 1) fires at the right time and the object is never returned to callers when invalid input is supplied. The $this->retention accesses in setup() are unaffected by the visibility change. All prior edge cases (null default, valid positive, zero, negative) are still exercised by the updated tests. No logic was changed, only the API surface.

No files require special attention.

Important Files Changed

Filename Overview
src/Audit/Adapter/ClickHouse.php Converts retention from a private field + getter/setter pair to a public readonly ?int promoted constructor property; validation and $this->retention usage in setup() are correctly preserved.
tests/Audit/Adapter/ClickHouseTest.php Tests updated to assert against ->retention directly and build the adapter via the constructor; zero and negative-day rejection tests are retained and cover the same edge cases as before.

Reviews (1): Last reviewed commit: "refactor(clickhouse): make retention a r..." | Re-trigger Greptile

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