Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Design an "Internal Service State" facility #789

Open
jsync-swirlds opened this issue Mar 6, 2025 · 0 comments
Open

Design an "Internal Service State" facility #789

jsync-swirlds opened this issue Mar 6, 2025 · 0 comments

Comments

@jsync-swirlds
Copy link
Contributor

jsync-swirlds commented Mar 6, 2025

Goal

Design a facility for services to persistently store and retrieve data regarding internal service state.

Intention

The facility is intended to support values like the last block verified, or the oldest block persisted.
This data is intended to be stored and accessed as simple key-value pairs, and to persist between application restarts.
The facility is intended to offer a simple interface to store and read values.
We intend to offer a message-based interface at some point, but might not implement that initially.

Considerations

  • Why not store everything in the server status service
    • Each service, including third-party plugins, may need to determine independently what to store, when to store, and when to read data.
    • Server status may listen for data stores and reads to detect values it is interested in, but the services should manage their own values.
    • Having a general facility allows services better control without requiring changes to the Status Service to accommodate other services.
    • Mixing this function into server status needlessly complicates that service.
  • Why not have each service manage its own data storage
    • Allowing (or encouraging) each service to store these small data values independently invites all manner of unexpected storage mechanisms and unnecessarily adds complexity to our own services.
    • Having this facility does not constrain service developers, but does offer a useful common functionality.

Technical Details

A direct call interface might include the following

  • void storeValue(String keyName, String newValue) throws StoreFacilityException
  • String getValue(String keyName)
  • void removeValue(String keyName) throws StoreFacilityException

A message-based interface might include the following
Messages listened for

  • StoreValue[String keyName, String newValue]
  • RetrieveStoredValue[String keyName]
  • RemoveStoredValue[String keyName]
    Messages emitted
  • ValueRetrieved[String keyName, String retrievedValue]
  • ValueRemoved[String keyName, String removedValue]
  • ValueStored[String keyName, String StoredValue]
    Any entity (not just the requesting entity and facility) can listen for the store/stored or retrieve/retrieved pairs and update its own in-memory state to reflect things like last known block or price lists.
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

No branches or pull requests

1 participant