-
Notifications
You must be signed in to change notification settings - Fork 1
/
cron.go
41 lines (33 loc) · 995 Bytes
/
cron.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package backend
import (
"context"
"net/http"
"time"
"github.com/utahta/momoclo-channel/adapter/handler"
"github.com/utahta/momoclo-channel/container"
)
// CronReminder checks reminder
func CronReminder(w http.ResponseWriter, req *http.Request) {
ctx := req.Context()
if err := container.Usecase(ctx).Remind().Do(); err != nil {
handler.Fail(ctx, w, err, http.StatusInternalServerError)
return
}
}
// CronUstream checks ustream status
func CronUstream(w http.ResponseWriter, req *http.Request) {
ctx := req.Context()
if err := container.Usecase(ctx).CheckUstream().Do(); err != nil {
handler.Fail(ctx, w, err, http.StatusInternalServerError)
return
}
}
// CronCrawl crawling some sites
func CronCrawl(w http.ResponseWriter, req *http.Request) {
ctx, cancel := context.WithTimeout(req.Context(), 30*time.Second)
defer cancel()
if err := container.Usecase(ctx).CrawlFeeds().Do(); err != nil {
handler.Fail(ctx, w, err, http.StatusInternalServerError)
return
}
}