diff --git a/feeds/crates/crates.go b/feeds/crates/crates.go index 091df419..b01f0b7b 100644 --- a/feeds/crates/crates.go +++ b/feeds/crates/crates.go @@ -5,6 +5,7 @@ import ( "net/http" "time" + "github.com/ossf/package-feeds/events" "github.com/ossf/package-feeds/feeds" ) @@ -51,6 +52,13 @@ func fetchPackages() ([]*Package, error) { } type Feed struct { + lossyFeedAlerter *feeds.LossyFeedAlerter +} + +func New(eventHandler *events.Handler) *Feed { + return &Feed{ + lossyFeedAlerter: feeds.NewLossyFeedAlerter(eventHandler), + } } func (feed Feed) Latest(cutoff time.Time) ([]*feeds.Package, error) { @@ -66,6 +74,7 @@ func (feed Feed) Latest(cutoff time.Time) ([]*feeds.Package, error) { } pkgs = append(pkgs, pkg) } + feed.lossyFeedAlerter.ProcessPackages(FeedName, pkgs) pkgs = feeds.ApplyCutoff(pkgs, cutoff) return pkgs, nil } diff --git a/feeds/crates/crates_test.go b/feeds/crates/crates_test.go index d11fd639..b81bbe62 100644 --- a/feeds/crates/crates_test.go +++ b/feeds/crates/crates_test.go @@ -5,6 +5,7 @@ import ( "testing" "time" + "github.com/ossf/package-feeds/events" "github.com/ossf/package-feeds/testutils" ) @@ -17,7 +18,7 @@ func TestCratesLatest(t *testing.T) { srv := testutils.HttpServerMock(handlers) baseURL = srv.URL + "/api/v1/summary" - feed := Feed{} + feed := New(events.NewNullHandler()) cutoff := time.Date(1970, 1, 1, 0, 0, 0, 0, time.UTC) pkgs, err := feed.Latest(cutoff) diff --git a/feeds/pypi/pypi.go b/feeds/pypi/pypi.go index 4e4f0bf3..e8fa39f4 100644 --- a/feeds/pypi/pypi.go +++ b/feeds/pypi/pypi.go @@ -6,6 +6,7 @@ import ( "strings" "time" + "github.com/ossf/package-feeds/events" "github.com/ossf/package-feeds/feeds" ) @@ -73,6 +74,13 @@ func fetchPackages() ([]*Package, error) { } type Feed struct { + lossyFeedAlerter *feeds.LossyFeedAlerter +} + +func New(eventHandler *events.Handler) *Feed { + return &Feed{ + lossyFeedAlerter: feeds.NewLossyFeedAlerter(eventHandler), + } } func (feed Feed) Latest(cutoff time.Time) ([]*feeds.Package, error) { @@ -88,6 +96,7 @@ func (feed Feed) Latest(cutoff time.Time) ([]*feeds.Package, error) { } pkgs = append(pkgs, pkg) } + feed.lossyFeedAlerter.ProcessPackages(FeedName, pkgs) pkgs = feeds.ApplyCutoff(pkgs, cutoff) return pkgs, nil } diff --git a/feeds/pypi/pypi_test.go b/feeds/pypi/pypi_test.go index 879bd1cb..d1edb3fe 100644 --- a/feeds/pypi/pypi_test.go +++ b/feeds/pypi/pypi_test.go @@ -5,6 +5,7 @@ import ( "testing" "time" + "github.com/ossf/package-feeds/events" "github.com/ossf/package-feeds/testutils" ) @@ -17,7 +18,7 @@ func TestPypiLatest(t *testing.T) { srv := testutils.HttpServerMock(handlers) baseURL = srv.URL + "/rss/updates.xml" - feed := Feed{} + feed := New(events.NewNullHandler()) cutoff := time.Date(1970, 1, 1, 0, 0, 0, 0, time.UTC) pkgs, err := feed.Latest(cutoff)