Skip to content
This repository has been archived by the owner on May 10, 2018. It is now read-only.

Managed responses system #1

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

Conversation

uuf6429
Copy link
Owner

@uuf6429 uuf6429 commented Apr 2, 2017

Managed / Tracked Responses

Problem Description

Currently the JS server makes heavy use of global variables or variables shared across RPC calls, especially response variables.
This produces a whole host of problems, for example a slow async process might interfere with a more recent async process by overwriting response variables causing an early return with the wrong payload data. Moreover, as it is, it's very difficult to figure out who did what and why a particular payload is returned.

Solution

A having a sort of registry of responses. This registry should be cleaned automatically. Example of use:

--> client requests visiting URL
<-- server creates empty payload and returns the newly created payload_id
--> client repeatedly polls the server with the payload_id
--- when servers finally receives confirmation that new page was loaded updates payload content
<-- on next client polling for payload_id, server returns payload and removes it from registry

At some points the server should do some maintenance to the payload registry:

  • delete very old payloads (pending and resolved payloads)
  • disallow requests when number of payloads exceed a certain value
  • if the payload_id is an incremental index, reset it at some point

Things to Consider

  • What should the payload_id be? Possible candidates:
    • incremental number (needs to be reset eventually)
    • timestamp (Date.now() for ms or process.hrtime() for μs)
    • UUID v4, via node-uuid
  • What's the maximum number of allowed payloads?
    • maybe the limit should be computed relatively to memory usage and payload count
  • What's the time limit when payloads should be purged, irrelevant of their state?
  • Should we clean up payloads periodically or remove the payload immediately when after it's requested by the client?

@codecov
Copy link

codecov bot commented Apr 2, 2017

Codecov Report

Merging #1 into master will decrease coverage by 75.89%.
The diff coverage is 1.34%.

@@             Coverage Diff             @@
##             master      #1      +/-   ##
===========================================
- Coverage     85.35%   9.45%   -75.9%     
- Complexity      120     165      +45     
===========================================
  Files             1       2       +1     
  Lines           355     603     +248     
===========================================
- Hits            303      57     -246     
- Misses           52     546     +494

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 443bc48...6a16bc1. Read the comment docs.

@uuf6429 uuf6429 closed this Apr 2, 2017
@uuf6429 uuf6429 reopened this Apr 2, 2017
@uuf6429 uuf6429 force-pushed the master branch 7 times, most recently from 1c0fcd3 to 7b93d5c Compare April 10, 2017 18:42
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant