Skip to content

Commit

Permalink
feat: database/datasource: add DataSourceSet{}
Browse files Browse the repository at this point in the history
  • Loading branch information
grokify committed Oct 28, 2023
1 parent 944ea45 commit 112083a
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions database/datasource/datasource_set.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package datasource

import (
"fmt"

"github.com/grokify/mogo/type/maputil"
)

type DataSourceSet struct {
Data map[string]DataSource
}

func (dss DataSourceSet) GetDataSource(key string) (DataSource, error) {
if ds, ok := dss.Data[key]; ok {
return ds, nil
}
return DataSource{}, fmt.Errorf("key not found (%s)", key)
}

func (dss DataSourceSet) Keys() []string {
return maputil.Keys(dss.Data)
}

0 comments on commit 112083a

Please sign in to comment.