mirror of
https://github.com/Luzifer/ots.git
synced 2024-12-17 19:44:36 -05:00
27 lines
482 B
Go
27 lines
482 B
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/Luzifer/ots/pkg/storage"
|
|
"github.com/Luzifer/ots/pkg/storage/memory"
|
|
"github.com/Luzifer/ots/pkg/storage/redis"
|
|
)
|
|
|
|
func getStorageByType(t string) (storage.Storage, error) {
|
|
switch t {
|
|
case "mem":
|
|
return memory.New(), nil
|
|
|
|
case "redis":
|
|
s, err := redis.New()
|
|
if err != nil {
|
|
return s, fmt.Errorf("creating redis storage: %w", err)
|
|
}
|
|
return s, nil
|
|
|
|
default:
|
|
return nil, fmt.Errorf("storage type %q not found", t)
|
|
}
|
|
}
|