if (! $readPreference instanceof ReadPreference) {
// TODO: PHPLIB-476: Read transaction read preference once PHPC-1439 is implemented
$readPreference = new ReadPreference(ReadPreference::RP_PRIMARY);
}
return $manager->selectServer($readPreference);
}
/**
* Performs server selection for an aggregate operation with a write stage. The
* $options parameter may be modified by reference if a primary read preference
if (! $readPreference instanceof ReadPreference) {
// TODO: PHPLIB-476: Read transaction read preference once PHPC-1439 is implemented
$readPreference = new ReadPreference(ReadPreference::RP_PRIMARY);
}
return $manager->selectServer($readPreference);
}
/**
* Performs server selection for an aggregate operation with a write stage. The
* $options parameter may be modified by reference if a primary read preference
{
if (! isset($options['readPreference']) && ! is_in_transaction($options)) {
$options['readPreference'] = $this->readPreference;
}
$server = select_server($this->manager, $options);
if (! isset($options['readConcern']) && ! is_in_transaction($options)) {
$options['readConcern'] = $this->readConcern;
}
* @return mixed
*/
public function __call($method, $parameters)
{
$start = microtime(true);
$result = call_user_func_array([$this->collection, $method], $parameters);
// Once we have run the query we will calculate the time that it took to run and
// then log the query, bindings, and execution time so we will report them on
// the event that the developer needs them. We'll log time in milliseconds.
$time = $this->connection->getElapsedTime($start);
if (count($this->options)) {
$options = array_merge($options, $this->options);
}
// Execute query and get MongoCursor
$cursor = $this->collection->find($wheres, $options);
if ($returnLazy) {
return LazyCollection::make(function () use ($cursor) {
foreach ($cursor as $item) {
yield $item;
/**
* @inheritdoc
*/
public function get($columns = [])
{
return $this->getFresh($columns);
}
/**
* @inheritdoc
*/
* @return \Illuminate\Database\Eloquent\Model[]|static[]
*/
public function getModels($columns = ['*'])
{
return $this->model->hydrate(
$this->query->get($columns)->all()
)->all();
}
/**
* Eager load the relationships for the models.
$builder = $this->applyScopes();
// If we actually found models we will also eager load any relationships that
// have been specified as needing to be eager loaded, which will solve the
// n+1 query issue for the developers to avoid running a lot of queries.
if (count($models = $builder->getModels($columns)) > 0) {
$models = $builder->eagerLoadRelations($models);
}
return $builder->getModel()->newCollection($models);
}
* @param array|string $columns
* @return \Illuminate\Database\Eloquent\Model|object|static|null
*/
public function first($columns = ['*'])
{
return $this->take(1)->get($columns)->first();
}
/**
* Execute the query and get the first result if it's the sole matching record.
*
{
public function handle(Request $request, Closure $next)
{
$setting = Setting::query()
->latest()
->first();
foreach ($setting->toArray() as $key => $value) {
config()->set(str_replace(' ', '.', $key), $value);
}
return $next($request);
}
// since the object we're given was already a fully instantiated object.
$parameters = [$passable, $stack];
}
$carry = method_exists($pipe, $this->method)
? $pipe->{$this->method}(...$parameters)
: $pipe(...$parameters);
return $this->handleCarry($carry);
} catch (Throwable $e) {
return $this->handleException($passable, $e);
{
$pipeline = array_reduce(
array_reverse($this->pipes()), $this->carry(), $this->prepareDestination($destination)
);
return $pipeline($this->passable);
}
/**
* Run the pipeline and return the result.
*
$this->bootstrap();
return (new Pipeline($this->app))
->send($request)
->through($this->app->shouldSkipMiddleware() ? [] : $this->middleware)
->then($this->dispatchToRouter());
}
/**
* Bootstrap the application for HTTP requests.
*
public function handle($request)
{
try {
$request->enableHttpMethodParameterOverride();
$response = $this->sendRequestThroughRouter($request);
} catch (Throwable $e) {
$this->reportException($e);
$response = $this->renderException($request, $e);
}
* @return \Illuminate\Http\Response
*/
protected function handleRequest(Request $request)
{
if ($this->isLaravel()) {
return $this->getKernel()->handle($request);
}
return $this->getApplication()->dispatch($request);
}
protected function prepareObResponse(Request $request)
{
ob_start();
// handle request with laravel or lumen
$response = $this->handleRequest($request);
// prepare content for ob
$content = '';
$isFile = false;
if ($isStream = $response instanceof StreamedResponse) {
}
$shouldUseOb = $this->config->get('swoole_http.ob_output', true);
if ($shouldUseOb) {
return $this->prepareObResponse($request);
}
return $this->prepareResponse($request);
}
// enable sandbox
$sandbox->enable();
// handle request via laravel/lumen's dispatcher
$illuminateResponse = $sandbox->run($illuminateRequest);
// send response
Response::make($illuminateResponse, $swooleResponse, $swooleRequest)->send();
} catch (Throwable $e) {
try {
ConnectionTimeoutException
|
---|
MongoDB\Driver\Exception\ConnectionTimeoutException: No suitable servers found (`serverSelectionTryOnce` set): [Failed to resolve 'chatbot-db.cluster-cv1cbaz9hcwa.us-east-1.docdb.amazonaws.com'] at /app/vendor/mongodb/mongodb/src/functions.php:487 at MongoDB\Driver\Manager->selectServer() (/app/vendor/mongodb/mongodb/src/functions.php:487) at MongoDB\select_server() (/app/vendor/mongodb/mongodb/src/Collection.php:639) at MongoDB\Collection->find() at call_user_func_array() (/app/vendor/jenssegers/mongodb/src/Collection.php:45) at Jenssegers\Mongodb\Collection->__call() (/app/vendor/jenssegers/mongodb/src/Query/Builder.php:410) at Jenssegers\Mongodb\Query\Builder->getFresh() (/app/vendor/jenssegers/mongodb/src/Query/Builder.php:201) at Jenssegers\Mongodb\Query\Builder->get() (/app/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php:699) at Illuminate\Database\Eloquent\Builder->getModels() (/app/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php:683) at Illuminate\Database\Eloquent\Builder->get() (/app/vendor/laravel/framework/src/Illuminate/Database/Concerns/BuildsQueries.php:296) at Illuminate\Database\Eloquent\Builder->first() (/app/app/Http/Kernel.php:29) at App\Http\Config->handle() (/app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:180) at Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}() (/app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:116) at Illuminate\Pipeline\Pipeline->then() (/app/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php:142) at Illuminate\Foundation\Http\Kernel->sendRequestThroughRouter() (/app/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php:111) at Illuminate\Foundation\Http\Kernel->handle() (/app/vendor/swooletw/laravel-swoole/src/Server/Sandbox.php:257) at SwooleTW\Http\Server\Sandbox->handleRequest() (/app/vendor/swooletw/laravel-swoole/src/Server/Sandbox.php:217) at SwooleTW\Http\Server\Sandbox->prepareObResponse() (/app/vendor/swooletw/laravel-swoole/src/Server/Sandbox.php:179) at SwooleTW\Http\Server\Sandbox->run() (/app/vendor/swooletw/laravel-swoole/src/Server/Manager.php:225) |