samedi 8 septembre 2018

Design pattern for providing data with custom parameters

I am trying to design a framework that allows various workers to request values from a central data source given arbitrary parameters. Consider the following:

A worker requests the current value of a moving average calculated from the previous 7 time periods. It does so by passing the following to some central data source or provider:

{ 
  Name: 'MovingAverage',
  Parameters: {
    Periods: 7,
    RemoveBias: true,
  }
}

The central data source / provider has MovingAverage registered in some manner, along with the acceptable range of parameters that can be used in the calculation of the moving average. Given what was passed, the data source calculates the moving average with the specified parameters and passes the result back to the worker.

This seems fairly straightforward in theory, but I am having a hard time figuring out how to architect something like this.

I am wondering if there are any established design patterns or open-source examples that implement something like this so that I can study them and implement them into my project.

Aucun commentaire:

Enregistrer un commentaire