feat: replace model with store (#322)

This commit is contained in:
zhaoyang
2021-12-13 21:23:01 +08:00
committed by GitHub
parent 9a787d2362
commit 28fb141819
3 changed files with 150 additions and 173 deletions

View File

@@ -1,8 +1,12 @@
package main
import (
"time"
"github.com/micro/micro/v3/service"
"github.com/micro/micro/v3/service/logger"
"github.com/micro/micro/v3/service/store"
"github.com/micro/services/pkg/tracing"
"github.com/micro/services/rss/handler"
pb "github.com/micro/services/rss/proto"
@@ -14,8 +18,21 @@ func main() {
service.Name("rss"),
)
st := store.DefaultStore
crawl := handler.NewCrawl(st)
rss := handler.NewRss(st, crawl)
// crawl
go func() {
crawl.FetchAll()
tick := time.NewTicker(1 * time.Minute)
for _ = range tick.C {
crawl.FetchAll()
}
}()
// Register handler
pb.RegisterRssHandler(srv.Server(), handler.NewRss())
pb.RegisterRssHandler(srv.Server(), rss)
traceCloser := tracing.SetupOpentracing("rss")
defer traceCloser.Close()