File tree Expand file tree Collapse file tree 1 file changed +6
-1
lines changed Expand file tree Collapse file tree 1 file changed +6
-1
lines changed Original file line number Diff line number Diff line change 8
8
"log"
9
9
"os"
10
10
"strings"
11
+ "time"
11
12
)
12
13
13
14
var (
@@ -61,11 +62,15 @@ func document(cmd *cobra.Command, args []string) {
61
62
func download (client * comdirect.Client , documents * comdirect.Documents ) {
62
63
ctx , cancel := contextWithTimeout ()
63
64
defer cancel ()
64
- for _ , d := range documents .Values {
65
+ for i , d := range documents .Values {
65
66
err := client .DownloadDocument (ctx , & d , folderFlag )
66
67
if err != nil {
67
68
log .Fatal ("failed to download document: " , err )
68
69
}
70
+ // TODO: think about a better solution to limit download requests to 10/sec
71
+ if i % 10 == 0 && i != 0 {
72
+ time .Sleep (900 * time .Millisecond )
73
+ }
69
74
fmt .Printf ("Download complete for document with ID %s\n " , d .DocumentID )
70
75
}
71
76
}
You can’t perform that action at this time.
0 commit comments