feat(ocr): 新增本地 OCR sidecar

This commit is contained in:
yml
2026-11-17 17:26:59 +08:00
parent a6eb6c95b9
commit 90addb80d5
166 changed files with 72858 additions and 34 deletions
@@ -4,6 +4,7 @@ import (
"context"
"errors"
"net/http"
"strings"
"time"
"github.com/redis/go-redis/v9"
@@ -22,6 +23,7 @@ type Repository struct {
ocrHTTPClient *http.Client
ocrGate *ocrRequestGate
ocrSleep func(context.Context, time.Duration) error
ocrServiceURL string
}
const (
@@ -62,6 +64,12 @@ func withOCRSleep(sleep func(context.Context, time.Duration) error) RepositoryOp
}
}
func WithOCRServiceURL(rawURL string) RepositoryOption {
return func(repo *Repository) {
repo.ocrServiceURL = strings.TrimRight(strings.TrimSpace(rawURL), "/")
}
}
func NewRepository(db *gorm.DB, hub *chathub.Hub, redis *redis.Client, options ...RepositoryOption) *Repository {
repo := &Repository{
db: db,