State-Management Functionality
The functionality required for state management naturally depends on the project's requirements for state management. In the simplest case, the import process receives the data and saves its status. A second asynchronous process then sends the IMPORTED data to the target system and sets its status to SUCCESS or FAILED (separated import and update processes).
The first function we need, of course, is saveState( payload, newState).
Save state will actually be split into updateState( id, state) and createState( playload, initialState). The payload represents the received data from the customer and it should be immutable once the state has been created. Create state returns the id that is used in later context to update an existing state.
The second function that is needed is fetchStates( state) to fetch all records with a certain state.
Get, Query and Fetch
Get returns a single record (by id). It is expected that this record exists. Otherwise, an exception is thrown.
Query returns 0..n record ids using any number of query parameters. After querying records you can get each record's data.
Fetch is a combination of query and get and it allows you the query records to return the full records (incl. payload).
Example: Files in a directory: the filename is the id which you can use to get (read) a file's content. You can query filenames to list files matching a filter, or you can fetch files to read the content of all files of a filtered file list.
Your requirements on state-management will probably be more complex than these two basic function.
Last updated