feat(scraper): bound article enrichment diagnostics (#40)
This commit is contained in:
@ -8,6 +8,7 @@ import (
|
||||
"fmt"
|
||||
"io"
|
||||
"net/http"
|
||||
"os"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
@ -15,8 +16,9 @@ import (
|
||||
)
|
||||
|
||||
type Bloomberg struct {
|
||||
scraperURL string
|
||||
client *http.Client
|
||||
scraperURL string
|
||||
client *http.Client
|
||||
diagnostics io.Writer
|
||||
}
|
||||
|
||||
func New(scraperURL string) *Bloomberg {
|
||||
@ -29,6 +31,15 @@ func New(scraperURL string) *Bloomberg {
|
||||
}
|
||||
}
|
||||
|
||||
// NewWithClient uses the same production RPC DTOs and validation with injected I/O.
|
||||
func NewWithClient(scraperURL string, client *http.Client, diagnostics io.Writer) *Bloomberg {
|
||||
b := New(scraperURL)
|
||||
if client != nil {
|
||||
b.client = client
|
||||
}
|
||||
b.diagnostics = diagnostics
|
||||
return b
|
||||
}
|
||||
func (b *Bloomberg) Name() string { return "bloomberg" }
|
||||
|
||||
type scraperRequest struct {
|
||||
@ -99,7 +110,11 @@ func (b *Bloomberg) ScrapeWithCredentials(ctx context.Context, username, passwor
|
||||
Symbols: syms,
|
||||
})
|
||||
}
|
||||
fmt.Printf("bloomberg: %d articles fetched\n", len(articles))
|
||||
writer := b.diagnostics
|
||||
if writer == nil {
|
||||
writer = os.Stdout
|
||||
}
|
||||
fmt.Fprintf(writer, "bloomberg: %d articles fetched\n", len(articles))
|
||||
return articles, nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user