Don't embed the execution.Storer interface into a runner
Previously, the execution.Storer interface was embedded in the Runner interface. However, this resulted in calls like runner.Add(...) to add an execution to the store which is kind of ugly. Thus, we decided to add only the required functions to the runner interface and make the execution.Storer a field of the implementation.
This commit is contained in:
@ -13,6 +13,9 @@ type Storer interface {
|
||||
// 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)
|
||||
|
@ -26,6 +26,13 @@ func (s *localStorage) Add(id ID, executionRequest *dto.ExecutionRequest) {
|
||||
s.executions[id] = executionRequest
|
||||
}
|
||||
|
||||
func (s *localStorage) Exists(id ID) bool {
|
||||
s.Lock()
|
||||
defer s.Unlock()
|
||||
_, ok := s.executions[id]
|
||||
return ok
|
||||
}
|
||||
|
||||
func (s *localStorage) Pop(id ID) (*dto.ExecutionRequest, bool) {
|
||||
s.Lock()
|
||||
defer s.Unlock()
|
||||
|
Reference in New Issue
Block a user