You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Layers are currently required to implement UpdateConfiguration(config *common.Config) common.LayerError, and in addition Dataset(dataset string) (common.Dataset, common.LayerError).
The reason for this is that the specific implementation details of a layer dataset cannot be known to the common framework.
Given that a typical implementation of UpdateConfiguration looks like this:
func (dl *SomeDatalayer) UpdateConfiguration(config *common.Config) common.LayerError {
existingDatasets := map[string]bool{}
// update existing datasets
for k, v := range dl.datasets {
for _, dsd := range config.DatasetDefinitions {
if k == dsd.DatasetName {
existingDatasets[k] = true
v.datasetDefinition = dsd
}
}
}
// remove deleted datasets
for k := range dl.datasets {
if _, found := existingDatasets[k]; !found {
delete(dl.datasets, k)
}
}
// add new datasets
for _, dsd := range config.DatasetDefinitions {
if _, found := existingDatasets[dsd.DatasetName]; !found {
dl.datasets[dsd.DatasetName] = &Dataset{
logger: dl.logger,
db: dl.db,
datasetDefinition: dsd,
}
}
}
return nil
}
and a typical Dataset implementation looks like this
func (dl *SomeDatalayer) Dataset(dataset string) (common.Dataset, common.LayerError) {
ds, found := dl.datasets[dataset]
if found {
return ds, nil
}
return nil, ErrDatasetNotFound(dataset)
}
... it seems that all the layer really should need to provide is how to map a DatasetDefinition to a custom Dataset instance. And then the common framework can provide UpdateConfiguration and a Dataset impl under the hood.
The framework can then also automatically call UpdateConfiguration as part of the bootstap invocation, currently users have to remember to call it once as part of their layer constructor.
The text was updated successfully, but these errors were encountered:
Layers are currently required to implement
UpdateConfiguration(config *common.Config) common.LayerError
, and in additionDataset(dataset string) (common.Dataset, common.LayerError)
.The reason for this is that the specific implementation details of a layer dataset cannot be known to the common framework.
Given that a typical implementation of
UpdateConfiguration
looks like this:and a typical
Dataset
implementation looks like this... it seems that all the layer really should need to provide is how to map a DatasetDefinition to a custom Dataset instance. And then the common framework can provide
UpdateConfiguration
and aDataset
impl under the hood.The framework can then also automatically call
UpdateConfiguration
as part of the bootstap invocation, currently users have to remember to call it once as part of their layer constructor.The text was updated successfully, but these errors were encountered: