Destutter cayley/config

This commit is contained in:
kortschak 2014-06-28 12:42:15 +09:30
parent c4a19a4e35
commit 388618bfa7
6 changed files with 11 additions and 11 deletions

View file

@ -22,7 +22,7 @@ import (
"github.com/barakmich/glog"
)
type CayleyConfig struct {
type Config struct {
DatabaseType string `json:"database"`
DatabasePath string `json:"db_path"`
DatabaseOptions map[string]interface{} `json:"db_options"`
@ -41,8 +41,8 @@ var port = flag.String("port", "64210", "Port to listen on.")
var readOnly = flag.Bool("read_only", false, "Disable writing via HTTP.")
var gremlinTimeout = flag.Int("gremlin_timeout", 30, "Number of seconds until an individual query times out.")
func ParseConfigFromFile(filename string) *CayleyConfig {
config := &CayleyConfig{}
func ParseConfigFromFile(filename string) *Config {
config := &Config{}
if filename == "" {
return config
}
@ -61,7 +61,7 @@ func ParseConfigFromFile(filename string) *CayleyConfig {
return config
}
func ParseConfigFromFlagsAndFile(fileFlag string) *CayleyConfig {
func ParseConfigFromFlagsAndFile(fileFlag string) *Config {
// Find the file...
var trueFilename string
if fileFlag != "" {

View file

@ -20,7 +20,7 @@ import (
"github.com/google/cayley/graph/mongo"
)
func Init(cfg *config.CayleyConfig, triplePath string) bool {
func Init(cfg *config.Config, triplePath string) bool {
created := false
dbpath := cfg.DatabasePath
switch cfg.DatabaseType {

View file

@ -25,7 +25,7 @@ import (
"github.com/google/cayley/nquads"
)
func Load(ts graph.TripleStore, cfg *config.CayleyConfig, triplePath string, firstTime bool) {
func Load(ts graph.TripleStore, cfg *config.Config, triplePath string, firstTime bool) {
switch cfg.DatabaseType {
case "mongo", "mongodb":
if firstTime {

View file

@ -24,7 +24,7 @@ import (
"github.com/google/cayley/graph/mongo"
)
func OpenTSFrom(cfg *config.CayleyConfig) graph.TripleStore {
func OpenTSFrom(cfg *config.Config) graph.TripleStore {
glog.Infof("Opening database \"%s\" at %s", cfg.DatabaseType, cfg.DatabasePath)
switch cfg.DatabaseType {
case "mongo", "mongodb":

View file

@ -60,7 +60,7 @@ func Run(query string, ses graph.Session) {
}
}
func Repl(ts graph.TripleStore, queryLanguage string, cfg *config.CayleyConfig) {
func Repl(ts graph.TripleStore, queryLanguage string, cfg *config.Config) {
var ses graph.Session
switch queryLanguage {
case "sexp":

View file

@ -106,7 +106,7 @@ func (h *TemplateRequestHandler) ServeHTTP(w http.ResponseWriter, r *http.Reques
}
type Api struct {
config *config.CayleyConfig
config *config.Config
ts graph.TripleStore
}
@ -119,7 +119,7 @@ func (api *Api) ApiV1(r *httprouter.Router) {
r.POST("/api/v1/delete", LogRequest(api.ServeV1Delete))
}
func SetupRoutes(ts graph.TripleStore, cfg *config.CayleyConfig) {
func SetupRoutes(ts graph.TripleStore, cfg *config.Config) {
r := httprouter.New()
assets := findAssetsPath()
if glog.V(2) {
@ -141,7 +141,7 @@ func SetupRoutes(ts graph.TripleStore, cfg *config.CayleyConfig) {
http.Handle("/", r)
}
func Serve(ts graph.TripleStore, cfg *config.CayleyConfig) {
func Serve(ts graph.TripleStore, cfg *config.Config) {
SetupRoutes(ts, cfg)
glog.Infof("Cayley now listening on %s:%s\n", cfg.ListenHost, cfg.ListenPort)
fmt.Printf("Cayley now listening on %s:%s\n", cfg.ListenHost, cfg.ListenPort)