package tasks
import (
"context"
"fmt"
"log/slog"
"github.com/tilebox/tilebox-go/workflows/v1"
"github.com/tilebox/tilebox-go/workflows/v1/subtask"
)
type ProcessScene struct {
SceneID string
}
func (t *ProcessScene) Execute(ctx context.Context) error {
slog.InfoContext(ctx, "processing scene", slog.String("scene_id", t.SceneID))
return workflows.WithSpan(ctx, "plan-subtasks", func(ctx context.Context) error {
thumbnail, err := workflows.SubmitSubtask(ctx, &BuildThumbnail{SceneID: t.SceneID})
if err != nil {
return fmt.Errorf("failed to submit thumbnail subtask: %w", err)
}
_, err = workflows.SubmitSubtask(ctx, &PublishScene{SceneID: t.SceneID}, subtask.WithDependencies(thumbnail))
if err != nil {
return fmt.Errorf("failed to submit publish subtask: %w", err)
}
return nil
})
}
type BuildThumbnail struct {
SceneID string
}
func (t *BuildThumbnail) Execute(ctx context.Context) error {
slog.InfoContext(ctx, "building thumbnail", slog.String("scene_id", t.SceneID))
return nil
}
type PublishScene struct {
SceneID string
}
func (t *PublishScene) Execute(ctx context.Context) error {
slog.InfoContext(ctx, "publishing scene", slog.String("scene_id", t.SceneID))
return nil
}