Files

34 lines
1.4 KiB
Go

package ingestionbench
import (
"context"
"github.com/tradarr/backend/internal/scraper"
"github.com/tradarr/backend/internal/scraper/bloomberg"
"github.com/tradarr/backend/internal/scraper/cnbcbusiness"
"github.com/tradarr/backend/internal/scraper/yahoofinance"
"io"
"net/http"
)
// This wrapper supplies the already-provided credentials to the production RPC
// methods. It contains no collector, parser or enrichment implementation.
type bloombergFeed struct {
client *bloomberg.Bloomberg
username, password string
}
func (b bloombergFeed) Name() string { return "bloomberg" }
func (b bloombergFeed) Scrape(ctx context.Context, s []string) ([]scraper.Article, error) {
return b.client.ScrapeWithCredentials(ctx, b.username, b.password, s)
}
func (b bloombergFeed) Enrich(ctx context.Context, a []scraper.Article) ([]scraper.Article, error) {
return b.client.EnrichWithCredentials(ctx, b.username, b.password, a)
}
func ProductionSources(articleClient, rpcClient *http.Client, scraperURL, username, password, symbol string) []Source {
return []Source{
{Key: "yahoo_finance", Feed: yahoofinance.NewWithClient(articleClient, io.Discard), Symbols: []string{symbol}},
{Key: "cnbc_business", Feed: cnbcbusiness.NewWithClient(articleClient, io.Discard)},
{Key: "bloomberg", Feed: bloombergFeed{bloomberg.NewWithClient(scraperURL, rpcClient, io.Discard), username, password}},
}
}