core

package
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 29, 2025 License: Apache-2.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ArticleService

type ArticleService struct {
	// contains filtered or unexported fields
}

func NewArticleService

func NewArticleService(feedRepo *repository.FeedRepository, articleRepo *repository.ArticleRepository, eventProducer events.ArticleEventProducer, logger *slog.Logger) *ArticleService

func (*ArticleService) FetchAndSaveArticles

func (s *ArticleService) FetchAndSaveArticles(ctx context.Context, feedID uint) ([]*models.Article, error)

func (*ArticleService) GetArticleByID

func (s *ArticleService) GetArticleByID(ctx context.Context, userID, articleID uint) (*models.Article, error)

func (*ArticleService) HandleArticleProcessed

func (s *ArticleService) HandleArticleProcessed(ctx context.Context, event *article_eventspb.ArticleProcessedEvent) error

HandleArticleProcessed handles an ArticleProcessedEvent by updating the article with AI data

func (*ArticleService) ListArticlesByFeedID

func (s *ArticleService) ListArticlesByFeedID(ctx context.Context, userID, feedID uint) ([]*models.Article, error)

func (*ArticleService) ListArticlesToCheck

func (s *ArticleService) ListArticlesToCheck(ctx context.Context, publishedSince, lastCheckedBefore time.Time, pageSize int, pageToken string) ([]repository.ArticleCheckCandidate, string, error)

type ArticleServiceInterface

type ArticleServiceInterface interface {
	FetchAndSaveArticles(ctx context.Context, feedID uint) ([]*models.Article, error)
	ListArticlesByFeedID(ctx context.Context, userID, feedID uint) ([]*models.Article, error)
	GetArticleByID(ctx context.Context, userID, articleID uint) (*models.Article, error)
	HandleArticleProcessed(ctx context.Context, event *article_eventspb.ArticleProcessedEvent) error
	ListArticlesToCheck(ctx context.Context, publishedSince, lastCheckedBefore time.Time, pageSize int, pageToken string) ([]repository.ArticleCheckCandidate, string, error)
}

type ArticleUpdateChecker

type ArticleUpdateChecker struct {
	// contains filtered or unexported fields
}

func NewArticleUpdateChecker

func NewArticleUpdateChecker(repo *repository.ArticleRepository, logger *slog.Logger, httpClient *http.Client, robots *RobotsClient, cfg ArticleUpdateConfig) *ArticleUpdateChecker

func (*ArticleUpdateChecker) HandleEvent

type ArticleUpdateConfig

type ArticleUpdateConfig struct {
	UserAgent       string
	MaxAttempts     int
	BackoffInitial  time.Duration
	BackoffMax      time.Duration
	Jitter          bool
	MaxContentBytes int64
	RespectRobots   bool
}

type BatchSubscribeResult

type BatchSubscribeResult struct {
	URL     string
	Success bool
	Error   string
	Feed    *models.Feed
}

BatchSubscribeResult represents the result of a single feed subscription attempt

type FeedService

type FeedService struct {
	// contains filtered or unexported fields
}

func NewFeedService

func NewFeedService(repo *repository.FeedRepository, logger *slog.Logger, producer events.Producer) *FeedService

NewFeedService creates a FeedService. Producer can be nil (sync mode).

func (*FeedService) AddFeedByURL

func (s *FeedService) AddFeedByURL(ctx context.Context, url string) (*models.Feed, error)

func (*FeedService) BatchSubscribeToFeeds

func (s *FeedService) BatchSubscribeToFeeds(ctx context.Context, userID uint, urls []string) ([]BatchSubscribeResult, error)

BatchSubscribeToFeeds subscribes a user to multiple feeds in a single batch operation.

func (*FeedService) IsUserSubscribed

func (s *FeedService) IsUserSubscribed(ctx context.Context, userID, feedID uint) (bool, error)

IsUserSubscribed check if a user is subscribed to a feed

func (*FeedService) ListAllFeeds

func (s *FeedService) ListAllFeeds(ctx context.Context) ([]*models.Feed, error)

func (*FeedService) ListUserFeeds

func (s *FeedService) ListUserFeeds(ctx context.Context, userID uint) ([]*models.UserFeed, error)

func (*FeedService) SubscribeToFeed

func (s *FeedService) SubscribeToFeed(ctx context.Context, userID uint, url string) (*models.Feed, error)

func (*FeedService) UnsubscribeFromFeed

func (s *FeedService) UnsubscribeFromFeed(ctx context.Context, userID, feedID uint) error

func (*FeedService) UpdateFeedCustomTitle

func (s *FeedService) UpdateFeedCustomTitle(ctx context.Context, userID, feedID uint, customTitle *string) (*models.UserFeed, error)

type FeedServiceInterface

type FeedServiceInterface interface {
	AddFeedByURL(ctx context.Context, url string) (*models.Feed, error)
	ListAllFeeds(ctx context.Context) ([]*models.Feed, error)
	SubscribeToFeed(ctx context.Context, userID uint, url string) (*models.Feed, error)
	BatchSubscribeToFeeds(ctx context.Context, userID uint, urls []string) ([]BatchSubscribeResult, error)
	ListUserFeeds(ctx context.Context, userID uint) ([]*models.UserFeed, error)
	UnsubscribeFromFeed(ctx context.Context, userID, feedID uint) error
	IsUserSubscribed(ctx context.Context, userID, feedID uint) (bool, error)
	UpdateFeedCustomTitle(ctx context.Context, userID, feedID uint, customTitle *string) (*models.UserFeed, error)
}

type RobotsClient

type RobotsClient struct {
	// contains filtered or unexported fields
}

func NewRobotsClient

func NewRobotsClient(httpClient *http.Client, ttl time.Duration, logger *slog.Logger) *RobotsClient

func (*RobotsClient) IsAllowed

func (c *RobotsClient) IsAllowed(ctx context.Context, rawURL, userAgent string) (bool, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL