Mercurial > gemma
comparison pkg/imports/gm.go @ 3582:317d176ef38c
GM import: Try three times when timeouts happen on SOAP service. Increase SOAP timeout to 3 minutes.
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Mon, 03 Jun 2019 18:24:35 +0200 |
parents | d38b20ccb6f9 |
children | 391afcc961a2 |
comparison
equal
deleted
inserted
replaced
3581:9114097964d7 | 3582:317d176ef38c |
---|---|
17 | 17 |
18 import ( | 18 import ( |
19 "context" | 19 "context" |
20 "database/sql" | 20 "database/sql" |
21 "fmt" | 21 "fmt" |
22 "log" | |
22 "sort" | 23 "sort" |
23 "strings" | 24 "strings" |
24 "time" | 25 "time" |
25 | 26 |
26 "gemma.intevation.de/gemma/pkg/models" | 27 "gemma.intevation.de/gemma/pkg/models" |
175 | 176 |
176 req := &nts.Get_messages_query{ | 177 req := &nts.Get_messages_query{ |
177 Message_type: &mt, | 178 Message_type: &mt, |
178 } | 179 } |
179 | 180 |
181 const maxTries = 3 | |
182 | |
183 tries := 0 | |
184 | |
185 again: | |
180 resp, err := client.Get_messages(req) | 186 resp, err := client.Get_messages(req) |
187 | |
181 if err != nil { | 188 if err != nil { |
182 return nil, err | 189 if t, ok := err.(interface{ Timeout() bool }); ok && t.Timeout() && tries < maxTries { |
190 log.Println("warn: NtS SOAP request timed out. Trying again.") | |
191 tries++ | |
192 goto again | |
193 } | |
194 return nil, fmt.Errorf( | |
195 "Error requesting NtS service: %v", err) | |
183 } | 196 } |
184 | 197 |
185 result := resp.Result_message | 198 result := resp.Result_message |
186 if result == nil { | 199 if result == nil { |
187 for _, e := range resp.Result_error { | 200 for _, e := range resp.Result_error { |