Commit c0936cac authored by luhongguang's avatar luhongguang

update:es host优化

parent 94bec4fc
......@@ -20,8 +20,11 @@ final class ElasticUtil
* ElasticUtil constructor.
* @param $hosts
*/
public function __construct($hosts)
public function __construct()
{
$hostStr = config("elasticsearch", "goods.host");
$hosts = explode(",", $hostStr);
$this->client = ClientBuilder::create()->setHosts($hosts)->build();
}
......@@ -29,10 +32,10 @@ final class ElasticUtil
* @param $hosts
* @return ElasticUtil
*/
public static function getInstance($hosts): ElasticUtil
public static function getInstance(): ElasticUtil
{
if (empty(self::$instance)) {
self::$instance = new self($hosts);
self::$instance = new self();
}
return self::$instance;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment