-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathcloud.functions.go
More file actions
51 lines (40 loc) · 857 Bytes
/
cloud.functions.go
File metadata and controls
51 lines (40 loc) · 857 Bytes
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
42
43
44
45
46
47
48
49
50
51
package wakeup
import (
"context"
"log"
"net/http"
"github.com/evt/wakeup/config"
"github.com/evt/wakeup/db"
"github.com/evt/wakeup/db/migrations"
"github.com/evt/wakeup/scheduler"
"github.com/evt/wakeup/server"
)
var s *server.Server
func init() {
ctx := context.Background()
// config
cfg := config.Get()
pgDB, err := db.Dial(cfg)
if err != nil {
log.Fatal(err)
}
// Run Postgres migrations
if err := migrations.Run(pgDB); err != nil {
log.Fatal(err)
}
// create google cloud scheduler client
sch, err := scheduler.Init(ctx)
if err != nil {
log.Fatal(err)
}
// create new server instance
s = server.Init(ctx, cfg, pgDB, sch)
}
// ScheduleCall
func ScheduleCall(w http.ResponseWriter, r *http.Request) {
s.ScheduleCall(w, r)
}
// CallRoom
func CallRoom(w http.ResponseWriter, r *http.Request) {
s.CallRoom(w, r)
}