Skip to content

Make get_app lock-free via ETS, run OAuth refresh in Tasks#27

Open
wawashra wants to merge 1 commit into
mainfrom
non-blocking-client-cache
Open

Make get_app lock-free via ETS, run OAuth refresh in Tasks#27
wawashra wants to merge 1 commit into
mainfrom
non-blocking-client-cache

Conversation

@wawashra
Copy link
Copy Markdown

@wawashra wawashra commented May 25, 2026

Eliminates GenServer.call timeouts on get_app/1 and refresh stampedes.

Problem

Singleton Salesforce GenServer did synchronous HTTPS inside init/handle_call/handle_info, so every tenant's :get_app was head-of-line-blocked behind OAuth refreshes and timed out at 5s.

Fix

Per-app %{client, config} now lives in a public ETS table → get_app/1 is a lock-free :ets.lookup/2. All HTTPS (register, refresh, periodic) runs in unlinked Tasks that write ETS directly and self-schedule the next refresh.

Other changes

init/1 returns instantly; initial refresh fires from handle_continue in parallel. Refresh interval jittered 2h ± 7.5m; errors retry in 5m instead of falling off the schedule. Atom-leak from String.to_atom(app_token) removed.

Eliminates GenServer.call timeouts on get_app/1 and refresh stampedes.
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