Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
open-source
MetaGer
Commits
0d27b8d7
Commit
0d27b8d7
authored
May 08, 2017
by
Dominik Hebeler
Browse files
Merge branch '485-ux-bei-such-timeout' into 'development'
Die erste stabile Version Closes
#485
See merge request
!836
parents
b56cfcb9
e0887af5
Changes
2
Hide whitespace changes
Inline
Side-by-side
app/Jobs/Searcher.php
View file @
0d27b8d7
...
...
@@ -33,7 +33,6 @@ class Searcher implements ShouldQueue
$this
->
name
=
$name
;
$this
->
pid
=
getmypid
();
// Submit this worker to the Redis System
Redis
::
set
(
$this
->
name
,
"running"
);
Redis
::
expire
(
$this
->
name
,
5
);
}
...
...
@@ -51,6 +50,7 @@ class Searcher implements ShouldQueue
while
(
true
){
// Update the expire
Redis
::
expire
(
$this
->
name
,
5
);
Redis
::
expire
(
$this
->
name
.
".stats"
,
5
);
// One Searcher can handle a ton of requests to the same server
// Each search to the server of this Searcher will be submitted to a queue
// stored in redis which has the same name as this searchengine appended by a ".queue"
...
...
@@ -65,7 +65,6 @@ class Searcher implements ShouldQueue
$mission
=
$mission
[
1
];
$this
->
counter
++
;
#
$poptime
=
microtime
(
true
)
-
$time
;
$time
=
microtime
(
true
);
}
// The mission is a String which can be divided to retrieve two informations:
...
...
@@ -81,6 +80,16 @@ class Searcher implements ShouldQueue
$this
->
storeResult
(
$result
,
$poptime
,
$hashValue
);
if
(
$this
->
counter
===
3
){
Redis
::
set
(
$this
->
name
,
"running"
);
}
// Reset the time of the last Job so we can calculate
// the time we have spend waiting for a new job
// We submit that calculation to the Redis systemin the method
// storeResult()
$time
=
microtime
(
true
);
// In sync mode every Searcher may only retrieve one result because it would block
// the execution of the remaining code otherwise:
if
(
getenv
(
"QUEUE_DRIVER"
)
===
"sync"
||
$this
->
counter
>
$this
->
MAX_REQUESTS
){
...
...
app/Models/Searchengine.php
View file @
0d27b8d7
...
...
@@ -156,10 +156,19 @@ abstract class Searchengine
// Now we have to check if the current count is enough to fetch all the
// searches or if it needs help.
// Let's hardcode a minimum of 100ms between every search job.
die
(
var_dump
(
$searcherData
));
// First calculate the median of all Times
$median
=
0
;
foreach
(
$searcherData
as
$pid
=>
$data
){
$data
=
explode
(
";"
,
$data
);
$median
+=
floatval
(
$data
[
1
]);
}
$median
/=
sizeof
(
$searcherData
);
if
(
$median
<
100
){
$needSearcher
=
true
;
}
}
if
(
$needSearcher
){
if
(
$needSearcher
&&
Redis
::
get
(
$this
->
name
)
!==
"locked"
){
Redis
::
set
(
$this
->
name
,
"locked"
);
$this
->
dispatch
(
new
Searcher
(
$this
->
name
));
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment