package main import ( "context" "encoding/json" "fmt" "log" "time" "github.com/RyanCopley/skybridge/faas/internal/domain" "github.com/RyanCopley/skybridge/faas/internal/runtime/docker" "go.uber.org/zap" ) func main() { // Create a logger logger, err := zap.NewDevelopment() if err != nil { log.Fatal("Failed to create logger:", err) } defer logger.Sync() // Create the Docker runtime runtime, err := docker.NewSimpleDockerRuntime(logger) if err != nil { log.Fatal("Failed to create Docker runtime:", err) } // Test health check ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) defer cancel() if err := runtime.HealthCheck(ctx); err != nil { log.Fatal("Docker runtime health check failed:", err) } fmt.Println("Docker runtime health check passed!") // Get runtime info info, err := runtime.GetInfo(ctx) if err != nil { log.Fatal("Failed to get runtime info:", err) } fmt.Printf("Runtime Info: %+v\n", info) // Test with a simple function (using a basic image) function := &domain.FunctionDefinition{ Name: "test-function", Image: "alpine:latest", } // Deploy the function (pull the image) fmt.Println("Deploying function...") if err := runtime.Deploy(ctx, function); err != nil { log.Fatal("Failed to deploy function:", err) } fmt.Println("Function deployed successfully!") // Test execution with a simple command input := json.RawMessage(`{"cmd": "echo Hello World"}`) fmt.Println("Executing function...") result, err := runtime.Execute(ctx, function, input) if err != nil { log.Fatal("Failed to execute function:", err) } fmt.Printf("Execution result: %+v\n", result) fmt.Println("Logs:", result.Logs) fmt.Println("Output:", string(result.Output)) }