mirror of
https://github.com/silverstripe/silverstripe-fulltextsearch
synced 2024-10-22 12:05:29 +00:00
SS 4.0 - Upgrade search processors and remove MessageQueue as not maintained
This commit is contained in:
parent
695b2d2fc3
commit
8e07d4a5c6
@ -1,5 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace SilverStripe\FullTextSearch\Search\Processors;
|
||||
|
||||
use SilverStripe\Core\Config\Config;
|
||||
|
||||
/**
|
||||
* Provides batching of search updates
|
||||
*/
|
||||
|
@ -1,9 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace SilverStripe\FullTextSearch\Search\Processors;
|
||||
if (!interface_exists('QueuedJob')) {
|
||||
|
||||
use SilverStripe\FullTextSearch\Search\FullTextSearch;
|
||||
use SilverStripe\Core\Config\Config;
|
||||
use SilverStripe\Core\Injector\Injector;
|
||||
use SilverStripe\ORM\FieldType\DBDatetime;
|
||||
use DateTime;
|
||||
use DateInterval;
|
||||
use stdClass;
|
||||
|
||||
if (!interface_exists('SilverStripe\QueuedJobs\Services\QueuedJob')) {
|
||||
return;
|
||||
}
|
||||
|
||||
use SilverStripe\QueuedJobs\Services\QueuedJob;
|
||||
use SilverStripe\QueuedJobs\Services\QueuedJobService;
|
||||
|
||||
class SearchUpdateCommitJobProcessor implements QueuedJob
|
||||
{
|
||||
/**
|
||||
@ -81,7 +94,7 @@ class SearchUpdateCommitJobProcessor implements QueuedJob
|
||||
public static function queue($dirty = true, $startAfter = null)
|
||||
{
|
||||
$commit = Injector::inst()->create(__CLASS__);
|
||||
$id = singleton('QueuedJobService')->queueJob($commit, $startAfter);
|
||||
$id = singleton(QueuedJobService::class)->queueJob($commit, $startAfter);
|
||||
|
||||
if ($dirty) {
|
||||
$indexes = FullTextSearch::get_indexes();
|
||||
@ -159,7 +172,7 @@ class SearchUpdateCommitJobProcessor implements QueuedJob
|
||||
// This could occur if we completed a searchupdate job in a prior request, as well as in
|
||||
// the current request
|
||||
$cooldown = Config::inst()->get(__CLASS__, 'cooldown');
|
||||
$now = new DateTime(SS_Datetime::now()->getValue());
|
||||
$now = new DateTime(DBDatetime::now()->getValue());
|
||||
$now->add(new DateInterval('PT'.$cooldown.'S'));
|
||||
$runat = $now->Format('Y-m-d H:i:s');
|
||||
|
||||
|
@ -1,19 +0,0 @@
|
||||
<?php
|
||||
namespace SilverStripe\FullTextSearch\Search\Processors;
|
||||
class SearchUpdateMessageQueueProcessor extends SearchUpdateProcessor
|
||||
{
|
||||
/**
|
||||
* The MessageQueue to use when processing updates
|
||||
* @config
|
||||
* @var string
|
||||
*/
|
||||
private static $reindex_queue = "search_indexing";
|
||||
|
||||
public function triggerProcessing()
|
||||
{
|
||||
MessageQueue::send(
|
||||
Config::inst()->get('SearchMessageQueueUpdater', 'reindex_queue'),
|
||||
new MethodInvocationMessage($this, "process")
|
||||
);
|
||||
}
|
||||
}
|
@ -1,9 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace SilverStripe\FullTextSearch\Search\Processors;
|
||||
if (!interface_exists('QueuedJob')) {
|
||||
|
||||
use SilverStripe\Core\Config\Config;
|
||||
use stdClass;
|
||||
|
||||
if (!interface_exists('SilverStripe\QueuedJobs\Services\QueuedJob')) {
|
||||
return;
|
||||
}
|
||||
|
||||
use SilverStripe\QueuedJobs\Services\QueuedJob;
|
||||
use SilverStripe\QueuedJobs\Services\QueuedJobService;
|
||||
|
||||
class SearchUpdateQueuedJobProcessor extends SearchUpdateBatchedProcessor implements QueuedJob
|
||||
{
|
||||
/**
|
||||
@ -18,7 +26,7 @@ class SearchUpdateQueuedJobProcessor extends SearchUpdateBatchedProcessor implem
|
||||
public function triggerProcessing()
|
||||
{
|
||||
parent::triggerProcessing();
|
||||
singleton('QueuedJobService')->queueJob($this);
|
||||
singleton(QueuedJobService::class)->queueJob($this);
|
||||
}
|
||||
|
||||
public function getTitle()
|
||||
|
Loading…
x
Reference in New Issue
Block a user