Commit 0a49b637 authored by yujiwei's avatar yujiwei
parents 30d9d842 c0936cac
...@@ -20,8 +20,11 @@ final class ElasticUtil ...@@ -20,8 +20,11 @@ final class ElasticUtil
* ElasticUtil constructor. * ElasticUtil constructor.
* @param $hosts * @param $hosts
*/ */
public function __construct($hosts) public function __construct()
{ {
$hostStr = config("elasticsearch", "goods.host");
$hosts = explode(",", $hostStr);
$this->client = ClientBuilder::create()->setHosts($hosts)->build(); $this->client = ClientBuilder::create()->setHosts($hosts)->build();
} }
...@@ -29,10 +32,10 @@ final class ElasticUtil ...@@ -29,10 +32,10 @@ final class ElasticUtil
* @param $hosts * @param $hosts
* @return ElasticUtil * @return ElasticUtil
*/ */
public static function getInstance($hosts): ElasticUtil public static function getInstance(): ElasticUtil
{ {
if (empty(self::$instance)) { if (empty(self::$instance)) {
self::$instance = new self($hosts); self::$instance = new self();
} }
return self::$instance; 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