示例#1
0
/**
 * @param $config
 * @param MessageService $service
 * @param MessageStore $store
 * @param $participant
 * @param $by
 * @throws Exception
 */
function catchupParticipant($config, $service, $store, $participant, $by)
{
    $timestamp = time() * 1000;
    $offset = 0;
    $limit = 1000;
    do {
        echo "fetch {$timestamp} limit {$limit} - ";
        $res = $service->getThreadRange($participant, $timestamp, $offset, $limit, $by);
        $messages = $res->payload->actions;
        var_dump(count($messages));
        echo "importing - ";
        var_dump($saveRes = $store->save($messages));
        if ($saveRes['success'] == 0) {
            echo "failures, stopping\n";
            break;
        }
        $timestamp = $messages[0]->timestamp;
    } while (true);
}