zmq-fileserver/file_generator

17 lines
496 B
Plaintext
Raw Normal View History

2020-06-19 17:04:39 +02:00
#!/usr/bin/env php
<?php
$argc < 2 and die('Usage: file_generator <namespace>' . PHP_EOL);
require_once __DIR__ . '/vendor/autoload.php';
$push = (new ZMQContext)->getSocket(ZMQ::SOCKET_PUSH)->connect('ipc:///tmp/storage_server_sink.ipc');
$faker = Faker\Factory::create();
$id = 1;
while (true) {
$document = file_get_contents("https://twitter.com/{$faker->firstName}");
$push->send($argv[1], ZMQ::MODE_SNDMORE)
->send($id++ . '.html', ZMQ::MODE_SNDMORE)
->send($document);
sleep(2);
}