Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
s2low
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Libriciel
s2low
Commits
8bef458a
Commit
8bef458a
authored
11 months ago
by
Julien LE GALL
Browse files
Options
Downloads
Patches
Plain Diff
Suppression systématique du job dès qu'il est réservé
parent
f6e65524
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
class/WorkerRunnerWithSelfUpdatedBeanstalkd.php
+4
-7
4 additions, 7 deletions
class/WorkerRunnerWithSelfUpdatedBeanstalkd.php
test/PHPUnit/class/WorkerRunnerWithSelfUpdatedBeanstalkdTest.php
+4
-0
4 additions, 0 deletions
...PUnit/class/WorkerRunnerWithSelfUpdatedBeanstalkdTest.php
with
8 additions
and
7 deletions
class/WorkerRunnerWithSelfUpdatedBeanstalkd.php
+
4
−
7
View file @
8bef458a
...
...
@@ -4,13 +4,8 @@ declare(strict_types=1);
namespace
S2lowLegacy\Class
;
use
Pheanstalk\Exception\CommandException
;
use
Pheanstalk\Exception\ServerException
;
use
Pheanstalk\Job
;
use
Pheanstalk\Pheanstalk
;
use
Pheanstalk\PheanstalkInterface
;
use
S2lowLegacy\Lib\SigTermHandler
;
use
Throwable
;
/**
* WorkerRunner qui va
...
...
@@ -35,11 +30,13 @@ class WorkerRunnerWithSelfUpdatedBeanstalkd implements IWorkerRunnerStrategies
public
function
getAllId
(
IWorker
$worker
,
S2lowLogger
$s2lowLogger
):
iterable
{
while
(
true
)
{
$job
=
$this
->
queue
->
reserve
(
1
);
$job
=
$this
->
queue
->
reserve
(
0
);
if
(
!
$job
)
{
return
false
;
}
yield
$job
->
getData
();
$data
=
$job
->
getData
();
$this
->
queue
->
delete
(
$job
);
yield
$data
;
}
}
...
...
This diff is collapsed.
Click to expand it.
test/PHPUnit/class/WorkerRunnerWithSelfUpdatedBeanstalkdTest.php
+
4
−
0
View file @
8bef458a
...
...
@@ -77,6 +77,10 @@ class WorkerRunnerWithSelfUpdatedBeanstalkdTest extends TestCase
$this
->
queue
->
method
(
'reserve'
)
->
willReturnOnConsecutiveCalls
(
$this
->
Job
,
false
);
$this
->
Job
->
expects
(
static
::
once
())
->
method
(
'getData'
)
->
willReturn
(
'data'
);
// Le job est supprimé systématiquement avant même d'être traité
// Autrement, la queue risque d'être bloquée
$this
->
queue
->
expects
(
self
::
once
())
->
method
(
'delete'
)
->
with
(
$this
->
Job
);
// Le heliosReceptionWorker est capable de traiter
$this
->
heliosReceptionWorker
->
expects
(
static
::
once
())
->
method
(
'getData'
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment