Compare commits

..

2 Commits

Author SHA1 Message Date
ea41bef942 fix: move before new context gets created
All checks were successful
Gitea Build Check / Build (push) Successful in 39s
Gitea Build Check / Build (pull_request) Successful in 47s
2024-08-27 14:21:33 +02:00
caef31f48f feat: Add validation check for user account before starting task
All checks were successful
Gitea Build Check / Build (push) Successful in 43s
Gitea Build Check / Build (pull_request) Successful in 45s
2024-08-27 14:17:31 +02:00

View File

@ -2,6 +2,7 @@ package plug
import (
"context"
"errors"
"git.anthrove.art/Anthrove/otter-space-sdk/v3/pkg/database"
"git.anthrove.art/Anthrove/otter-space-sdk/v3/pkg/models"
@ -57,6 +58,18 @@ func (s *server) TaskStart(ctx context.Context, creation *gRPC.PlugTaskCreation)
}
span.AddEvent("Retrieved user source", trace.WithAttributes(attribute.String("user_source_id", creation.UserSourceId)))
if !userSource.AccountValidate {
err = errors.New("user is not validated")
log.WithContext(ctx).WithError(err).WithField("task_id", id).Error("Task execution failed")
span.RecordError(err)
span.SetStatus(codes.Error, err.Error())
plugTaskState.TaskState = gRPC.PlugTaskState_STOPPED
return &plugTaskState, err
}
// gRPC closes the context after the call ended. So the whole scrapping stopped without waiting
// by using this method we assign a new context to each new request we get.
// This can be used for example to close the context with the given id