services

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type SearchResult

type SearchResult struct {
	URLID uint    `json:"url_id"`
	Score float64 `json:"score"`
}

SearchResult represents a unified search result.

type SearchService

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

SearchService provides keyword, semantic, and hybrid search.

func NewSearchService

func NewSearchService(ks *search.KeywordSearch, vs *search.VectorSearch, llmClient *llm.LLMClient) *SearchService

func (*SearchService) HybridSearch

func (s *SearchService) HybridSearch(ctx context.Context, query string, limit int) ([]SearchResult, error)

HybridSearch combines keyword and semantic search with equal weights.

func (*SearchService) KeywordSearch

func (s *SearchService) KeywordSearch(query string, limit int) ([]SearchResult, error)

KeywordSearch performs FTS5 keyword search.

func (*SearchService) SemanticSearch

func (s *SearchService) SemanticSearch(ctx context.Context, query string, limit int) ([]SearchResult, error)

SemanticSearch performs vector similarity search.

type ShortURLService

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

ShortURLService provides business logic for short link management.

func NewShortURLService

func NewShortURLService(shortRepo repos.ShortURLRepo) *ShortURLService

NewShortURLService creates a new ShortURLService.

func (s *ShortURLService) DeleteShortLink(id uint) error

DeleteShortLink soft-deletes a short link by its ID.

func (s *ShortURLService) GenerateShortLink(longURL string, ttl *time.Duration) (*entity.ShortLink, error)

GenerateShortLink creates a new short link for the given long URL. If ttl is provided, the link will expire after the given duration.

func (s *ShortURLService) ListShortLinks(page, size int) ([]*entity.ShortLink, int64, error)

ListShortLinks returns a paginated list of short links.

func (*ShortURLService) RecordClick

func (s *ShortURLService) RecordClick(id uint) error

RecordClick increments the click count for the given short link.

func (*ShortURLService) ResolveCode

func (s *ShortURLService) ResolveCode(code string) (*entity.ShortLink, error)

ResolveCode retrieves the short link by code and checks if it has expired.

type URLService

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

URLService provides business logic for URL management.

func NewURLService

func NewURLService(urlRepo repos.URLRepo) *URLService

NewURLService creates a new URLService.

func (*URLService) AddURL

func (s *URLService) AddURL(link string) (*entity.URL, error)

AddURL creates a new URL entry with status "pending".

func (*URLService) DeleteURL

func (s *URLService) DeleteURL(id uint) error

DeleteURL soft-deletes a URL by its ID.

func (*URLService) GetURL

func (s *URLService) GetURL(id uint) (*entity.URL, error)

GetURL retrieves a URL by its ID.

func (*URLService) ListURLs

func (s *URLService) ListURLs(page, size int, sort, category, tags string) ([]*entity.URL, int64, error)

ListURLs returns a paginated, sorted, and filtered list of URLs and total count.

func (*URLService) RecordVisit

func (s *URLService) RecordVisit(id uint) error

RecordVisit increments the visit counter for the URL with the given ID.

func (*URLService) UpdateURL

func (s *URLService) UpdateURL(url *entity.URL) error

UpdateURL updates an existing URL record.

type VisitService

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

VisitService provides business logic for recording visits.

func NewVisitService

func NewVisitService(visitRepo repos.VisitRepo) *VisitService

NewVisitService creates a new VisitService.

func (*VisitService) RecordShortVisit

func (s *VisitService) RecordShortVisit(shortID uint, ip, userAgent string) error

RecordShortVisit creates a visit record for a short link.

func (*VisitService) RecordURLVisit

func (s *VisitService) RecordURLVisit(urlID uint, ip, userAgent string) error

RecordURLVisit creates a visit record for a URL.

type WorkerService

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

func NewWorkerService

func NewWorkerService(
	urlRepo repos.URLRepo,
	llmLogRepo repos.LLMLogRepo,
	embeddingRepo repos.EmbeddingRepo,
	llmClient *llm.LLMClient,
	prompts map[string]string,
) *WorkerService

func (*WorkerService) Enqueue

func (w *WorkerService) Enqueue(urlID uint)

func (*WorkerService) RecoverPending

func (w *WorkerService) RecoverPending()

func (*WorkerService) Start

func (w *WorkerService) Start(ctx context.Context)

Jump to

Keyboard shortcuts

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