Merged in feature/doc_import (pull request #177)
integration of background processor * integration part 1 * feature working * fix mimetype issue
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package queryapi
|
||||
|
||||
import (
|
||||
"queryorchestration/internal/backgroundtask"
|
||||
"queryorchestration/internal/client"
|
||||
clientupdate "queryorchestration/internal/client/update"
|
||||
"queryorchestration/internal/collector"
|
||||
@@ -36,6 +37,7 @@ type Services struct {
|
||||
type ConfigProvider interface {
|
||||
auth.ConfigProvider
|
||||
objectstore.ConfigProvider
|
||||
GetBackgroundRunner() *backgroundtask.Runner
|
||||
}
|
||||
|
||||
type Controllers struct {
|
||||
|
||||
@@ -37,6 +37,7 @@ func (s *Controllers) UploadDocument(ctx echo.Context, clientId ClientID) error
|
||||
err = s.svc.DocumentUpload.Upload(ctx.Request().Context(), documentupload.File{
|
||||
ClientID: clientId,
|
||||
Content: src,
|
||||
Filename: file.Filename,
|
||||
})
|
||||
if err != nil {
|
||||
slog.Error("unable to get form data", "error", err)
|
||||
@@ -185,6 +186,15 @@ func (s *Controllers) UploadDocumentBatch(ctx echo.Context, clientId ClientID) e
|
||||
"client_id", clientId,
|
||||
)
|
||||
|
||||
// Signal background runner to process new batch
|
||||
if runner := s.cfg.GetBackgroundRunner(); runner != nil {
|
||||
if err := runner.Signal(); err != nil {
|
||||
slog.Warn("Failed to signal background runner", "error", err, "batch_id", batchID)
|
||||
} else {
|
||||
slog.Info("Background runner signaled for batch processing", "batch_id", batchID)
|
||||
}
|
||||
}
|
||||
|
||||
// Return 202 Accepted with batch ID and status URL
|
||||
statusUrl := fmt.Sprintf("/clients/%s/documents/batches/%s", clientId, batchID)
|
||||
response := BatchUploadResponse{
|
||||
|
||||
@@ -7,6 +7,7 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"queryorchestration/internal/backgroundtask"
|
||||
"queryorchestration/internal/client"
|
||||
"queryorchestration/internal/collector"
|
||||
"queryorchestration/internal/database/repository"
|
||||
@@ -152,6 +153,10 @@ type ControllerConfig struct {
|
||||
objectstore.ObjectStoreConfig
|
||||
}
|
||||
|
||||
func (c *ControllerConfig) GetBackgroundRunner() *backgroundtask.Runner {
|
||||
return nil // Test config returns nil
|
||||
}
|
||||
|
||||
func createControllerServices(cfg *ControllerConfig) *queryapi.Services {
|
||||
docsvc := document.New(cfg)
|
||||
col := collector.New(cfg)
|
||||
|
||||
@@ -5,6 +5,7 @@ import (
|
||||
"io"
|
||||
"log/slog"
|
||||
|
||||
"queryorchestration/internal/backgroundtask"
|
||||
"queryorchestration/internal/serviceconfig/aws"
|
||||
"queryorchestration/internal/serviceconfig/objectstore"
|
||||
)
|
||||
@@ -76,11 +77,12 @@ func (m *mockAuthConfig) SetS3UsePathStyle(bool)
|
||||
func (m *mockAuthConfig) CalculateETag(context.Context, io.Reader) (string, error) {
|
||||
return "test-etag", nil
|
||||
}
|
||||
func (m *mockAuthConfig) GetDirectoryPart(uint16, int64) uint16 { return 0 }
|
||||
func (m *mockAuthConfig) GetBucket() string { return "test-bucket" }
|
||||
func (m *mockAuthConfig) SetBucket(string) {}
|
||||
func (m *mockAuthConfig) GetAWSProfile() aws.Profile { return aws.Profile("default") }
|
||||
func (m *mockAuthConfig) SetAWSProfile(aws.Profile) {}
|
||||
func (m *mockAuthConfig) GetDirectoryPart(uint16, int64) uint16 { return 0 }
|
||||
func (m *mockAuthConfig) GetBucket() string { return "test-bucket" }
|
||||
func (m *mockAuthConfig) SetBucket(string) {}
|
||||
func (m *mockAuthConfig) GetAWSProfile() aws.Profile { return aws.Profile("default") }
|
||||
func (m *mockAuthConfig) SetAWSProfile(aws.Profile) {}
|
||||
func (m *mockAuthConfig) GetBackgroundRunner() *backgroundtask.Runner { return nil }
|
||||
|
||||
// NewTestControllers creates a Controllers instance for testing with a mock auth config
|
||||
func NewTestControllers(services *Services) *Controllers {
|
||||
|
||||
Reference in New Issue
Block a user