/** * @param Driver $tripod * @param array $opts */ public function __construct(Driver $tripod, $opts = array()) { $this->tripod = $tripod; $this->storeName = $tripod->getStoreName(); $this->podName = $tripod->getPodName(); $this->stat = $tripod->getStat(); $this->labeller = new Labeller(); $opts = array_merge(array('defaultContext' => null, OP_ASYNC => array(OP_VIEWS => false, OP_TABLES => true, OP_SEARCH => true), 'stat' => null, 'readPreference' => ReadPreference::RP_PRIMARY_PREFERRED, 'retriesToGetLock' => 20), $opts); $this->readPreference = $opts['readPreference']; $this->config = $this->getConfigInstance(); // default context $this->defaultContext = $opts['defaultContext']; //max retries to get lock $this->retriesToGetLock = $opts['retriesToGetLock']; // fill in and default any missing keys for $async array $async = $opts[OP_ASYNC]; if (!array_key_exists(OP_VIEWS, $async)) { $async[OP_VIEWS] = false; } if (!array_key_exists(OP_TABLES, $async)) { $async[OP_TABLES] = true; } if (!array_key_exists(OP_SEARCH, $async)) { $async[OP_SEARCH] = true; } // if there is no es configured then remove OP_SEARCH from async (no point putting these onto the queue) TRI-19 if ($this->config->getSearchDocumentSpecifications($this->storeName) == null) { unset($async[OP_SEARCH]); } // If a custom queue name was specified, store it if (array_key_exists(OP_QUEUE, $async)) { $this->queueName = $async[OP_QUEUE]; unset($async[OP_QUEUE]); } $this->async = $async; if (isset($opts['statsConfig'])) { $this->statsConfig = $opts['statsConfig']; } }
/** * @param \Tripod\Mongo\Driver $tripod * @return Collection */ protected function getTripodCollection(\Tripod\Mongo\Driver $tripod) { $config = \Tripod\Mongo\Config::getInstance(); $podName = $tripod->getPodName(); $dataSource = $config->getDataSourceForPod($tripod->getStoreName(), $podName); return $config->getDatabase($tripod->getStoreName(), $dataSource)->selectCollection($tripod->getPodName()); }