feat: 일일 토큰 한도 집행 - #51
Merged
Merged
Conversation
The granted daily figure lived only in the record of what was decided. The approval screen said a limit had been granted; nothing carried it to the key, the gateway has no daily concept at all, and so nothing enforced it. Both parties believed a limit was in place. The api counts and the gateway refuses, as the internal contract already specified: short-window limits belong where request start and end are observed, but a day's running total would need durable per-key state the gateway was built not to have -- and every usage event arrives here anyway. The flag is a column rather than something computed inside the sync query, and that is the load-bearing choice. The gateway is handed a document only when the generation moves, and only a write moves it. A quota computed at read time would be perfectly correct in the database and would never once reach the gateway. Which also means bumping only when a row actually changed: an unconditional sweep would hand out a full document every five minutes forever, defeating the unchanged path. Both directions are covered by tests because both fail silently. Midnight needs no separate reset -- after 00:00 KST the day's sum is zero and the ordinary sweep clears what it set. That is why the sweep must keep running while nothing is being used: it is what releases a key, not what locks one. Enforcement lags by a shipping window plus a poll, so a key can overshoot by roughly one batch. That is inherent to counting after the fact.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
📝 작업내용
⭐️ 검증
💬 리뷰 포인트