public function testFactory_001() { $dummy_kinesis = KinesisClient::factory(array('key' => 'XXXXXX', 'secret' => 'XXXXX', 'region' => Region::VIRGINIA)); $proxy1 = KinesisProxy::factory($dummy_kinesis, 'hoge'); $proxy2 = KinesisProxy::factory($dummy_kinesis, 'hoge'); $proxy3 = KinesisProxy::factory($dummy_kinesis, 'foo'); $this->assertTrue(spl_object_hash($proxy1) === spl_object_hash($proxy2)); $this->assertFalse(spl_object_hash($proxy1) === spl_object_hash($proxy3)); }
<?php require '../vendor/autoload.php'; use Aws\Kinesis\KinesisClient; use Aws\Common\Enum\Region; use Rf\Aws\Kinesis\ClientLibrary\KinesisProxy; define('STREAM_NAME', 'kinesis-trial'); $kinesis = KinesisClient::factory(array('key' => 'XXXXX', 'secret' => 'XXXXX', 'region' => Region::VIRGINIA)); $kinesis_proxy = KinesisProxy::factory($kinesis, STREAM_NAME); while (true) { $sample_data = date('YmdHis'); $kinesis_proxy->putRecord($sample_data, mt_rand(1, 1000000)); echo $sample_data, PHP_EOL; sleep(1); }
<?php require '../vendor/autoload.php'; require '../src/Rf/Aws/AutoLoader.php'; use Aws\Kinesis\KinesisClient; use Aws\Common\Enum\Region; use Rf\Aws\AutoLoader; use Rf\Aws\Kinesis\ClientLibrary\KinesisProxy; use Rf\Aws\Kinesis\ClientLibrary\KinesisShardFileDataStore; use Rf\Aws\Kinesis\ClientLibrary\KinesisShardMemcacheDataStore; use Rf\Aws\Kinesis\ClientLibrary\KinesisStorageManager; define('STREAM_NAME', 'kinesis-trial'); AutoLoader::register(); $kinesis = KinesisClient::factory(array('key' => 'XXXXX', 'secret' => 'XXXXX', 'region' => Region::VIRGINIA)); $kinesis_proxy = KinesisProxy::factory($kinesis, 'kinesis-trial'); $kinesis_storage_manager = new KinesisStorageManager($kinesis_proxy, new KinesisShardFileDataStore('/tmp/amazon-kinesis')); // $memcache = new Memcache; // $memcache->addServer("localhost", 11211); // $kinesis_proxy = KinesisProxy::factory($kinesis, new KinesisShardMemcacheDataStore($memcache), STREAM_NAME); $data_records = $kinesis_storage_manager->findWithMergeStoreDataRecords(null, 10, 5); foreach ($data_records as $data_record) { echo $data_record->getData(), PHP_EOL; } $kinesis_storage_manager->saveAll();