feat: Add reprocess command
This commit is contained in:
44
internal/cli/reprocess.go
Normal file
44
internal/cli/reprocess.go
Normal file
@@ -0,0 +1,44 @@
|
||||
package cli
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"gis/internal/app"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var reprocessCmd = &cobra.Command{
|
||||
Use: "reprocess <dataset-id>",
|
||||
Short: "Re-enqueue the processing job for an uploaded dataset",
|
||||
Long: "Re-publish the RabbitMQ message that drives an uploaded dataset's\n" +
|
||||
"asynchronous processing, selecting the right step from its file type\n" +
|
||||
"(vector_with_kato -> parse, vector -> properties, raster -> cog).\n\n" +
|
||||
"Example:\n" +
|
||||
" gis reprocess 06818b2b-1fc5-47d9-a764-db2d4cb3df75",
|
||||
Args: cobra.ExactArgs(1),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
id, err := uuid.Parse(args[0])
|
||||
if err != nil {
|
||||
return fmt.Errorf("invalid dataset id %q: %w", args[0], err)
|
||||
}
|
||||
|
||||
ctx, cancel := signalContext()
|
||||
defer cancel()
|
||||
|
||||
application, err := app.New(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer application.Close()
|
||||
|
||||
dataset, err := application.ReprocessDataset(ctx, id)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
application.Log.Info("re-enqueued dataset processing",
|
||||
"dataset_id", dataset.ID, "file_type", dataset.FileType, "status", dataset.Status)
|
||||
return nil
|
||||
},
|
||||
}
|
||||
Reference in New Issue
Block a user