Skip to content

Commit 50f35c0

Browse files
committed
Add timeout on configuration
Signed-off-by: Antonio Jesus Navarro Perez <[email protected]>
1 parent e5b1d16 commit 50f35c0

File tree

2 files changed

+19
-8
lines changed

2 files changed

+19
-8
lines changed

cmd/gitbase/command/server.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"runtime"
88
"strconv"
99
"strings"
10+
"time"
1011

1112
"github.com/src-d/gitbase"
1213
"github.com/src-d/gitbase/internal/function"
@@ -46,6 +47,7 @@ type Server struct {
4647
Port int `short:"p" long:"port" default:"3306" description:"Port where the server is going to listen"`
4748
User string `short:"u" long:"user" default:"root" description:"User name used for connection"`
4849
Password string `short:"P" long:"password" default:"" description:"Password used for connection"`
50+
ConnTimeout time.Duration `short:"t" long:"timeout" env:"GITBASE_CONNECTION_TIMEOUT" description:"Timeout used for connections"`
4951
IndexDir string `short:"i" long:"index" default:"/var/lib/gitbase/index" description:"Directory where the gitbase indexes information will be persisted." env:"GITBASE_INDEX_DIR"`
5052
CacheSize cache.FileSize `long:"cache" default:"512" description:"Object cache size in megabytes" env:"GITBASE_CACHESIZE_MB"`
5153
Parallelism uint `long:"parallelism" description:"Maximum number of parallel threads per table. By default, it's the number of CPU cores. 0 means default, 1 means disabled."`
@@ -148,10 +150,12 @@ func (c *Server) Execute(args []string) error {
148150
hostString := net.JoinHostPort(c.Host, strconv.Itoa(c.Port))
149151
s, err := server.NewServer(
150152
server.Config{
151-
Protocol: "tcp",
152-
Address: hostString,
153-
Auth: auth,
154-
Tracer: tracer,
153+
Protocol: "tcp",
154+
Address: hostString,
155+
Auth: auth,
156+
Tracer: tracer,
157+
ConnReadTimeout: c.ConnTimeout,
158+
ConnWriteTimeout: c.ConnTimeout,
155159
},
156160
c.engine,
157161
gitbase.NewSessionBuilder(c.pool,

docs/using-gitbase/configuration.md

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
| `GITBASE_LANGUAGE_CACHE_SIZE`| size of the cache for the `language` UDF. The size is the maximum number of elements kept in the cache, 10000 by default |
1515
| `GITBASE_UAST_CACHE_SIZE` | size of the cache for the `uast` and `uast_mode` UDFs. The size is the maximum number of elements kept in the cache, 10000 by default |
1616
| `GITBASE_CACHESIZE_MB` | size of the cache for git objects specified as MB |
17+
| `GITBASE_CONNECTION_TIMEOUT` | timeout used for client connections on write and reads. No timeout by default. |
1718

1819
### Jaeger tracing variables
1920

@@ -67,20 +68,26 @@ Help Options:
6768
-h, --help Show this help message
6869
6970
[server command options]
70-
-d, --directories= Path where the git repositories are located (standard and siva), multiple directories can be defined. Accepts globs.
71+
-d, --directories= Path where the git repositories are located (standard and siva), multiple directories can be
72+
defined. Accepts globs.
7173
--depth= load repositories looking at less than <depth> nested subdirectories. (default: 1000)
7274
--host= Host where the server is going to listen (default: localhost)
7375
-p, --port= Port where the server is going to listen (default: 3306)
7476
-u, --user= User name used for connection (default: root)
7577
-P, --password= Password used for connection
76-
-i, --index= Directory where the gitbase indexes information will be persisted. (default: /var/lib/gitbase/index) [$GITBASE_INDEX_DIR]
78+
-t, --timeout= Timeout used for connections [$GITBASE_CONNECTION_TIMEOUT]
79+
-i, --index= Directory where the gitbase indexes information will be persisted. (default:
80+
/var/lib/gitbase/index) [$GITBASE_INDEX_DIR]
7781
--cache= Object cache size in megabytes (default: 512) [$GITBASE_CACHESIZE_MB]
78-
--parallelism= Maximum number of parallel threads per table. By default, it's the number of CPU cores. 0 means default, 1 means disabled.
82+
--parallelism= Maximum number of parallel threads per table. By default, it's the number of CPU cores. 0
83+
means default, 1 means disabled.
7984
--no-squash Disables the table squashing.
8085
--trace Enables jaeger tracing [$GITBASE_TRACE]
81-
-r, --readonly Only allow read queries. This disables creating and deleting indexes as well. [$GITBASE_READONLY]
86+
-r, --readonly Only allow read queries. This disables creating and deleting indexes as well.
87+
[$GITBASE_READONLY]
8288
--no-git disable the load of git standard repositories.
8389
--no-siva disable the load of siva files.
8490
-v Activates the verbose mode
8591
92+
8693
```

0 commit comments

Comments
 (0)