StateEvents returns a channel with state change events.
(ctx context.Context, client *gitlab.Client, issue *gitlab.Issue)
| 111 | |
| 112 | // StateEvents returns a channel with state change events. |
| 113 | func StateEvents(ctx context.Context, client *gitlab.Client, issue *gitlab.Issue) <-chan Event { |
| 114 | out := make(chan Event) |
| 115 | |
| 116 | go func() { |
| 117 | defer close(out) |
| 118 | |
| 119 | opts := gitlab.ListStateEventsOptions{} |
| 120 | |
| 121 | for { |
| 122 | events, resp, err := client.ResourceStateEvents.ListIssueStateEvents(issue.ProjectID, issue.IID, &opts, gitlab.WithContext(ctx)) |
| 123 | if err != nil { |
| 124 | out <- ErrorEvent{Err: err, Time: time.Now()} |
| 125 | } |
| 126 | |
| 127 | for _, e := range events { |
| 128 | out <- StateEvent{*e} |
| 129 | } |
| 130 | |
| 131 | if resp.CurrentPage >= resp.TotalPages { |
| 132 | break |
| 133 | } |
| 134 | |
| 135 | opts.Page = resp.NextPage |
| 136 | } |
| 137 | }() |
| 138 | |
| 139 | return out |
| 140 | } |