Function: randomDBShard()

function randomDBShard(string $load_balancing_group): ?\SmartFactory\DatabaseWorkers\DBWorker;

Short function for requesting the dbworker connected to the specified shard, that is chosen randomly for load balancing reason.

Parameters

Name Pass type Value type Default value Description
$load_balancing_group by value string

The name of the shard.

Returns

?\SmartFactory\DatabaseWorkers\DBWorker

returns DBWorker object or null if the object could not be created.

Throws

\Exception

It might throw the following exceptions in the case of any errors:

  • if the load balancing group was not found.
  • db_server_conn_error - if the database server cannot be connected.
  • db_not_exists_error - if database does not exists od inaccesible to the user.

Authors

Oleg Schildt

Package

Source code