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",
"read_only": true,
"load_size": 10000,
"gremlin_timeout": 10
"timeout": 10
}

View file

@ -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)

View file

@ -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 {

View file

@ -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

View file

@ -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

View file

@ -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: