[go: up one dir, main page]

Node: exposes http cache header tools

What

Exposes the http cache headers tools from node.

Why

We need to calculate the start of next level (which is the expected time the current round should end) to tell the cache when it should invalidate the query of head block. This MR will be useful when implementing the http cache header for max-age.

Relative (head-n) queries are always changing which creates friction for integrating Octez RPCs with generic Caches as operators needs extra logic/heuristics to know when to invalidate such a response. To get around this, we introduce relevant HTTP Cache headers into the responses of Octez RPCs. The headers to be implemented are max-age and ETag with If-None-Modified. This is an ongoing work with multiple MRs.

How

We expose a set of tools that the rpc middleware will use. The tools abstract away the node and store to the caller. Currently, only has 1 function - get_estimated_time_to_next_level - but will have more in future MRs.

The estimated time to next level is the difference between the round end time and current time.

The calculation of round end time is exposed from a proto plugin so that we can leverage some useful helper functions. The plugin function itself takes a context maker and uses it the first time the function is called to get the constants. After that, the constants are cached and re-used from subsequent calls. When a new protocol is realised, that instance of the plugin should have an empty constant cache that is ready to be filled with the constants of that protocol.

Manually testing the MR

Checklist

  • Document the interface of any function added or modified (see the coding guidelines)
  • Document any change to the user interface, including configuration parameters (see node configuration)
  • Provide automatic testing (see the testing guide).
  • For new features and bug fixes, add an item in the appropriate changelog (docs/protocols/alpha.rst for the protocol and the environment, CHANGES.rst at the root of the repository for everything else).
  • Select suitable reviewers using the Reviewers field below.
  • Select as Assignee the next person who should take action on that MR

Merge request reports

Loading