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.
This commit is contained in:
kortschak 2014-08-02 23:23:43 +09:30
parent 0fedecd392
commit ffb52af00b
6 changed files with 18 additions and 18 deletions

View file

@ -3,5 +3,5 @@
"db_path": "30kmoviedata.nq.gz", "db_path": "30kmoviedata.nq.gz",
"read_only": true, "read_only": true,
"load_size": 10000, "load_size": 10000,
"gremlin_timeout": 10 "timeout": 10
} }

View file

@ -293,9 +293,9 @@ var m2_actors = movie2.Save("name","movie2").Follow(filmToActor)
var ( var (
once sync.Once once sync.Once
cfg = &config.Config{ cfg = &config.Config{
DatabasePath: "30kmoviedata.nq.gz", DatabasePath: "30kmoviedata.nq.gz",
DatabaseType: "memstore", DatabaseType: "memstore",
GremlinTimeout: 300 * time.Second, Timeout: 300 * time.Second,
} }
ts graph.TripleStore ts graph.TripleStore
@ -317,7 +317,7 @@ func TestQueries(t *testing.T) {
if testing.Short() && test.long { if testing.Short() && test.long {
continue continue
} }
ses := gremlin.NewSession(ts, cfg.GremlinTimeout, true) ses := gremlin.NewSession(ts, cfg.Timeout, true)
_, err := ses.InputParses(test.query) _, err := ses.InputParses(test.query)
if err != nil { if err != nil {
t.Fatalf("Failed to parse benchmark gremlin %s: %v", test.message, err) 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() b.Skip()
} }
prepare(b) prepare(b)
ses := gremlin.NewSession(ts, cfg.GremlinTimeout, true) ses := gremlin.NewSession(ts, cfg.Timeout, true)
_, err := ses.InputParses(benchmarkQueries[n].query) _, err := ses.InputParses(benchmarkQueries[n].query)
if err != nil { if err != nil {
b.Fatalf("Failed to parse benchmark gremlin %s: %v", benchmarkQueries[n].message, err) b.Fatalf("Failed to parse benchmark gremlin %s: %v", benchmarkQueries[n].message, err)

View file

@ -32,7 +32,7 @@ type Config struct {
ListenHost string ListenHost string
ListenPort string ListenPort string
ReadOnly bool ReadOnly bool
GremlinTimeout time.Duration Timeout time.Duration
LoadSize int LoadSize int
} }
@ -43,7 +43,7 @@ type config struct {
ListenHost string `json:"listen_host"` ListenHost string `json:"listen_host"`
ListenPort string `json:"listen_port"` ListenPort string `json:"listen_port"`
ReadOnly bool `json:"read_only"` ReadOnly bool `json:"read_only"`
GremlinTimeout duration `json:"gremlin_timeout"` Timeout duration `json:"timeout"`
LoadSize int `json:"load_size"` LoadSize int `json:"load_size"`
} }
@ -60,7 +60,7 @@ func (c *Config) UnmarshalJSON(data []byte) error {
ListenHost: t.ListenHost, ListenHost: t.ListenHost,
ListenPort: t.ListenPort, ListenPort: t.ListenPort,
ReadOnly: t.ReadOnly, ReadOnly: t.ReadOnly,
GremlinTimeout: time.Duration(t.GremlinTimeout), Timeout: time.Duration(t.Timeout),
LoadSize: t.LoadSize, LoadSize: t.LoadSize,
} }
return nil return nil
@ -74,7 +74,7 @@ func (c *Config) MarshalJSON() ([]byte, error) {
ListenHost: c.ListenHost, ListenHost: c.ListenHost,
ListenPort: c.ListenPort, ListenPort: c.ListenPort,
ReadOnly: c.ReadOnly, ReadOnly: c.ReadOnly,
GremlinTimeout: duration(c.GremlinTimeout), Timeout: duration(c.Timeout),
LoadSize: c.LoadSize, LoadSize: c.LoadSize,
}) })
} }
@ -121,7 +121,7 @@ var (
loadSize = flag.Int("load_size", 10000, "Size of triplesets to load") loadSize = flag.Int("load_size", 10000, "Size of triplesets to load")
port = flag.String("port", "64210", "Port to listen on.") port = flag.String("port", "64210", "Port to listen on.")
readOnly = flag.Bool("read_only", false, "Disable writing via HTTP.") 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 { func ParseConfigFromFile(filename string) *Config {
@ -183,8 +183,8 @@ func ParseConfigFromFlagsAndFile(fileFlag string) *Config {
config.ListenPort = *port config.ListenPort = *port
} }
if config.GremlinTimeout == 0 { if config.Timeout == 0 {
config.GremlinTimeout = *gremlinTimeout config.Timeout = *timeout
} }
if config.LoadSize == 0 { if config.LoadSize == 0 {

View file

@ -72,7 +72,7 @@ func Repl(ts graph.TripleStore, queryLanguage string, cfg *config.Config) error
case "gremlin": case "gremlin":
fallthrough fallthrough
default: default:
ses = gremlin.NewSession(ts, cfg.GremlinTimeout, true) ses = gremlin.NewSession(ts, cfg.Timeout, true)
} }
buf := bufio.NewReader(os.Stdin) buf := bufio.NewReader(os.Stdin)
var line []byte var line []byte

View file

@ -72,12 +72,12 @@ All command line flags take precedence over the configuration file.
## Language Options ## Language Options
#### **`gremlin_timeout`** #### **`timeout`**
* Type: Integer or String * Type: Integer or String
* Default: 30 * 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 ## Per-Database Options

View file

@ -71,7 +71,7 @@ func (api *Api) ServeV1Query(w http.ResponseWriter, r *http.Request, params http
var ses query.HttpSession var ses query.HttpSession
switch params.ByName("query_lang") { switch params.ByName("query_lang") {
case "gremlin": case "gremlin":
ses = gremlin.NewSession(api.ts, api.config.GremlinTimeout, false) ses = gremlin.NewSession(api.ts, api.config.Timeout, false)
case "mql": case "mql":
ses = mql.NewSession(api.ts) ses = mql.NewSession(api.ts)
default: default:
@ -119,7 +119,7 @@ func (api *Api) ServeV1Shape(w http.ResponseWriter, r *http.Request, params http
var ses query.HttpSession var ses query.HttpSession
switch params.ByName("query_lang") { switch params.ByName("query_lang") {
case "gremlin": case "gremlin":
ses = gremlin.NewSession(api.ts, api.config.GremlinTimeout, false) ses = gremlin.NewSession(api.ts, api.config.Timeout, false)
case "mql": case "mql":
ses = mql.NewSession(api.ts) ses = mql.NewSession(api.ts)
default: default: