comparison calsync/event_sync.go @ 60:3b0595c2bf03

logging and small refactors
author drewp@bigasterisk.com
date Fri, 06 Sep 2024 16:41:48 -0700
parents 6c7151126a0b
children 8aee4f5c4bdd
comparison
equal deleted inserted replaced
59:1f8e66cb0108 60:3b0595c2bf03
17 func updateMongoEventsToMatchGoogleForever( 17 func updateMongoEventsToMatchGoogleForever(
18 mc *mongoclient.MongoClient, 18 mc *mongoclient.MongoClient,
19 gc *gcalclient.GCalClient, 19 gc *gcalclient.GCalClient,
20 keepHistory time.Duration, 20 keepHistory time.Duration,
21 syncAhead time.Duration) error { 21 syncAhead time.Duration) error {
22 log.Println("starting updateMongoEventsToMatchGoogleForever")
22 23
23 now := time.Now() 24 now := time.Now()
24 syncStart := now.Add(-keepHistory) 25 syncStart := now.Add(-keepHistory)
25 syncEnd := now.Add(syncAhead) 26 syncEnd := now.Add(syncAhead)
26 // Note that we could receive updates outside this interval. 27 // Note that we could receive updates outside this interval.
33 34
34 for _, cal := range cals { 35 for _, cal := range cals {
35 rd := newCalEventsReader(mc, gc, cal, syncStart, syncEnd) 36 rd := newCalEventsReader(mc, gc, cal, syncStart, syncEnd)
36 go rd.updateForever() 37 go rd.updateForever()
37 } 38 }
38 return nil // return a mapping of webhook name to calEventsReader? 39 return nil
39 } 40 }
40 41
41 // i think this should own the webhook watcher
42 type calEventsReader struct { 42 type calEventsReader struct {
43 mc *mongoclient.MongoClient 43 mc *mongoclient.MongoClient
44 gc *gcalclient.GCalClient 44 gc *gcalclient.GCalClient
45 cal M.MongoCal 45 cal M.MongoCal
46 t1, t2 time.Time 46 t1, t2 time.Time