-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Christopher Lorke
committed
Oct 18, 2018
1 parent
458c27b
commit f80b1ea
Showing
43 changed files
with
756 additions
and
2,508 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
namespace Triadev\EsMigration\Business\Mapper; | ||
|
||
class MigrationStatus | ||
{ | ||
const MIGRATION_STATUS_WAIT = 0; | ||
const MIGRATION_STATUS_RUNNING = 1; | ||
const MIGRATION_STATUS_DONE = 2; | ||
const MIGRATION_STATUS_ERROR = 3; | ||
|
||
/** | ||
* Is migration status valid | ||
* | ||
* @param int $status | ||
* @return bool | ||
*/ | ||
public function isMigrationStatusValid(int $status) : bool | ||
{ | ||
$valid = [ | ||
self::MIGRATION_STATUS_WAIT, | ||
self::MIGRATION_STATUS_RUNNING, | ||
self::MIGRATION_STATUS_DONE, | ||
self::MIGRATION_STATUS_ERROR | ||
]; | ||
|
||
if (in_array($status, $valid)) { | ||
return true; | ||
} | ||
|
||
return false; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
namespace Triadev\EsMigration\Business\Mapper; | ||
|
||
class MigrationTypes | ||
{ | ||
const MIGRATION_TYPE_CREATE_INDEX = 'createIndex'; | ||
const MIGRATION_TYPE_UPDATE_INDEX = 'updateIndex'; | ||
const MIGRATION_TYPE_DELETE_INDEX = 'deleteIndex'; | ||
const MIGRATION_TYPE_ALIAS = 'alias'; | ||
const MIGRATION_TYPE_DELETE_BY_QUERY = 'deleteByQuery'; | ||
const MIGRATION_TYPE_UPDATE_BY_QUERY = 'updateByQuery'; | ||
const MIGRATION_TYPE_REINDEX = 'reindex'; | ||
|
||
/** | ||
* Is migration type valid | ||
* | ||
* @param string $type | ||
* @return bool | ||
*/ | ||
public function isMigrationTypeValid(string $type) : bool | ||
{ | ||
if (in_array($type, [ | ||
self::MIGRATION_TYPE_CREATE_INDEX, | ||
self::MIGRATION_TYPE_UPDATE_INDEX, | ||
self::MIGRATION_TYPE_DELETE_INDEX, | ||
self::MIGRATION_TYPE_ALIAS, | ||
self::MIGRATION_TYPE_DELETE_BY_QUERY, | ||
self::MIGRATION_TYPE_UPDATE_BY_QUERY, | ||
self::MIGRATION_TYPE_REINDEX, | ||
])) { | ||
return true; | ||
} | ||
|
||
return false; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
<?php | ||
namespace Triadev\EsMigration\Business\Repository; | ||
|
||
use Elasticsearch\Client; | ||
use Elasticsearch\ClientBuilder; | ||
|
||
class ElasticsearchClients | ||
{ | ||
/** | ||
* @var array | ||
*/ | ||
private $elasticsearchClients = []; | ||
|
||
/** @var ClientBuilder */ | ||
private $clientBuilder; | ||
|
||
/** | ||
* ElasticsearchClients constructor. | ||
*/ | ||
public function __construct() | ||
{ | ||
$this->clientBuilder = ClientBuilder::create(); | ||
} | ||
|
||
/** | ||
* Add | ||
* | ||
* @param string $esClientKey | ||
* @param string $host | ||
* @param int $port | ||
* @param string $scheme | ||
* @param null|string $user | ||
* @param null|string $password | ||
*/ | ||
public function add( | ||
string $esClientKey, | ||
string $host, | ||
int $port, | ||
string $scheme, | ||
?string $user = null, | ||
?string $password = null | ||
) { | ||
$this->elasticsearchClients[$esClientKey] = $this->clientBuilder->setHosts([ | ||
[ | ||
'host' => $host, | ||
'port' => $port, | ||
'scheme' => $scheme, | ||
'user' => $user, | ||
'pass' => $password | ||
] | ||
])->build(); | ||
} | ||
|
||
/** | ||
* Get | ||
* | ||
* @param string $esClientKey | ||
* @return Client|null | ||
*/ | ||
public function get(string $esClientKey) : ?Client | ||
{ | ||
return array_get($this->elasticsearchClients, $esClientKey); | ||
} | ||
|
||
/** | ||
* All | ||
* | ||
* @return Client[] | ||
*/ | ||
public function all() : array | ||
{ | ||
return $this->elasticsearchClients; | ||
} | ||
} |
Oops, something went wrong.