Documentation
¶
Index ¶
- type Content
- type Job
- type JobStatus
- type Page
- type SQLiteStorage
- func (s *SQLiteStorage) Close() error
- func (s *SQLiteStorage) GetContent(ctx context.Context, contentID string) (*Content, error)
- func (s *SQLiteStorage) GetContentByURL(ctx context.Context, url string) (*Content, error)
- func (s *SQLiteStorage) GetJob(ctx context.Context, jobID string) (*Job, error)
- func (s *SQLiteStorage) GetLastScrapeTime(ctx context.Context, url string) (time.Time, error)
- func (s *SQLiteStorage) GetScrapedPages(ctx context.Context, limit int) ([]Page, error)
- func (s *SQLiteStorage) GetScrapedPagesCount(ctx context.Context) (int, error)
- func (s *SQLiteStorage) GetScrapedPagesPaginated(ctx context.Context, limit int, offset int) ([]Page, error)
- func (s *SQLiteStorage) SaveContent(ctx context.Context, content *Content) error
- func (s *SQLiteStorage) SaveJob(ctx context.Context, job *Job) error
- func (s *SQLiteStorage) SaveScrapedData(ctx context.Context, url string, scrapedAt time.Time, contentHash string) error
- func (s *SQLiteStorage) UpdateJobStatus(ctx context.Context, jobID string, status JobStatus, errorMessage string) error
- type Storage
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Content ¶
type Content struct {
ID string
URL string
Title string
TextContent string
RawHTML string
Links []string
Images []string
ScrapedAt time.Time
ContentHash string
Metadata map[string]string
}
Content represents scraped content
type Job ¶
type Job struct {
ID string
URL string
Status JobStatus
CreatedAt time.Time
UpdatedAt time.Time
ErrorMessage string
RetryCount int32
ContentID string // Links to content table
}
Job represents a scraping job
type SQLiteStorage ¶
type SQLiteStorage struct {
// contains filtered or unexported fields
}
SQLiteStorage implements the Storage interface using SQLite
func (*SQLiteStorage) Close ¶
func (s *SQLiteStorage) Close() error
Close closes the database connection
func (*SQLiteStorage) GetContent ¶
GetContent retrieves content by ID
func (*SQLiteStorage) GetContentByURL ¶
GetContentByURL retrieves content by URL
func (*SQLiteStorage) GetLastScrapeTime ¶
GetLastScrapeTime retrieves the last time a URL was scraped. Returns sql.ErrNoRows if the URL has not been scraped.
func (*SQLiteStorage) GetScrapedPages ¶
GetScrapedPages retrieves a list of scraped pages
func (*SQLiteStorage) GetScrapedPagesCount ¶
func (s *SQLiteStorage) GetScrapedPagesCount(ctx context.Context) (int, error)
GetScrapedPagesCount returns the total count of scraped pages
func (*SQLiteStorage) GetScrapedPagesPaginated ¶
func (s *SQLiteStorage) GetScrapedPagesPaginated(ctx context.Context, limit int, offset int) ([]Page, error)
GetScrapedPagesPaginated retrieves a paginated list of scraped pages
func (*SQLiteStorage) SaveContent ¶
func (s *SQLiteStorage) SaveContent(ctx context.Context, content *Content) error
SaveContent saves scraped content to the database
func (*SQLiteStorage) SaveJob ¶
func (s *SQLiteStorage) SaveJob(ctx context.Context, job *Job) error
SaveJob saves a job to the database
func (*SQLiteStorage) SaveScrapedData ¶
func (s *SQLiteStorage) SaveScrapedData(ctx context.Context, url string, scrapedAt time.Time, contentHash string) error
SaveScrapedData saves metadata about a scraped page
func (*SQLiteStorage) UpdateJobStatus ¶
func (s *SQLiteStorage) UpdateJobStatus(ctx context.Context, jobID string, status JobStatus, errorMessage string) error
UpdateJobStatus updates the status of a job
type Storage ¶
type Storage interface {
// Job tracking methods
SaveJob(ctx context.Context, job *Job) error
GetJob(ctx context.Context, jobID string) (*Job, error)
UpdateJobStatus(ctx context.Context, jobID string, status JobStatus, errorMessage string) error
// Content methods
SaveContent(ctx context.Context, content *Content) error
GetContent(ctx context.Context, contentID string) (*Content, error)
GetContentByURL(ctx context.Context, url string) (*Content, error)
// Legacy methods (for compatibility)
SaveScrapedData(ctx context.Context, url string, scrapedAt time.Time, contentHash string) error
GetLastScrapeTime(ctx context.Context, url string) (time.Time, error)
GetScrapedPages(ctx context.Context, limit int) ([]Page, error)
GetScrapedPagesCount(ctx context.Context) (int, error)
GetScrapedPagesPaginated(ctx context.Context, limit int, offset int) ([]Page, error)
Close() error
}
Storage defines the interface for data persistence
func NewSQLiteStorage ¶
func NewSQLiteStorage(cfg config.DatabaseConfig) (Storage, error)
NewSQLiteStorage creates a new SQLite-based storage