carpool-service/storage/storage.go

30 lines
746 B
Go
Raw Normal View History

2023-03-27 18:54:56 +00:00
package storage
import (
"fmt"
"github.com/paulmach/orb/geojson"
"github.com/spf13/viper"
)
type Storage interface {
CreateRegularRoutes([]*geojson.FeatureCollection) error
GetUserRegularRoutes(userid string) ([]*geojson.FeatureCollection, error)
2023-03-29 10:50:25 +00:00
GetDriverRegularRoutesForTile(day string, gridId int64) ([]*geojson.FeatureCollection, error)
GetPassengerRegularRoutesForTile(day string, gridId int64) ([]*geojson.FeatureCollection, error)
2023-03-27 18:54:56 +00:00
}
func NewStorage(cfg *viper.Viper) (Storage, error) {
var (
storage_type = cfg.GetString("storage.db.type")
)
switch storage_type {
case "mongodb":
s, err := NewMongoDBStorage(cfg)
return s, err
default:
return nil, fmt.Errorf("storage type %v is not supported", storage_type)
}
}