summaryrefslogtreecommitdiffstats
path: root/modules/webhook
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2019-11-02 10:35:12 +0800
committerGitHub <noreply@github.com>2019-11-02 10:35:12 +0800
commitf518fe66620bcb60a5251befca116f8caa48ee42 (patch)
tree0522717b649d6d5148e11e122048cf8629aafcfb /modules/webhook
parent4b8d9e58c58b8952e86e7e5f90a0a8e0480e1de1 (diff)
downloadgitea-f518fe66620bcb60a5251befca116f8caa48ee42.tar.gz
gitea-f518fe66620bcb60a5251befca116f8caa48ee42.zip
Rename HookQueue to hookQueue (#8778)
* Rename HookQueue to hookQueue * fix lint
Diffstat (limited to 'modules/webhook')
-rw-r--r--modules/webhook/deliver.go4
-rw-r--r--modules/webhook/webhook.go18
2 files changed, 16 insertions, 6 deletions
diff --git a/modules/webhook/deliver.go b/modules/webhook/deliver.go
index 1b3da25d5e..54f20171fa 100644
--- a/modules/webhook/deliver.go
+++ b/modules/webhook/deliver.go
@@ -159,9 +159,9 @@ func DeliverHooks() {
}
// Start listening on new hook requests.
- for repoIDStr := range HookQueue.Queue() {
+ for repoIDStr := range hookQueue.Queue() {
log.Trace("DeliverHooks [repo_id: %v]", repoIDStr)
- HookQueue.Remove(repoIDStr)
+ hookQueue.Remove(repoIDStr)
repoID, err := com.StrTo(repoIDStr).Int64()
if err != nil {
diff --git a/modules/webhook/webhook.go b/modules/webhook/webhook.go
index da88c58c88..623a475df9 100644
--- a/modules/webhook/webhook.go
+++ b/modules/webhook/webhook.go
@@ -20,8 +20,8 @@ import (
"github.com/gobwas/glob"
)
-// HookQueue is a global queue of web hooks
-var HookQueue = sync.NewUniqueQueue(setting.Webhook.QueueLength)
+// hookQueue is a global queue of web hooks
+var hookQueue = sync.NewUniqueQueue(setting.Webhook.QueueLength)
// getPayloadBranch returns branch for hook event, if applicable.
func getPayloadBranch(p api.Payloader) string {
@@ -44,7 +44,12 @@ func getPayloadBranch(p api.Payloader) string {
// PrepareWebhook adds special webhook to task queue for given payload.
func PrepareWebhook(w *models.Webhook, repo *models.Repository, event models.HookEventType, p api.Payloader) error {
- return prepareWebhook(w, repo, event, p)
+ if err := prepareWebhook(w, repo, event, p); err != nil {
+ return err
+ }
+
+ go hookQueue.Add(repo.ID)
+ return nil
}
func checkBranch(w *models.Webhook, branch string) bool {
@@ -147,7 +152,12 @@ func prepareWebhook(w *models.Webhook, repo *models.Repository, event models.Hoo
// PrepareWebhooks adds new webhooks to task queue for given payload.
func PrepareWebhooks(repo *models.Repository, event models.HookEventType, p api.Payloader) error {
- return prepareWebhooks(repo, event, p)
+ if err := prepareWebhooks(repo, event, p); err != nil {
+ return err
+ }
+
+ go hookQueue.Add(repo.ID)
+ return nil
}
func prepareWebhooks(repo *models.Repository, event models.HookEventType, p api.Payloader) error {