选举leader
@param int $index
@return \Generator
324140
public function leader($index = 0)
    {
        $this->getSession(function ($id) use ($index) {
            $data = ['ip' => getBindIp()];
            $this->consul_leader->setQuery(['acquire' => $id])
                ->setData(json_encode($data))->setMethod('PUT')->execute("/v1/kv/servers/$this->leader_name/leader", function ($data) use ($index) {
                    $leader = $data['body'];
                    if ($leader == 'true') {//是leader
                        $leader = true;
                    } else {
                        $leader = false;
                    }
                    Start::setLeader($leader);
                    //继续监听
                    $this->checkLeader($index);
                });
        });
    }
1357207
public function getDependency(string $index)
    {
        if (! isset($this->container[$index])) {
            throw $this->unbound($index);
        }
        $dependency = $this->container[$index];

        return $dependency->inject($this);
    }
685527
public function at($index)
    {
        if (isset($this->_children[$index])) {
            return $this->_children[$index];
        }
        throw new OutOfBoundsException("Index $index does not exist");
    }
1257298
public function remove($index)
    {
        if( $index >= count($this->generators) || $index < 0 )
            return;
        
        unset($this->generators[$index]);
        $this->generators = array_values($this->generators);
    }
1014848
public function deriveColumn($index)
    {
        $this->validateColumnIndex($index);
        
        $column = new DerivedColumn($this->columns[$index]->getAlias());
        
        return $column->setTable($this);
    }
1259039
public function refresh($index)
    {
        $request = $this->createRequestInstance(self::INDEX_REFRESH, $index, null);

        return $this->client->send($request);
    }
110951
public function fetchColumn($index = 0): Generator
    {
        $offset = $this->getColumnIndex($index, __METHOD__.'() expects the column index to be a valid string or integer, `%s` given');
        $filter = static function (array $record) use ($offset): bool {
            return isset($record[$offset]);
        };

        $select = static function (array $record) use ($offset): string {
            return $record[$offset];
        };

        $iterator = new MapIterator(new CallbackFilterIterator($this->records, $filter), $select);
        foreach ($iterator as $offset => $value) {
            yield $offset => $value;
        }
    }
1117440
public function getTokenAt($index) {
        // Get token from behind
        if ($index < 0) {
            $index = count($this->tokens) + $index;
        }

        return $this->tokens[$index];
    }
250440
public function getChunkPath($index)
    {
        return $this->config->getTempDir().DIRECTORY_SEPARATOR.basename($this->identifier).'_'. (int) $index;
    }
1144428
public static function fromIndex(Db\Index $index)
    {
        return new self([
            'name' => $index->getName(),
            'columns' => $index->getColumns(),
            'type' => $index->getType()
        ]);
    }
1036079
public function withIndex(string $index): self
    {
        $metadata = clone $this;
        $metadata->index = $index;

        return $metadata;
    }
275623
public function remove($index) {
        $element = $this->get($index);
        if (!is_null($element)) { array_splice($this->_elements, $index, 1); }
        return $element;
    }
180538
public function get(int $index): string
    {
        return $this->handle->lIndex($this->name, $index);
    }
1187245
public function orderByFixed($index, $direction = 'desc')
    {
        if ($direction != 'desc') {
            $direction = 'asc';
        }

        if (is_array($index)) {
            $this->attributes['orderFixed'][] = $index;
        } else {
            $this->attributes['orderFixed'][] = [$index, $direction];
        }

        return $this;
    }
1344837
protected function removeAt($index)
    {
        if ($this->getReadOnly()) {
            throw new Exception('只读list，不允许执行移除操作', 100100505);
        }

        if ($index >= 0 && $index < $this->_count) {
            $this->_count--;
            if ($index === $this->_count) {
                return array_pop($this->_data);
            } else {
                $item = $this->_data[$index];
                array_splice($this->_data, $index, 1);
                return $item;
            }
        } else {
            throw new Exception(str_cover('List索引"{index}"已超出范围', [
                '{index}' => $index,
            ]), 100100506);
        }
    }
284214
public function getNgRestRelationByIndex($index)
    {
        $relations = $this->generateNgRestRelations();

        return isset($relations[$index]) ? $relations[$index] : false;
    }
1363434
public function withIndex(Fluent $index)
    {
        $this->indexes[] = $index;

        if ($index->name == 'unique') {
            $this->unique[] = $index;
        }

        return $this;
    }