Skip to content

feat: [SDK-5502] send sessions API requests on their own queue - #2786

Closed
fadi-george wants to merge 3 commits into
mainfrom
fadi/sdk-5502
Closed

fadi-george wants to merge 3 commits into
mainfrom
fadi/sdk-5502

Conversation

@fadi-george

Copy link
Copy Markdown
Contributor

Description

One Line Summary

Experiment: send sessions API requests on their own small queue instead of through OperationRepo.

Details

Motivation

Compare against the #2777 / #2780 / #2781 stack. A failing sessions request in OperationRepo blocks user and subscription operations, and the stack needs about 300 lines of shared OperationRepo changes. This keeps sessions fully separate.

Size (excluding #2774 / #2775):

Code Tests OperationRepo changes
Stack +734 / -90 +1234 / -136 +300
This PR +553 / -79 +484 / -102 0

Scope

  • One persisted record per session: the create, plus the latest unsent update. A newer update replaces an unsent one, and an end is final.
  • Idempotency keys are reused on retry, including after a restart.
  • Backoff 5s doubling to 300s with jitter. Retry-After is honored (capped at 1h). A request is dropped after 5 answered failures or a non-retryable 4xx. Network errors don't count.
  • Retries on foreground, and on network available while foregrounded.
  • Waits for backend user and subscription IDs. Records with a local ID that is no longer current are dropped. This replaces the pinned IDs on SessionModel.
  • Ending a session in the background job sends the end right away, limited to 30s.
  • Behind the sessions v2 flag. No change when it is off.

OPTIONAL - Other

Testing

Unit testing

  • SessionsApiQueueTests: merging, retries and keys, drop rules, backoff sequence, Retry-After, cap, local ID handling.
  • SessionServiceTests: create, background end + flush, end time after kill, flag off, cold start ordering.
  • Full core suite, spotless, detekt and assembleRelease pass.

Manual testing

Not tested on a device yet.

Affected code checklist

  • Notifications
    • Display
    • Open
    • Push Processing
    • Confirm Deliveries
  • Outcomes
  • Sessions
  • In-App Messaging
  • REST API requests
  • Public API changes

Checklist

Overview

  • I have filled out all REQUIRED sections above
  • PR does one thing
  • Any Public API changes are explained in the PR details and conform to existing APIs

Testing

  • I have included test coverage for these changes, or explained why they are not needed
  • All automated tests pass, or I explained why that is not possible
  • I have personally tested this on my device, or explained why that is not possible

Final pass

  • Code is as readable as possible.
  • I have reviewed this PR myself, ensuring it meets each checklist item

🤖 Generated with Claude Code

fadi-george and others added 3 commits October 12, 2026 15:15
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Session create and end requests go through a small persisted queue outside
OperationRepo, so a sessions outage never delays user or subscription
operations. One record per session holds the create and the latest unsent
update, with idempotency keys reused on retry, backoff with jitter,
Retry-After, an attempt cap, and retry on foreground and network return.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown
Contributor

📊 Diff Coverage Report

Diff Coverage Report (Changed Lines Only)

Gate: aggregate coverage on changed executable lines must be ≥ 80% (JaCoCo line data for lines touched in the diff).

Changed Files Coverage

  • Time.kt: 1/1 touched executable lines (100.0%) (2 touched lines in diff)
  • OneSignalImp.kt: 1/1 touched executable lines (100.0%) (2 touched lines in diff)
  • ⚠️ SessionModule.kt: Not in coverage report (may not be compiled/tested)
  • SessionModel.kt: 9/9 touched executable lines (100.0%) (32 touched lines in diff)
  • ISessionsBackendService.kt: 15/15 touched executable lines (100.0%) (48 touched lines in diff)
  • SessionsBackendService.kt: 35/35 touched executable lines (100.0%) (71 touched lines in diff)
  • SessionService.kt: 38/39 touched executable lines (97.4%) (70 touched lines in diff)
  • ISessionsApiQueue.kt: 2/2 touched executable lines (100.0%) (29 touched lines in diff)
  • SessionRecord.kt: 24/24 touched executable lines (100.0%) (63 touched lines in diff)
  • SessionsApiBackoff.kt: 16/16 touched executable lines (100.0%) (55 touched lines in diff)
  • SessionsApiQueue.kt: 81/84 touched executable lines (96.4%) (177 touched lines in diff)
  • SessionsApiRetryTrigger.kt: 15/18 touched executable lines (83.3%) (43 touched lines in diff)
  • SessionsApiSender.kt: 69/71 touched executable lines (97.2%) (139 touched lines in diff)
  • AppIdResolution.kt: 5/5 touched executable lines (100.0%) (15 touched lines in diff)
  • ⚠️ MockHelper.kt: Not in coverage report (may not be compiled/tested)

Overall (aggregate gate)

311/320 touched executable lines covered (97.2% — requires ≥ 80%)

📥 View workflow run

@fadi-george

Copy link
Copy Markdown
Contributor Author

Closing in favor of fixing OperationRepo retry for all ops (SDK-5535).

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.

1 participant