From ffb52af00b392f422bf22f85a0f89033190a5be1 Mon Sep 17 00:00:00 2001 From: kortschak Date: Sat, 2 Aug 2014 23:23:43 +0930 Subject: [PATCH] Rename GremlinTimeout -> Timeout Given that there may be other Turing complete query interfaces (particularly a Go query API), the timeout config should not be specifically tied to gremlin. --- cayley_appengine.cfg | 2 +- cayley_test.go | 10 +++++----- config/config.go | 14 +++++++------- db/repl.go | 2 +- docs/Configuration.md | 4 ++-- http/query.go | 4 ++-- 6 files changed, 18 insertions(+), 18 deletions(-) diff --git a/cayley_appengine.cfg b/cayley_appengine.cfg index 2ecd797..a762b5f 100644 --- a/cayley_appengine.cfg +++ b/cayley_appengine.cfg @@ -3,5 +3,5 @@ "db_path": "30kmoviedata.nq.gz", "read_only": true, "load_size": 10000, -"gremlin_timeout": 10 +"timeout": 10 } diff --git a/cayley_test.go b/cayley_test.go index f0e85b7..9bda12a 100644 --- a/cayley_test.go +++ b/cayley_test.go @@ -293,9 +293,9 @@ var m2_actors = movie2.Save("name","movie2").Follow(filmToActor) var ( once sync.Once cfg = &config.Config{ - DatabasePath: "30kmoviedata.nq.gz", - DatabaseType: "memstore", - GremlinTimeout: 300 * time.Second, + DatabasePath: "30kmoviedata.nq.gz", + DatabaseType: "memstore", + Timeout: 300 * time.Second, } ts graph.TripleStore @@ -317,7 +317,7 @@ func TestQueries(t *testing.T) { if testing.Short() && test.long { continue } - ses := gremlin.NewSession(ts, cfg.GremlinTimeout, true) + ses := gremlin.NewSession(ts, cfg.Timeout, true) _, err := ses.InputParses(test.query) if err != nil { t.Fatalf("Failed to parse benchmark gremlin %s: %v", test.message, err) @@ -358,7 +358,7 @@ func runBench(n int, b *testing.B) { b.Skip() } prepare(b) - ses := gremlin.NewSession(ts, cfg.GremlinTimeout, true) + ses := gremlin.NewSession(ts, cfg.Timeout, true) _, err := ses.InputParses(benchmarkQueries[n].query) if err != nil { b.Fatalf("Failed to parse benchmark gremlin %s: %v", benchmarkQueries[n].message, err) diff --git a/config/config.go b/config/config.go index 04867d8..d8cb4d8 100644 --- a/config/config.go +++ b/config/config.go @@ -32,7 +32,7 @@ type Config struct { ListenHost string ListenPort string ReadOnly bool - GremlinTimeout time.Duration + Timeout time.Duration LoadSize int } @@ -43,7 +43,7 @@ type config struct { ListenHost string `json:"listen_host"` ListenPort string `json:"listen_port"` ReadOnly bool `json:"read_only"` - GremlinTimeout duration `json:"gremlin_timeout"` + Timeout duration `json:"timeout"` LoadSize int `json:"load_size"` } @@ -60,7 +60,7 @@ func (c *Config) UnmarshalJSON(data []byte) error { ListenHost: t.ListenHost, ListenPort: t.ListenPort, ReadOnly: t.ReadOnly, - GremlinTimeout: time.Duration(t.GremlinTimeout), + Timeout: time.Duration(t.Timeout), LoadSize: t.LoadSize, } return nil @@ -74,7 +74,7 @@ func (c *Config) MarshalJSON() ([]byte, error) { ListenHost: c.ListenHost, ListenPort: c.ListenPort, ReadOnly: c.ReadOnly, - GremlinTimeout: duration(c.GremlinTimeout), + Timeout: duration(c.Timeout), LoadSize: c.LoadSize, }) } @@ -121,7 +121,7 @@ var ( loadSize = flag.Int("load_size", 10000, "Size of triplesets to load") port = flag.String("port", "64210", "Port to listen on.") readOnly = flag.Bool("read_only", false, "Disable writing via HTTP.") - gremlinTimeout = flag.Duration("gremlin_timeout", 30*time.Second, "Elapsed time until an individual query times out.") + timeout = flag.Duration("timeout", 30*time.Second, "Elapsed time until an individual query times out.") ) func ParseConfigFromFile(filename string) *Config { @@ -183,8 +183,8 @@ func ParseConfigFromFlagsAndFile(fileFlag string) *Config { config.ListenPort = *port } - if config.GremlinTimeout == 0 { - config.GremlinTimeout = *gremlinTimeout + if config.Timeout == 0 { + config.Timeout = *timeout } if config.LoadSize == 0 { diff --git a/db/repl.go b/db/repl.go index 2ef9429..c1bb5ea 100644 --- a/db/repl.go +++ b/db/repl.go @@ -72,7 +72,7 @@ func Repl(ts graph.TripleStore, queryLanguage string, cfg *config.Config) error case "gremlin": fallthrough default: - ses = gremlin.NewSession(ts, cfg.GremlinTimeout, true) + ses = gremlin.NewSession(ts, cfg.Timeout, true) } buf := bufio.NewReader(os.Stdin) var line []byte diff --git a/docs/Configuration.md b/docs/Configuration.md index 37b7669..b464adb 100644 --- a/docs/Configuration.md +++ b/docs/Configuration.md @@ -72,12 +72,12 @@ All command line flags take precedence over the configuration file. ## Language Options -#### **`gremlin_timeout`** +#### **`timeout`** * Type: Integer or String * Default: 30 -The maximum length of time the Javascript runtime should run until cancelling the query and returning a 408 Timeout. When gremlin_timeout is an integer is is interpretted as seconds, when it is a string it is [parsed](http://golang.org/pkg/time/#ParseDuration) as a Go time.Duration. A negative duration means no limit. +The maximum length of time the Javascript runtime should run until cancelling the query and returning a 408 Timeout. When timeout is an integer is is interpretted as seconds, when it is a string it is [parsed](http://golang.org/pkg/time/#ParseDuration) as a Go time.Duration. A negative duration means no limit. ## Per-Database Options diff --git a/http/query.go b/http/query.go index e8b5d72..f4f5a34 100644 --- a/http/query.go +++ b/http/query.go @@ -71,7 +71,7 @@ func (api *Api) ServeV1Query(w http.ResponseWriter, r *http.Request, params http var ses query.HttpSession switch params.ByName("query_lang") { case "gremlin": - ses = gremlin.NewSession(api.ts, api.config.GremlinTimeout, false) + ses = gremlin.NewSession(api.ts, api.config.Timeout, false) case "mql": ses = mql.NewSession(api.ts) default: @@ -119,7 +119,7 @@ func (api *Api) ServeV1Shape(w http.ResponseWriter, r *http.Request, params http var ses query.HttpSession switch params.ByName("query_lang") { case "gremlin": - ses = gremlin.NewSession(api.ts, api.config.GremlinTimeout, false) + ses = gremlin.NewSession(api.ts, api.config.Timeout, false) case "mql": ses = mql.NewSession(api.ts) default: