Commit 321ee8cf authored by vaikas-google's avatar vaikas-google

Add flag for timeout for talking to service

parent 47a79141
...@@ -41,6 +41,7 @@ var ( ...@@ -41,6 +41,7 @@ var (
template_registry = flag.String("registry", "kubernetes/deployment-manager/templates", "Github based template registry (owner/repo[/path])") template_registry = flag.String("registry", "kubernetes/deployment-manager/templates", "Github based template registry (owner/repo[/path])")
service = flag.String("service", "http://localhost:8001/api/v1/proxy/namespaces/dm/services/manager-service:manager", "URL for deployment manager") service = flag.String("service", "http://localhost:8001/api/v1/proxy/namespaces/dm/services/manager-service:manager", "URL for deployment manager")
binary = flag.String("binary", "../expandybird/expansion/expansion.py", "Path to template expansion binary") binary = flag.String("binary", "../expandybird/expansion/expansion.py", "Path to template expansion binary")
timeout = flag.Int("timeout", 10, "Time in seconds to wait for response")
) )
var commands = []string{ var commands = []string{
...@@ -181,7 +182,12 @@ func callService(path, method, action string, reader io.ReadCloser) { ...@@ -181,7 +182,12 @@ func callService(path, method, action string, reader io.ReadCloser) {
func callHttp(path, method, action string, reader io.ReadCloser) string { func callHttp(path, method, action string, reader io.ReadCloser) string {
request, err := http.NewRequest(method, path, reader) request, err := http.NewRequest(method, path, reader)
request.Header.Add("Content-Type", "application/json") request.Header.Add("Content-Type", "application/json")
response, err := http.DefaultClient.Do(request)
client := http.Client{
Timeout: time.Duration(time.Duration(*timeout) * time.Second),
}
response, err := client.Do(request)
if err != nil { if err != nil {
log.Fatalf("cannot %s: %s\n", action, err) log.Fatalf("cannot %s: %s\n", action, err)
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment