package storage import ( "fmt" "github.com/paulmach/orb/geojson" "github.com/spf13/viper" "solidarity-service/internal" ) type Storage interface { CreatePassenger(passenger internal.Passenger) (err error) GetPassenger(passengerID string) (passenger internal.Passenger, err error) GetAllPassengers() (passengers []internal.Passenger, err error) CreateDriver(driver internal.Driver) (err error) GetDriver(driverID string) (driver internal.Driver, err error) GetBooking(id string) (booking internal.Booking, err error) CreateBooking(booking internal.BookingRequest) (err error) UpdateBookingStatus(id string, status internal.BookingStatus) (err error) FilterUserBookingsByStatus(user_type string, status internal.BookingStatus, user_id string) (bookings []internal.Booking, err error) DriverJourneys(departure_route *geojson.Feature, departure_date int64) (drivers []internal.Driver, err error) GetAllDrivers(date int64) (drivers []internal.Driver, err error) } func NewStorage(cfg *viper.Viper) (Storage, error) { var ( storage_type = cfg.GetString("storage.db.type") ) switch storage_type { case "psql": s, err := NewPostgresqlStorage(cfg) return s, err default: return nil, fmt.Errorf("storage type %v is not supported", storage_type) } }