package storage

import (
	"strings"
)

type Type int

const (
	MAP             = Type(iota)
	REDIS           = Type(iota)
	DYNOMITE        = Type(iota)
	BOLT            = Type(iota)
	COCKROACH       = Type(iota)
	CACHE           = Type(iota)
	LEVELDB         = Type(iota)
	MEMCACHE        = Type(iota)
	MEMCACHECLUSTER = Type(iota)
	MONGO           = Type(iota)
	MINIO           = Type(iota)
)

func (t Type) String() string {
	switch t {
	case DYNOMITE:
		return "dynomite"
	case REDIS:
		return "redis"
	case MAP:
		return "map"
	case COCKROACH:
		return "cockroach"
	case BOLT:
		return "bolt"
	case MINIO:
		return "minio"
	case CACHE:
		return "cache"
	case LEVELDB:
		return "leveldb"
	case MEMCACHE:
		return "memcache"
	case MEMCACHECLUSTER:
		return "memcachecluster"
	case MONGO:
		return "mongo"
	}
	return "<unknown>"
}

func TypeFromString(key string) Type {
	key = strings.ToLower(key)
	for i := 0; i < 30; i++ {
		t := Type(i)
		if t.String() == key {
			return t
		}
	}
	return Type(-1)
}
