Skip to content

Commit

Permalink
Fix golang problem with cron job funcionality
Browse files Browse the repository at this point in the history
  • Loading branch information
vvalvesga committed Sep 16, 2019
1 parent b8db1e3 commit 711104d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion microservices/ri-orchestration-twitter/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.9
FROM golang:1.10
WORKDIR /go/src/app
COPY . .
RUN go get -d -v ./...
Expand Down
6 changes: 4 additions & 2 deletions microservices/ri-orchestration-twitter/observer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
}
Expand Down Expand Up @@ -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)
}
Expand Down

0 comments on commit 711104d

Please sign in to comment.