Skip to content

feat(dapi): add method to retrieve all non-banned endpoints - #3072

Merged
lklimek merged 2 commits into
v3.1-devfrom
feat/dapi-get-all-addresses
Feb 9, 2026
Merged

lklimek merged 2 commits into
v3.1-devfrom
feat/dapi-get-all-addresses

Conversation

@lklimek

@lklimek lklimek commented Feb 9, 2026 •

Copy link
Copy Markdown
Contributor

Issue being fixed or feature implemented

Need ability to read all non-banned endpoints in DAPI client for monitoring, diagnostics, and custom load balancing strategies.

What was done?

Added public API to get all non-banned addresses from DAPI client:

  • AddressList::get_live_addresses() - returns Vec<Address> with all
    non-banned addresses
  • DapiClient::get_live_addresses() - convenience method at DapiClient
    level that delegates to AddressList
  • Uses same filtering logic as get_live_address() - checks if
    banned_until < now or ban has not been set
  • Added comprehensive documentation with usage examples

How Has This Been Tested?

Added 5 unit tests covering all scenarios:

  • Empty address list
  • All addresses unbanned
  • Some addresses banned
  • All addresses banned
  • Addresses unbanned after previous ban

All tests pass. Verified with:

  • cargo test -p rs-dapi-client
  • cargo check -p rs-dapi-client
  • cargo clippy -p rs-dapi-client

Breaking Changes

None. This is a purely additive change that introduces new public methods without modifying existing behavior.

Co-Authored-By: Claude Sonnet 4.5 [email protected]

Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added or updated relevant unit/integration/functional/e2e tests
  • I have added "!" to the title and described breaking changes in the corresponding section if my code contains any
  • I have made corresponding changes to the documentation if needed

For repository code-owners and collaborators only

  • I have assigned this pull request to a milestone

Summary by CodeRabbit

  • New Features

    • Added get_live_addresses() method to retrieve all currently active addresses in batch, complementing the existing single-address lookup functionality.
  • Tests

    • Added comprehensive unit tests covering various address states and ban expiration scenarios.

## Issue being fixed or feature implemented

Need ability to read all non-banned endpoints in DAPI client for
monitoring, diagnostics, and custom load balancing strategies.

## What was done?

Added public API to get all non-banned addresses from DAPI client:

- `AddressList::get_live_addresses()` - returns `Vec<Address>` with all
  non-banned addresses
- `DapiClient::get_live_addresses()` - convenience method at DapiClient
  level that delegates to AddressList
- Uses same filtering logic as `get_live_address()` - checks if
  `banned_until < now` or ban has not been set
- Added comprehensive documentation with usage examples

## How Has This Been Tested?

Added 5 unit tests covering all scenarios:
- Empty address list
- All addresses unbanned
- Some addresses banned
- All addresses banned
- Addresses unbanned after previous ban

All tests pass. Verified with:
- `cargo test -p rs-dapi-client`
- `cargo check -p rs-dapi-client`
- `cargo clippy -p rs-dapi-client`

## Breaking Changes

None. This is a purely additive change that introduces new public methods
without modifying existing behavior.

Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
@github-actions github-actions Bot added this to the v3.1.0 milestone Feb 9, 2026
@coderabbitai

coderabbitai Bot commented Feb 9, 2026 •

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

Two new public methods added to retrieve all live (non-banned) addresses: AddressList::get_live_addresses() returns all non-banned addresses with accompanying unit tests, and DapiClient::get_live_addresses() delegates to the address list method.

Changes

Cohort / File(s) Summary
Core Address List
packages/rs-dapi-client/src/address_list.rs
Added get_live_addresses() method that filters and returns all addresses not currently banned, using existing ban-expiry logic. Includes comprehensive unit test module covering empty lists, unbanned/banned/all-banned scenarios.
Client Delegation
packages/rs-dapi-client/src/dapi_client.rs
Added public get_live_addresses() method that delegates to the address list implementation, with documentation and usage examples.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 Hops of joy! A new method hops into view,
get_live_addresses() returns the healthy crew,
No bans, no delays—just addresses so true,
From AddressList to Client, the delegation shines through! ✨

🚥 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 pull request title clearly and specifically summarizes the main change: adding a method to retrieve all non-banned endpoints in the DAPI client, which directly aligns with the changeset.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ 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 feat/dapi-get-all-addresses

No actionable comments were generated in the recent review. 🎉

🧹 Recent nitpick comments
packages/rs-dapi-client/src/address_list.rs (1)

252-267: Extract the shared "is live" filter to reduce duplication.

The filter closure on lines 257–264 is identical to the one in get_live_address (lines 221–228). Consider extracting a helper (e.g., AddressStatus::is_live(&self, now: …) -> bool or a private method returning an iterator of live addresses) so both methods share a single source of truth for the liveness predicate.

♻️ Suggested helper approach
+impl AddressStatus {
+    fn is_live(&self, now: chrono::DateTime<Utc>) -> bool {
+        self.banned_until
+            .map(|banned_until| banned_until < now)
+            .unwrap_or(true)
+    }
+}

Then both methods simplify to:

// get_live_address
guard.iter()
    .filter(|(_, status)| status.is_live(now))
    .choose(&mut rng)
    .map(|(addr, _)| addr.clone())

// get_live_addresses
guard.iter()
    .filter(|(_, status)| status.is_live(now))
    .map(|(addr, _)| addr.clone())
    .collect()

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.

@lklimek
lklimek requested a review from shumkov February 9, 2026 12:36

@shumkov shumkov left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

👍

@lklimek

lklimek commented Feb 9, 2026

Copy link
Copy Markdown
Contributor Author

CI errors are unrelated.

@lklimek
lklimek merged commit 5e4dc87 into v3.1-dev Feb 9, 2026
42 of 45 checks passed
@lklimek
lklimek deleted the feat/dapi-get-all-addresses branch February 9, 2026 17:10
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