ots/storage.go

27 lines
482 B
Go
Raw Permalink Normal View History

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:
2023-10-04 16:53:29 -04:00
return nil, fmt.Errorf("storage type %q not found", t)
}
}