From 711104dde7ec8f109671f21a6fcee16c4f3f32c2 Mon Sep 17 00:00:00 2001 From: Victor Date: Mon, 16 Sep 2019 11:18:37 +0000 Subject: [PATCH] Fix golang problem with cron job funcionality --- microservices/ri-orchestration-twitter/Dockerfile | 2 +- microservices/ri-orchestration-twitter/observer.go | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/microservices/ri-orchestration-twitter/Dockerfile b/microservices/ri-orchestration-twitter/Dockerfile index 83bab07..5ff4453 100644 --- a/microservices/ri-orchestration-twitter/Dockerfile +++ b/microservices/ri-orchestration-twitter/Dockerfile @@ -1,4 +1,4 @@ -FROM golang:1.9 +FROM golang:1.10 WORKDIR /go/src/app COPY . . RUN go get -d -v ./... diff --git a/microservices/ri-orchestration-twitter/observer.go b/microservices/ri-orchestration-twitter/observer.go index 1dc7ec0..4c9f96e 100644 --- a/microservices/ri-orchestration-twitter/observer.go +++ b/microservices/ri-orchestration-twitter/observer.go @@ -50,7 +50,7 @@ func AddObservable(observable ObservableTwitter) { } fmt.Printf("[%s] 2.2.3: add cron job\n", accountName) - err := observableManager[accountName].CronJob.AddFunc(getObserverInterval(interval), func() { + spec, err := observableManager[accountName].CronJob.AddFunc(getObserverInterval(interval), func() { fmt.Printf("[%s] 2.3: crawl tweets\n", accountName) crawledTweets := crawlObservableTweets(accountName, lang) storeCrawledTweets(crawledTweets) @@ -76,6 +76,7 @@ func AddObservable(observable ObservableTwitter) { fmt.Printf("[%s] 2.6: topics extracted and stored\n", accountName) } }) + fmt.Printf("%s", spec) if err != nil { fmt.Printf("ERR - could not add %s as observer\nGot error: %v\n---\n", accountName, err) } @@ -210,9 +211,10 @@ func storeTweetsTopics(tweet Tweet) { func ObserveUnclassifiedTweets() { observerUnclassifiedTweets = cron.New() - err := observerUnclassifiedTweets.AddFunc(getObserverInterval("midnight"), func() { + spec, err := observerUnclassifiedTweets.AddFunc(getObserverInterval("midnight"), func() { retrieveAndProcessUnclassifiedTweets() }) + fmt.Printf("%s", spec) if err != nil { fmt.Println("ERR - could not add the observer for unclassified tweets", err) }