Amazon AWS SDK Guida di Installazione Pagina 46

  • Scaricare
  • Aggiungi ai miei manuali
  • Stampa
  • Pagina
    / 151
  • Indice
  • SEGNALIBRI
  • Valutato. / 5. Basato su recensioni clienti
Vedere la pagina 45
namespace MyApp\FakeWaiters
{
use Aws\Common\Waiter\AbstractResourceWaiter;
class SleptThreeTimes extends AbstractResourceWaiter
{
public function doWait()
{
if ($this->attempts < 3) {
echo "Need to sleep…\n";
return false;
} else {
echo "Now I've slept 3 times.\n";
return true;
}
}
}
}
namespace
{
use Aws\S3\S3Client;
use Aws\Common\Waiter\WaiterClassFactory;
$s3Client = S3Client::factory();
$compositeFactory = $s3Client->getWaiterFactory();
$compositeFactory->addFactory(new WaiterClassFactory('MyApp\FakeWaiters'));
$waiter = $s3Client->waitUntilSleptThreeTimes();
}
The result of this code should look like the following:
Need to sleep
Need to sleep
Need to sleep
Now I've slept 3 times.
Waiter Definitions
The waiters that are included in the SDK are defined in the service description for their client. They are defined using
a configuration DSL (domain-specific language) that describes the default wait intervals, wait conditions, and how to
check or poll the resource to resolve the condition.
This data is automatically consumed and used by the Aws\Common\Waiter\WaiterConfigFactory class
when a client is instantiated so that the waiters defined in the service description are available to the client.
The following is an excerpt of the Amazon Glacier service description that defines the waiters provided by
Aws\Glacier\GlacierClient.
return array(
// ...
'waiters' => array(
'__default__' => array(
'interval' => 3,
'max_attempts' => 15,
),
'__VaultState' => array(
'operation' => 'DescribeVault',
),
Waiters
34
Vedere la pagina 45
1 2 ... 41 42 43 44 45 46 47 48 49 50 51 ... 150 151

Commenti su questo manuale

Nessun commento