mirror of
https://code.forgejo.org/forgejo/runner.git
synced 2025-09-15 18:57:01 +00:00
feat: insert the daemon context in the poller context
The daemon context is needed when the context of a job or the poller is done. Otherwise it is no longer possible to send a conclusion report to Forgejo, short of creating a context.Background() which poses its own set of problems. - WithDaemonContext is used to store the daemon context - The poller uses the daemon context instead of context.Background
This commit is contained in:
parent
fccf857bce
commit
d114f3646d
5 changed files with 37 additions and 8 deletions
|
@ -42,14 +42,14 @@ type poller struct {
|
|||
done chan any
|
||||
}
|
||||
|
||||
func New(cfg *config.Config, client client.Client, runner run.RunnerInterface) Poller {
|
||||
return (&poller{}).init(cfg, client, runner)
|
||||
func New(ctx context.Context, cfg *config.Config, client client.Client, runner run.RunnerInterface) Poller {
|
||||
return (&poller{}).init(ctx, cfg, client, runner)
|
||||
}
|
||||
|
||||
func (p *poller) init(cfg *config.Config, client client.Client, runner run.RunnerInterface) Poller {
|
||||
pollingCtx, shutdownPolling := context.WithCancel(context.Background())
|
||||
func (p *poller) init(ctx context.Context, cfg *config.Config, client client.Client, runner run.RunnerInterface) Poller {
|
||||
pollingCtx, shutdownPolling := context.WithCancel(ctx)
|
||||
|
||||
jobsCtx, shutdownJobs := context.WithCancel(context.Background())
|
||||
jobsCtx, shutdownJobs := context.WithCancel(ctx)
|
||||
|
||||
done := make(chan any)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue