本文整理汇总了Golang中github.com/urandom/readeef/content.Feed.Err方法的典型用法代码示例。如果您正苦于以下问题:Golang Feed.Err方法的具体用法?Golang Feed.Err怎么用?Golang Feed.Err使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/urandom/readeef/content.Feed
的用法示例。
在下文中一共展示了Feed.Err方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: stopUpdatingFeed
func (fm *FeedManager) stopUpdatingFeed(f content.Feed) {
if f == nil {
fm.logger.Infoln("No feed provided")
return
}
data := f.Data()
fm.logger.Infoln("Stopping feed update for " + data.Link)
delete(fm.activeFeeds, data.Id)
users := f.Users()
if f.HasErr() {
fm.logger.Printf("Error getting users for feed '%s': %v\n", f, f.Err())
} else {
if len(users) == 0 {
fm.logger.Infoln("Removing orphan feed " + f.String() + " from the database")
for _, m := range fm.feedMonitors {
if err := m.FeedDeleted(f); err != nil {
fm.logger.Printf(
"Error invoking monitor '%s' on deleted feed '%s': %v\n",
reflect.TypeOf(m), f, err)
}
}
f.Delete()
if f.HasErr() {
fm.logger.Printf("Error deleting feed '%s' from the repository: %v\n", f, f.Err())
}
}
}
}
示例2: addFeeds
func addFeeds(user content.User, fm *readeef.FeedManager, links []string) (resp responseError) {
resp = newResponse()
var err error
errs := make([]addFeedError, 0, len(links))
for _, link := range links {
var u *url.URL
if u, err = url.Parse(link); err != nil {
resp.err = err
errs = append(errs, addFeedError{Link: link, Error: "Error parsing link"})
continue
} else if !u.IsAbs() {
resp.err = errors.New("Feed has no link")
errs = append(errs, addFeedError{Link: link, Error: resp.err.Error()})
continue
} else {
var f content.Feed
if f, err = fm.AddFeedByLink(link); err != nil {
resp.err = err
errs = append(errs, addFeedError{Link: link, Error: "Error adding feed to the database"})
continue
}
uf := user.AddFeed(f)
if uf.HasErr() {
resp.err = f.Err()
errs = append(errs, addFeedError{Link: link, Title: f.Data().Title, Error: "Error adding feed to the database"})
continue
}
tags := strings.SplitN(u.Fragment, ",", -1)
if u.Fragment != "" && len(tags) > 0 {
repo := uf.Repo()
tf := repo.TaggedFeed(user)
tf.Data(uf.Data())
t := make([]content.Tag, len(tags))
for i := range tags {
t[i] = repo.Tag(user)
t[i].Data(data.Tag{Value: data.TagValue(tags[i])})
}
tf.Tags(t)
if tf.UpdateTags(); tf.HasErr() {
resp.err = tf.Err()
errs = append(errs, addFeedError{Link: link, Title: f.Data().Title, Error: "Error adding feed to the database"})
continue
}
}
}
}
resp.val["Errors"] = errs
resp.val["Success"] = len(errs) < len(links)
return
}
示例3: updateFeed
func (fm FeedManager) updateFeed(f content.Feed) {
f.Update()
if f.HasErr() {
fm.logger.Printf("Error updating feed '%s' database record: %v\n", f, f.Err())
} else {
fm.processFeedUpdateMonitors(f)
}
}
示例4: AddFeed
func (u *User) AddFeed(f content.Feed) (uf content.UserFeed) {
uf = u.Repo().UserFeed(u)
if u.HasErr() {
uf.Err(u.Err())
return
}
if err := u.Validate(); err != nil {
u.Err(err)
return
}
d := f.Data()
if f.HasErr() {
uf.Data(d)
uf.Err(f.Err())
return
}
if err := f.Validate(); err != nil {
uf.Err(err)
return
}
login := u.Data().Login
u.logger.Infof("Getting user feed for user %s and feed %d\n", login, d.Id)
tx, err := u.db.Beginx()
if err != nil {
uf.Err(err)
return
}
defer tx.Rollback()
stmt, err := tx.Preparex(u.db.SQL().User.CreateFeed)
if err != nil {
uf.Err(err)
return
}
defer stmt.Close()
_, err = stmt.Exec(u.Data().Login, d.Id)
if err != nil {
uf.Err(err)
return
}
if err := tx.Commit(); err != nil {
uf.Err(err)
}
uf.Data(d)
return
}
示例5: FeedUpdated
func (i Unread) FeedUpdated(feed content.Feed) error {
i.logger.Infof("Adding 'unread' states for all new articles of %s' for all users\n", feed)
feed.SetNewArticlesUnread()
if feed.HasErr() {
return feed.Err()
} else {
return nil
}
}
示例6: DeleteFeed
func (si SearchIndex) DeleteFeed(feed content.Feed) error {
articles := feed.AllArticles()
if !feed.HasErr() {
si.logger.Infof("Removing all articles from the search index for feed '%s'\n", feed)
si.batchDelete(articles)
} else {
return feed.Err()
}
return nil
}
示例7: subscription
func (h Hubbub) subscription(s content.Subscription, f content.Feed, subscribe bool) {
var err error
fdata := f.Data()
u := callbackURL(h.config, h.pattern, fdata.Id)
body := url.Values{}
body.Set("hub.callback", u)
if subscribe {
h.logger.Infoln("Subscribing to hubbub for " + f.String() + " with url " + u)
body.Set("hub.mode", "subscribe")
} else {
h.logger.Infoln("Unsubscribing to hubbub for " + f.String() + " with url " + u)
body.Set("hub.mode", "unsubscribe")
}
body.Set("hub.topic", fdata.Link)
buf := util.BufferPool.GetBuffer()
defer util.BufferPool.Put(buf)
buf.WriteString(body.Encode())
req, _ := http.NewRequest("POST", s.Data().Link, buf)
req.Header.Add("Content-Type", "application/x-www-form-urlencoded")
req.Header.Add("From", h.config.Hubbub.From)
resp, err := h.client.Do(req)
if err != nil {
err = SubscriptionError{error: err, Subscription: s}
} else if resp.StatusCode != 202 {
err = SubscriptionError{error: errors.New("Expected response status 202, got " + resp.Status), Subscription: s}
}
if err == nil {
if subscribe {
h.subscribe <- s
} else {
h.unsubscribe <- s
}
} else {
fdata.SubscribeError = err.Error()
h.logger.Printf("Error subscribing to hub feed '%s': %s\n", f, err)
f.Data(fdata)
f.Update()
if f.HasErr() {
h.logger.Printf("Error updating feed database record for '%s': %s\n", f, f.Err())
}
h.removeFeed <- f
}
}
示例8: addFeed
func addFeed(user content.User, fm *readeef.FeedManager, links []string) (resp responseError) {
resp = newResponse()
success := false
for _, link := range links {
var u *url.URL
if u, resp.err = url.Parse(link); resp.err != nil {
/* TODO: non-fatal error */
return
} else if !u.IsAbs() {
/* TODO: non-fatal error */
resp.err = errors.New("Feed has no link")
return
} else {
var f content.Feed
if f, resp.err = fm.AddFeedByLink(link); resp.err != nil {
return
}
uf := user.AddFeed(f)
if uf.HasErr() {
resp.err = f.Err()
return
}
tags := strings.SplitN(u.Fragment, ",", -1)
if u.Fragment != "" && len(tags) > 0 {
repo := uf.Repo()
tf := repo.TaggedFeed(user)
tf.Data(uf.Data())
t := make([]content.Tag, len(tags))
for i := range tags {
t[i] = repo.Tag(user)
t[i].Value(data.TagValue(tags[i]))
}
tf.Tags(t)
if tf.UpdateTags(); tf.HasErr() {
resp.err = tf.Err()
return
}
}
success = true
}
}
resp.val["Success"] = success
return
}
示例9: scoreFeedContent
func (fm *FeedManager) scoreFeedContent(f content.Feed) {
if f == nil {
fm.logger.Infoln("No feed provided")
return
}
data := f.Data()
if len(fm.config.Popularity.Providers) == 0 {
fm.logger.Infoln("No popularity providers configured")
return
}
if !fm.activeFeeds[data.Id] {
fm.logger.Infof("Feed '%s' no longer active for scoring\n", f)
return
}
fm.logger.Infoln("Scoring feed content for " + f.String())
articles := f.LatestArticles()
if f.HasErr() {
fm.logger.Printf("Error getting latest feed articles for '%s': %v\n", f, f.Err())
return
}
for i := range articles {
sa := fm.repo.Article()
sa.Data(articles[i].Data())
fm.scoreArticle <- sa
}
fm.logger.Infoln("Done scoring feed content for " + f.String())
select {
case <-time.After(30 * time.Minute):
go fm.scoreFeedContent(f)
case <-fm.done:
return
}
}
示例10: FeedDeleted
func (i Index) FeedDeleted(feed content.Feed) error {
i.logger.Infof("Deleting article search index for feed '%s'\n", feed)
articles := feed.AllArticles()
if feed.HasErr() {
return fmt.Errorf("Error deleting all articles of %s from the search index: %v\n", feed, feed.Err())
} else {
i.logger.Infof("Deleting article search index for feed '%s'\n", feed)
return i.provider.BatchIndex(articles, data.BatchDelete)
}
}