/** * {@inheritDoc} */ public function refreshIndex(IndexInterface $index) { try { $this->client->indices()->refresh(['index' => $index->getName()]); } catch (\Exception $e) { $this->logger->error($e->getMessage()); } return $this; }
/** * @param string $endpoint * @return bool * @throws \Exception */ public function isApiRateLimitReached($endpoint = '/statuses/show/:id') { $rateLimitStatus = $this->fetchRateLimitStatus(); if ($this->hasError($rateLimitStatus)) { $message = $rateLimitStatus->errors[0]->message; $this->logger->error($message); throw new \Exception($message, $rateLimitStatus->errors[0]->code); } else { $leastUpperBound = $rateLimitStatus->resources->statuses->{$endpoint}->limit; $remainingCalls = $rateLimitStatus->resources->statuses->{$endpoint}->remaining; $remainingCallsMessage = $this->translator->transChoice('logs.info.calls_remaining', $remainingCalls, ['{{ count }}' => $remainingCalls, '{{ endpoint }}' => $endpoint, '{{ identifier }}' => substr($this->userToken, 0, '8')], 'logs'); $this->logger->info($remainingCallsMessage); return $remainingCalls < floor($leastUpperBound * (1 / 10)); } }