Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update jobs #2

Merged
merged 3 commits into from
Jul 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 19 additions & 21 deletions cmd/api/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ package main

import (
"net/http"
"time"

"github.com/go-co-op/gocron"
log "github.com/sirupsen/logrus"

"github.com/Becram/go-webhook/internal/config"
Expand All @@ -23,10 +21,10 @@ func main() {
if err != nil {
log.Fatal(err)
}
e := runCron()
if e != nil {
log.Fatal(err)
}
// e := runCron()
// if e != nil {
// log.Fatal(err)
// }
defer close(app.MailChan)
listenForMail()

Expand Down Expand Up @@ -57,21 +55,21 @@ func run() error {
return nil
}

func runCron() error {
task := func(in string) {
log.Println("run something here")
// webhook.Values()
// func runCron() error {
// task := func(in string) {
// log.Println("run something here")
// // webhook.Values()

}
s := gocron.NewScheduler(time.UTC)
s.SingletonModeAll()
j, err := s.Cron("*/1 * * * *").Do(task, "test")
if err != nil {
log.Fatalln("error scheduling job", err)
}
s.StartAsync()
log.Printf("Next Run: %s", j.NextRun())
// }
// s := gocron.NewScheduler(time.UTC)
// s.SingletonModeAll()
// j, err := s.Cron("*/1 * * * *").Do(task, "test")
// if err != nil {
// log.Fatalln("error scheduling job", err)
// }
// s.StartAsync()
// log.Printf("Next Run: %s", j.NextRun())

return nil
// return nil

}
// }
8 changes: 2 additions & 6 deletions internal/handlers/handers.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func NewHandlers(r *Repository) {

// The Home function renders the home page template in Go.
func (m *Repository) Home(w http.ResponseWriter, r *http.Request) {
log.Println("path / called")
log.Println(r.Header)
}

func (m *Repository) GHWebhook(w http.ResponseWriter, req *http.Request) {
Expand Down Expand Up @@ -69,7 +69,7 @@ func (m *Repository) GHWebhook(w http.ResponseWriter, req *http.Request) {

data, err := HandlePullRequestEvent(payload.(github.PullRequestPayload))
if err != nil {
log.Println("Couldnt process", err)
log.Println("couldn't process", err)
}
m.App.MailChan <- data

Expand Down Expand Up @@ -104,8 +104,4 @@ func (m *Repository) AlertWebhook(w http.ResponseWriter, r *http.Request) {
}
}

// if msg.Receiver == "go-webhook" && msg.Status == "firing" {

// }

}
5 changes: 2 additions & 3 deletions internal/webhook/alertmanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,9 @@ import (
func getDeployment(queue string) (string, error) {
queueDeployments := map[string]string{
"remittance-queue": "remittance-worker",
"batch": "batch-queue",
"elastic_search": "es-queue",
"batch-queue": "batch-worker",
"elastic-queue": "elastic-worker",
"webhook": "webhook-worker",
"webhook1": "webhook-worker1",
}

for k, v := range queueDeployments {
Expand Down