diff options
author | Michael Muré <batolettre@gmail.com> | 2019-07-06 16:32:57 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-07-06 16:32:57 +0200 |
commit | f4d4b2f41326d08fdfa574cd4732e950fa9532d8 (patch) | |
tree | 04cdd9508bf8c2fd1f3b928dd419a15cdb9709d0 /bridge/github/iterator.go | |
parent | aa4464dbba0b1e0ce39ae53e35971e6924d404d3 (diff) | |
parent | 9e611ee66787b9f005540395da2ea10b3320362c (diff) | |
download | git-bug-f4d4b2f41326d08fdfa574cd4732e950fa9532d8.tar.gz |
Merge pull request #166 from MichaelMure/github-exporter
[Bridge] GitHub exporter
Diffstat (limited to 'bridge/github/iterator.go')
-rw-r--r-- | bridge/github/iterator.go | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/bridge/github/iterator.go b/bridge/github/iterator.go index fcf72b8f..6d63cf42 100644 --- a/bridge/github/iterator.go +++ b/bridge/github/iterator.go @@ -59,7 +59,7 @@ type iterator struct { commentEdit commentEditIterator } -// NewIterator create and initalize a new iterator +// NewIterator create and initialize a new iterator func NewIterator(owner, project, token string, since time.Time) *iterator { i := &iterator{ gc: buildClient(token), @@ -147,7 +147,11 @@ func (i *iterator) Error() error { } func (i *iterator) queryIssue() bool { - if err := i.gc.Query(context.TODO(), &i.timeline.query, i.timeline.variables); err != nil { + parentCtx := context.Background() + ctx, cancel := context.WithTimeout(parentCtx, defaultTimeout) + defer cancel() + + if err := i.gc.Query(ctx, &i.timeline.query, i.timeline.variables); err != nil { i.err = err return false } @@ -220,7 +224,12 @@ func (i *iterator) NextTimelineItem() bool { // more timelines, query them i.timeline.variables["timelineAfter"] = i.timeline.query.Repository.Issues.Nodes[0].Timeline.PageInfo.EndCursor - if err := i.gc.Query(context.TODO(), &i.timeline.query, i.timeline.variables); err != nil { + + parentCtx := context.Background() + ctx, cancel := context.WithTimeout(parentCtx, defaultTimeout) + defer cancel() + + if err := i.gc.Query(ctx, &i.timeline.query, i.timeline.variables); err != nil { i.err = err return false } @@ -236,7 +245,11 @@ func (i *iterator) TimelineItemValue() timelineItem { } func (i *iterator) queryIssueEdit() bool { - if err := i.gc.Query(context.TODO(), &i.issueEdit.query, i.issueEdit.variables); err != nil { + parentCtx := context.Background() + ctx, cancel := context.WithTimeout(parentCtx, defaultTimeout) + defer cancel() + + if err := i.gc.Query(ctx, &i.issueEdit.query, i.issueEdit.variables); err != nil { i.err = err //i.timeline.issueEdit.index = -1 return false @@ -334,7 +347,11 @@ func (i *iterator) IssueEditValue() userContentEdit { } func (i *iterator) queryCommentEdit() bool { - if err := i.gc.Query(context.TODO(), &i.commentEdit.query, i.commentEdit.variables); err != nil { + parentCtx := context.Background() + ctx, cancel := context.WithTimeout(parentCtx, defaultTimeout) + defer cancel() + + if err := i.gc.Query(ctx, &i.commentEdit.query, i.commentEdit.variables); err != nil { i.err = err return false } |