mirror of
https://github.com/fnproject/fn.git
synced 2022-10-28 21:29:17 +03:00
* Add support for redis as a datastore Fixes: #388 * Use HEXISTS instead of HGET when checking for apps and routes * Get rid of SADD SREM and SMEMBERS * change redis test port * Add buffer time for redis docker * redis test ping loop (#552) * redis test ping loop * simplify * Refactor redis_test.go to adapt to @jmank88 new testing code * tiny fix * Redis datastore test fixes (#555) * redis datastore test fixes - UpdateRoute/UpdateApp * redis datastore fix InsertRoute * redis datastore fix GetRoutesByApp
31 lines
758 B
Go
31 lines
758 B
Go
package datastore
|
|
|
|
import (
|
|
"fmt"
|
|
"net/url"
|
|
|
|
"github.com/Sirupsen/logrus"
|
|
"github.com/iron-io/functions/api/datastore/bolt"
|
|
"github.com/iron-io/functions/api/datastore/postgres"
|
|
"github.com/iron-io/functions/api/datastore/redis"
|
|
"github.com/iron-io/functions/api/models"
|
|
)
|
|
|
|
func New(dbURL string) (models.Datastore, error) {
|
|
u, err := url.Parse(dbURL)
|
|
if err != nil {
|
|
logrus.WithError(err).WithFields(logrus.Fields{"url": dbURL}).Fatal("bad DB URL")
|
|
}
|
|
logrus.WithFields(logrus.Fields{"db": u.Scheme}).Debug("creating new datastore")
|
|
switch u.Scheme {
|
|
case "bolt":
|
|
return bolt.New(u)
|
|
case "postgres":
|
|
return postgres.New(u)
|
|
case "redis":
|
|
return redis.New(u)
|
|
default:
|
|
return nil, fmt.Errorf("db type not supported %v", u.Scheme)
|
|
}
|
|
}
|