Skip to content

chore: add settlment modes - #3881

Merged
turip merged 1 commit into
mainfrom
chore/add-settlment-mode-types
Feb 19, 2026
Merged

turip merged 1 commit into
mainfrom
chore/add-settlment-mode-types

Conversation

@turip

@turip turip commented Feb 19, 2026 •

Copy link
Copy Markdown
Member

Overview

Add settlement modes for later use.

Summary by CodeRabbit

Release Notes

  • New Features
    • Added settlement mode configuration to the product catalog with three distinct billing options: invoice-only, credit-then-invoice, and credit-only settlement methods.

@turip
turip requested a review from a team as a code owner February 19, 2026 09:46
@coderabbitai

coderabbitai Bot commented Feb 19, 2026 •

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

A new SettlementMode type is introduced in the productcatalog package with three predefined settlement modes (invoice_only, credit_then_invoice, credit_only), along with Values() and Validate() methods for retrieving valid modes and validating current values.

Changes

Cohort / File(s) Summary
Settlement Mode Type Definition
openmeter/productcatalog/settlementmode.go
Introduces SettlementMode type with three constants, a Values() method returning all valid settlement mode strings, and a Validate() method to verify the current value is in the allowed set.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title mentions 'settlment modes' but contains a typo ('settlment' instead of 'settlement'), and while it refers to the actual change in the PR, it's slightly imprecise.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch chore/add-settlment-mode-types

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@turip turip added the release-note/ignore Ignore this change when generating release notes label Feb 19, 2026
@turip
turip enabled auto-merge (squash) February 19, 2026 09:47
@turip
turip requested review from GAlexIHU and tothandras February 19, 2026 09:47

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
openmeter/productcatalog/settlementmode.go (1)

16-22: Consider a package-level variable for the valid values to avoid repeated slice allocation.

Right now, every Validate() call goes through s.Values(), which allocates a fresh []string on the heap each time. Since the set is fixed and small, you could lift it to a package-level variable and have Values() return that instead:

♻️ Suggested refactor
+var settlementModeValues = []string{
+	string(InvoiceOnlySettlementMode),
+	string(CreditThenInvoiceSettlementMode),
+	string(CreditOnlySettlementMode),
+}
+
 func (s SettlementMode) Values() []string {
-	return []string{
-		string(InvoiceOnlySettlementMode),
-		string(CreditThenInvoiceSettlementMode),
-		string(CreditOnlySettlementMode),
-	}
+	return settlementModeValues
 }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@openmeter/productcatalog/settlementmode.go` around lines 16 - 22, The
Values() method currently allocates a new []string slice on each call; refactor
by introducing a package-level variable (e.g., validSettlementModeValues)
initialized once with string(InvoiceOnlySettlementMode),
string(CreditThenInvoiceSettlementMode), string(CreditOnlySettlementMode), and
change SettlementMode.Values() to return that variable (or a slice reference) so
Validate() and other callers reuse the same slice instead of allocating
repeatedly. Ensure the variable is immutable (unexported) and used by Values(),
Validate(), and any other code referencing the list.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@openmeter/productcatalog/settlementmode.go`:
- Around line 16-22: The Values() method currently allocates a new []string
slice on each call; refactor by introducing a package-level variable (e.g.,
validSettlementModeValues) initialized once with
string(InvoiceOnlySettlementMode), string(CreditThenInvoiceSettlementMode),
string(CreditOnlySettlementMode), and change SettlementMode.Values() to return
that variable (or a slice reference) so Validate() and other callers reuse the
same slice instead of allocating repeatedly. Ensure the variable is immutable
(unexported) and used by Values(), Validate(), and any other code referencing
the list.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release-note/ignore Ignore this change when generating release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants