From c4a19a4e35a11089eef73ad86be09029b17ea0c8 Mon Sep 17 00:00:00 2001 From: kortschak Date: Sat, 28 Jun 2014 12:38:51 +0930 Subject: [PATCH] Simplify names in cmd source --- cayley.go | 14 +++++++------- db/init.go | 6 +++--- db/load.go | 2 +- db/open.go | 4 ++-- db/repl.go | 6 +++--- http/http.go | 2 +- 6 files changed, 17 insertions(+), 17 deletions(-) diff --git a/cayley.go b/cayley.go index 06af4f2..82d6ad7 100644 --- a/cayley.go +++ b/cayley.go @@ -69,18 +69,18 @@ func main() { } switch cmd { case "init": - db.CayleyInit(cfg, *tripleFile) + db.Init(cfg, *tripleFile) case "load": - ts = db.OpenTSFromConfig(cfg) - db.CayleyLoad(ts, cfg, *tripleFile, false) + ts = db.OpenTSFrom(cfg) + db.Load(ts, cfg, *tripleFile, false) ts.Close() case "repl": - ts = db.OpenTSFromConfig(cfg) - db.CayleyRepl(ts, *queryLanguage, cfg) + ts = db.OpenTSFrom(cfg) + db.Repl(ts, *queryLanguage, cfg) ts.Close() case "http": - ts = db.OpenTSFromConfig(cfg) - http.CayleyHTTP(ts, cfg) + ts = db.OpenTSFrom(cfg) + http.Serve(ts, cfg) ts.Close() default: fmt.Println("No command", cmd) diff --git a/db/init.go b/db/init.go index d3ab8a8..6625491 100644 --- a/db/init.go +++ b/db/init.go @@ -20,7 +20,7 @@ import ( "github.com/google/cayley/graph/mongo" ) -func CayleyInit(cfg *config.CayleyConfig, triplePath string) bool { +func Init(cfg *config.CayleyConfig, triplePath string) bool { created := false dbpath := cfg.DatabasePath switch cfg.DatabaseType { @@ -32,8 +32,8 @@ func CayleyInit(cfg *config.CayleyConfig, triplePath string) bool { return true } if created && triplePath != "" { - ts := OpenTSFromConfig(cfg) - CayleyLoad(ts, cfg, triplePath, true) + ts := OpenTSFrom(cfg) + Load(ts, cfg, triplePath, true) ts.Close() } return created diff --git a/db/load.go b/db/load.go index ff232a0..b0e05ca 100644 --- a/db/load.go +++ b/db/load.go @@ -25,7 +25,7 @@ import ( "github.com/google/cayley/nquads" ) -func CayleyLoad(ts graph.TripleStore, cfg *config.CayleyConfig, triplePath string, firstTime bool) { +func Load(ts graph.TripleStore, cfg *config.CayleyConfig, triplePath string, firstTime bool) { switch cfg.DatabaseType { case "mongo", "mongodb": if firstTime { diff --git a/db/open.go b/db/open.go index 7095739..c6a379e 100644 --- a/db/open.go +++ b/db/open.go @@ -24,7 +24,7 @@ import ( "github.com/google/cayley/graph/mongo" ) -func OpenTSFromConfig(cfg *config.CayleyConfig) graph.TripleStore { +func OpenTSFrom(cfg *config.CayleyConfig) graph.TripleStore { glog.Infof("Opening database \"%s\" at %s", cfg.DatabaseType, cfg.DatabasePath) switch cfg.DatabaseType { case "mongo", "mongodb": @@ -33,7 +33,7 @@ func OpenTSFromConfig(cfg *config.CayleyConfig) graph.TripleStore { return leveldb.NewDefaultLevelDBTripleStore(cfg.DatabasePath, cfg.DatabaseOptions) case "mem": ts := memstore.NewMemTripleStore() - CayleyLoad(ts, cfg, cfg.DatabasePath, true) + Load(ts, cfg, cfg.DatabasePath, true) return ts } panic("Unsupported database backend " + cfg.DatabaseType) diff --git a/db/repl.go b/db/repl.go index 405d61e..70d806b 100644 --- a/db/repl.go +++ b/db/repl.go @@ -40,7 +40,7 @@ func un(s string, startTime time.Time) { fmt.Printf(s, float64(endTime.UnixNano()-startTime.UnixNano())/float64(1E6)) } -func RunQuery(query string, ses graph.Session) { +func Run(query string, ses graph.Session) { nResults := 0 startTrace, startTime := trace("Elapsed time: %g ms\n\n") defer func() { @@ -60,7 +60,7 @@ func RunQuery(query string, ses graph.Session) { } } -func CayleyRepl(ts graph.TripleStore, queryLanguage string, cfg *config.CayleyConfig) { +func Repl(ts graph.TripleStore, queryLanguage string, cfg *config.CayleyConfig) { var ses graph.Session switch queryLanguage { case "sexp": @@ -131,7 +131,7 @@ func CayleyRepl(ts graph.TripleStore, queryLanguage string, cfg *config.CayleyCo result, err := ses.InputParses(line) switch result { case graph.Parsed: - RunQuery(line, ses) + Run(line, ses) line = "" case graph.ParseFail: fmt.Println("Error: ", err) diff --git a/http/http.go b/http/http.go index f850715..f4f58de 100644 --- a/http/http.go +++ b/http/http.go @@ -141,7 +141,7 @@ func SetupRoutes(ts graph.TripleStore, cfg *config.CayleyConfig) { http.Handle("/", r) } -func CayleyHTTP(ts graph.TripleStore, cfg *config.CayleyConfig) { +func Serve(ts graph.TripleStore, cfg *config.CayleyConfig) { 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)