From 388618bfa7c4e2821656623687a0398dd7dade3d Mon Sep 17 00:00:00 2001 From: kortschak Date: Sat, 28 Jun 2014 12:42:15 +0930 Subject: [PATCH] Destutter cayley/config --- config/config.go | 8 ++++---- db/init.go | 2 +- db/load.go | 2 +- db/open.go | 2 +- db/repl.go | 2 +- http/http.go | 6 +++--- 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/config/config.go b/config/config.go index 6432dd6..1c577fa 100644 --- a/config/config.go +++ b/config/config.go @@ -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 != "" { diff --git a/db/init.go b/db/init.go index 6625491..ce0eb08 100644 --- a/db/init.go +++ b/db/init.go @@ -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 { diff --git a/db/load.go b/db/load.go index b0e05ca..7e4f2d6 100644 --- a/db/load.go +++ b/db/load.go @@ -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 { diff --git a/db/open.go b/db/open.go index c6a379e..4cfb593 100644 --- a/db/open.go +++ b/db/open.go @@ -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": diff --git a/db/repl.go b/db/repl.go index 70d806b..e07efc3 100644 --- a/db/repl.go +++ b/db/repl.go @@ -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": diff --git a/http/http.go b/http/http.go index f4f58de..70321dd 100644 --- a/http/http.go +++ b/http/http.go @@ -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)