logs
This commit is contained in:
@ -8,6 +8,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"github.com/lib/pq"
|
||||
"go.uber.org/zap"
|
||||
|
||||
"github.com/RyanCopley/skybridge/faas/internal/domain"
|
||||
@ -97,7 +98,7 @@ func (r *executionRepository) Create(ctx context.Context, execution *domain.Func
|
||||
func (r *executionRepository) GetByID(ctx context.Context, id uuid.UUID) (*domain.FunctionExecution, error) {
|
||||
query := `
|
||||
SELECT id, function_id, status, input, output, error, duration, memory_used,
|
||||
container_id, executor_id, created_at, started_at, completed_at
|
||||
logs, container_id, executor_id, created_at, started_at, completed_at
|
||||
FROM executions WHERE id = $1`
|
||||
|
||||
execution := &domain.FunctionExecution{}
|
||||
@ -106,7 +107,7 @@ func (r *executionRepository) GetByID(ctx context.Context, id uuid.UUID) (*domai
|
||||
err := r.db.QueryRowContext(ctx, query, id).Scan(
|
||||
&execution.ID, &execution.FunctionID, &execution.Status, &execution.Input,
|
||||
&execution.Output, &execution.Error, &durationInterval, &execution.MemoryUsed,
|
||||
&execution.ContainerID, &execution.ExecutorID, &execution.CreatedAt,
|
||||
pq.Array(&execution.Logs), &execution.ContainerID, &execution.ExecutorID, &execution.CreatedAt,
|
||||
&execution.StartedAt, &execution.CompletedAt,
|
||||
)
|
||||
|
||||
@ -135,12 +136,13 @@ func (r *executionRepository) Update(ctx context.Context, id uuid.UUID, executio
|
||||
query := `
|
||||
UPDATE executions
|
||||
SET status = $2, output = $3, error = $4, duration = $5, memory_used = $6,
|
||||
container_id = $7, started_at = $8, completed_at = $9
|
||||
logs = $7, container_id = $8, started_at = $9, completed_at = $10
|
||||
WHERE id = $1`
|
||||
|
||||
_, err := r.db.ExecContext(ctx, query,
|
||||
id, execution.Status, jsonField(execution.Output), execution.Error,
|
||||
durationToInterval(execution.Duration), execution.MemoryUsed, execution.ContainerID,
|
||||
durationToInterval(execution.Duration), execution.MemoryUsed,
|
||||
pq.Array(execution.Logs), execution.ContainerID,
|
||||
execution.StartedAt, execution.CompletedAt,
|
||||
)
|
||||
|
||||
@ -209,7 +211,7 @@ func (r *executionRepository) List(ctx context.Context, functionID *uuid.UUID, l
|
||||
err := rows.Scan(
|
||||
&execution.ID, &execution.FunctionID, &execution.Status, &execution.Input,
|
||||
&execution.Output, &execution.Error, &durationInterval, &execution.MemoryUsed,
|
||||
&execution.ContainerID, &execution.ExecutorID, &execution.CreatedAt,
|
||||
pq.Array(&execution.Logs), &execution.ContainerID, &execution.ExecutorID, &execution.CreatedAt,
|
||||
&execution.StartedAt, &execution.CompletedAt,
|
||||
)
|
||||
|
||||
@ -245,7 +247,7 @@ func (r *executionRepository) GetByFunctionID(ctx context.Context, functionID uu
|
||||
func (r *executionRepository) GetByStatus(ctx context.Context, status domain.ExecutionStatus, limit, offset int) ([]*domain.FunctionExecution, error) {
|
||||
query := `
|
||||
SELECT id, function_id, status, input, output, error, duration, memory_used,
|
||||
container_id, executor_id, created_at, started_at, completed_at
|
||||
logs, container_id, executor_id, created_at, started_at, completed_at
|
||||
FROM executions WHERE status = $1
|
||||
ORDER BY created_at DESC LIMIT $2 OFFSET $3`
|
||||
|
||||
@ -264,7 +266,7 @@ func (r *executionRepository) GetByStatus(ctx context.Context, status domain.Exe
|
||||
err := rows.Scan(
|
||||
&execution.ID, &execution.FunctionID, &execution.Status, &execution.Input,
|
||||
&execution.Output, &execution.Error, &durationInterval, &execution.MemoryUsed,
|
||||
&execution.ContainerID, &execution.ExecutorID, &execution.CreatedAt,
|
||||
pq.Array(&execution.Logs), &execution.ContainerID, &execution.ExecutorID, &execution.CreatedAt,
|
||||
&execution.StartedAt, &execution.CompletedAt,
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user