feat(ocr): 新增本地 OCR sidecar
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user