mirror of
https://github.com/go-gitea/gitea.git
synced 2024-09-01 14:56:30 +00:00
chore: move job emitter to service
This commit is contained in:
parent
f57e6999a2
commit
dd417a3270
@ -11,18 +11,11 @@ import (
|
|||||||
|
|
||||||
"code.gitea.io/gitea/models/webhook"
|
"code.gitea.io/gitea/models/webhook"
|
||||||
"code.gitea.io/gitea/modules/git"
|
"code.gitea.io/gitea/modules/git"
|
||||||
"code.gitea.io/gitea/modules/graceful"
|
|
||||||
"code.gitea.io/gitea/modules/log"
|
"code.gitea.io/gitea/modules/log"
|
||||||
"code.gitea.io/gitea/modules/queue"
|
|
||||||
|
|
||||||
"github.com/nektos/act/pkg/model"
|
"github.com/nektos/act/pkg/model"
|
||||||
)
|
)
|
||||||
|
|
||||||
func Init() {
|
|
||||||
jobEmitterQueue = queue.CreateUniqueQueue("bots_ready_job", jobEmitterQueueHandle, new(jobUpdate))
|
|
||||||
go graceful.GetManager().RunWithShutdownFns(jobEmitterQueue.Run)
|
|
||||||
}
|
|
||||||
|
|
||||||
func ListWorkflows(commit *git.Commit) (git.Entries, error) {
|
func ListWorkflows(commit *git.Commit) (git.Entries, error) {
|
||||||
tree, err := commit.SubTree(".gitea/workflows")
|
tree, err := commit.SubTree(".gitea/workflows")
|
||||||
if _, ok := err.(git.ErrNotExist); ok {
|
if _, ok := err.(git.ErrNotExist); ok {
|
||||||
|
@ -19,6 +19,7 @@ import (
|
|||||||
"code.gitea.io/gitea/modules/log"
|
"code.gitea.io/gitea/modules/log"
|
||||||
"code.gitea.io/gitea/modules/setting"
|
"code.gitea.io/gitea/modules/setting"
|
||||||
api "code.gitea.io/gitea/modules/structs"
|
api "code.gitea.io/gitea/modules/structs"
|
||||||
|
bot_service "code.gitea.io/gitea/services/bots"
|
||||||
secret_service "code.gitea.io/gitea/services/secrets"
|
secret_service "code.gitea.io/gitea/services/secrets"
|
||||||
|
|
||||||
runnerv1 "gitea.com/gitea/proto-go/runner/v1"
|
runnerv1 "gitea.com/gitea/proto-go/runner/v1"
|
||||||
@ -214,7 +215,7 @@ func (s *Service) UpdateTask(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if req.Msg.State.Result != runnerv1.Result_RESULT_UNSPECIFIED {
|
if req.Msg.State.Result != runnerv1.Result_RESULT_UNSPECIFIED {
|
||||||
if err := bots.EmitJobsIfReady(task.Job.RunID); err != nil {
|
if err := bot_service.EmitJobsIfReady(task.Job.RunID); err != nil {
|
||||||
log.Error("Emit ready jobs of run %d: %v", task.Job.RunID, err)
|
log.Error("Emit ready jobs of run %d: %v", task.Job.RunID, err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,6 @@ import (
|
|||||||
|
|
||||||
"code.gitea.io/gitea/models"
|
"code.gitea.io/gitea/models"
|
||||||
asymkey_model "code.gitea.io/gitea/models/asymkey"
|
asymkey_model "code.gitea.io/gitea/models/asymkey"
|
||||||
"code.gitea.io/gitea/modules/bots"
|
|
||||||
"code.gitea.io/gitea/modules/cache"
|
"code.gitea.io/gitea/modules/cache"
|
||||||
"code.gitea.io/gitea/modules/eventsource"
|
"code.gitea.io/gitea/modules/eventsource"
|
||||||
"code.gitea.io/gitea/modules/git"
|
"code.gitea.io/gitea/modules/git"
|
||||||
@ -41,6 +40,7 @@ import (
|
|||||||
"code.gitea.io/gitea/services/auth"
|
"code.gitea.io/gitea/services/auth"
|
||||||
"code.gitea.io/gitea/services/auth/source/oauth2"
|
"code.gitea.io/gitea/services/auth/source/oauth2"
|
||||||
"code.gitea.io/gitea/services/automerge"
|
"code.gitea.io/gitea/services/automerge"
|
||||||
|
bot_service "code.gitea.io/gitea/services/bots"
|
||||||
"code.gitea.io/gitea/services/cron"
|
"code.gitea.io/gitea/services/cron"
|
||||||
"code.gitea.io/gitea/services/mailer"
|
"code.gitea.io/gitea/services/mailer"
|
||||||
markup_service "code.gitea.io/gitea/services/markup"
|
markup_service "code.gitea.io/gitea/services/markup"
|
||||||
@ -175,7 +175,7 @@ func GlobalInitInstalled(ctx context.Context) {
|
|||||||
auth.Init()
|
auth.Init()
|
||||||
svg.Init()
|
svg.Init()
|
||||||
|
|
||||||
bots.Init()
|
bot_service.Init()
|
||||||
|
|
||||||
// Finally start up the cron
|
// Finally start up the cron
|
||||||
cron.NewContext(ctx)
|
cron.NewContext(ctx)
|
||||||
|
15
services/bots/bots.go
Normal file
15
services/bots/bots.go
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
// Copyright 2022 The Gitea Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a MIT-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
package bots
|
||||||
|
|
||||||
|
import (
|
||||||
|
"code.gitea.io/gitea/modules/graceful"
|
||||||
|
"code.gitea.io/gitea/modules/queue"
|
||||||
|
)
|
||||||
|
|
||||||
|
func Init() {
|
||||||
|
jobEmitterQueue = queue.CreateUniqueQueue("bots_ready_job", jobEmitterQueueHandle, new(jobUpdate))
|
||||||
|
go graceful.GetManager().RunWithShutdownFns(jobEmitterQueue.Run)
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user