Remove unused and deprecated Storer interface.

This commit is contained in:
Maximilian Paß
2022-10-14 20:16:56 +01:00
parent 7119f3e012
commit b9c923da8a
2 changed files with 6 additions and 29 deletions

View File

@ -9,7 +9,6 @@ import (
"github.com/gorilla/websocket" "github.com/gorilla/websocket"
"github.com/openHPI/poseidon/internal/config" "github.com/openHPI/poseidon/internal/config"
"github.com/openHPI/poseidon/pkg/dto" "github.com/openHPI/poseidon/pkg/dto"
"github.com/openHPI/poseidon/pkg/execution"
"github.com/openHPI/poseidon/pkg/monitoring" "github.com/openHPI/poseidon/pkg/monitoring"
"github.com/openHPI/poseidon/pkg/storage" "github.com/openHPI/poseidon/pkg/storage"
"io" "io"
@ -34,7 +33,7 @@ type AWSFunctionWorkload struct {
id string id string
fs map[dto.FilePath][]byte fs map[dto.FilePath][]byte
executions storage.Storage[*dto.ExecutionRequest] executions storage.Storage[*dto.ExecutionRequest]
runningExecutions map[execution.ID]context.CancelFunc runningExecutions map[string]context.CancelFunc
onDestroy DestroyRunnerHandler onDestroy DestroyRunnerHandler
environment ExecutionEnvironment environment ExecutionEnvironment
ctx context.Context ctx context.Context
@ -53,7 +52,7 @@ func NewAWSFunctionWorkload(
workload := &AWSFunctionWorkload{ workload := &AWSFunctionWorkload{
id: newUUID.String(), id: newUUID.String(),
fs: make(map[dto.FilePath][]byte), fs: make(map[dto.FilePath][]byte),
runningExecutions: make(map[execution.ID]context.CancelFunc), runningExecutions: make(map[string]context.CancelFunc),
onDestroy: onDestroy, onDestroy: onDestroy,
environment: environment, environment: environment,
ctx: ctx, ctx: ctx,
@ -102,7 +101,7 @@ func (w *AWSFunctionWorkload) ExecuteInteractively(id string, _ io.ReadWriter, s
exit := make(chan ExitInfo, 1) exit := make(chan ExitInfo, 1)
go w.executeCommand(ctx, command, stdout, stderr, exitInternal) go w.executeCommand(ctx, command, stdout, stderr, exitInternal)
go w.handleRunnerTimeout(ctx, exitInternal, exit, execution.ID(id)) go w.handleRunnerTimeout(ctx, exitInternal, exit, id)
return exit, cancel, nil return exit, cancel, nil
} }
@ -220,10 +219,10 @@ func (w *AWSFunctionWorkload) receiveOutput(
// handleRunnerTimeout listens for a runner timeout and aborts the execution in that case. // handleRunnerTimeout listens for a runner timeout and aborts the execution in that case.
// It listens via a context in runningExecutions that is canceled on the timeout event. // It listens via a context in runningExecutions that is canceled on the timeout event.
func (w *AWSFunctionWorkload) handleRunnerTimeout(ctx context.Context, func (w *AWSFunctionWorkload) handleRunnerTimeout(ctx context.Context,
exitInternal <-chan ExitInfo, exit chan<- ExitInfo, id execution.ID) { exitInternal <-chan ExitInfo, exit chan<- ExitInfo, executionID string) {
executionCtx, cancelExecution := context.WithCancel(ctx) executionCtx, cancelExecution := context.WithCancel(ctx)
w.runningExecutions[id] = cancelExecution w.runningExecutions[executionID] = cancelExecution
defer delete(w.runningExecutions, id) defer delete(w.runningExecutions, executionID)
defer close(exit) defer close(exit)
select { select {

View File

@ -1,22 +0,0 @@
package execution
import (
"github.com/openHPI/poseidon/pkg/dto"
)
// ID is an identifier for an execution.
type ID string
// Storer stores executions.
type Storer interface {
// Add adds a runner to the storage.
// It overwrites the existing execution if an execution with the same id already exists.
Add(id ID, executionRequest *dto.ExecutionRequest)
// Exists returns whether the execution with the given id exists in the store.
Exists(id ID) bool
// Pop deletes the execution with the given id from the storage and returns it.
// If no such execution exists, ok is false and true otherwise.
Pop(id ID) (request *dto.ExecutionRequest, ok bool)
}