fix: review findings + cache/quota performance refinements (v1.3.1)#3
Merged
Conversation
Review fixes (on top of v1.3.0): - name-resolver: drop reverse substring match (q.includes(name)) to avoid long queries collapsing onto short device names - expand: require cached device for setPosition so Curtain vs Blind Tilt dispatch is reliable; tighten setMode to Relay Switch* only; use startsWith for Blind Tilt to tolerate future variants - device-meta: validate version === '1' on load; atomic tmp+rename writes - plan: JSON Schema enforces deviceId/deviceName mutual exclusion, aligning with runtime validatePlan() behavior Cache/quota refinements: - cache: getCachedTypeMap() lets batch/watch skip the unnecessary GET /v1.1/devices when --ids already names the targets - cache: hot-cache for status cache (resetStatusCache for tests) - batch/watch: reuse a single axios client across a run - quota: debounced writes (250ms) + flush hooks on beforeExit/exit; SIGINT/SIGTERM handlers now exit with 130/143 after flushing - lib/devices: plumb ttlMs from read mode into setCachedStatus Tests updated for the new reset/flush hooks; 658/658 pass.
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.
Summary
expandrequires cached device for setPosition and restricts setMode to Relay Switch; device-meta validates schema version and writes atomically; plan JSON Schema enforcesdeviceId/deviceNamemutual exclusion.getCachedTypeMap()lets batch/watch skip the device-list round-trip when--idsis supplied; status cache gains a hot-cache (with a test reset); batch/watch reuse one axios client; quota writes are debounced (250ms) with flush hooks; SIGINT/SIGTERM now exit 130/143 after flushing.1.3.1withpackage-lock.jsonresynced.Test plan
npm run buildcleannpm test— 658/658 pass across 36 filesswitchbot devices batch turnOff --ids ID1,ID2 --dry-runissues noGET /v1.1/devicesswitchbot quota statusshows counts after a burst of calls and after a SIGINT