feat(scraper): bound article enrichment diagnostics (#40)

This commit is contained in:
2026-11-25 00:07:45 +01:00
parent a3c70670f6
commit 6883b3976b
53 changed files with 4049 additions and 68 deletions

View File

@ -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
}