Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- threads::Worker apiWorker(const ConfigHolder& config, MySQL& mysql,
- ExportQueue& in, WriteQueue& out)
- {
- auto consumer = [&config, &out](const GroupId& groupId)
- {
- auto progress = [&mysql, groupId](uint32_t current, uint32_t total)
- {
- mysql.updateCount(groupId, current, total);
- };
- auto groupInfo = apiFetch(config, groupId, progress);
- out.push(groupInfo);
- };
- auto failure = [&mysql](const GroupId& groupId, std::exception& error)
- {
- logger.rb::streamError("%s", error.what());
- mysql.updateStatus(groupId, GroupStatus::API_EXPORTING);
- };
- return threads::queueConsumer(in, 100, consumer, failure);
- }
- threads::Supervisor apiSupervisor(const ConfigHolder& config, MySQL& mysql,
- ExportQueue& in, WriteQueue& out)
- {
- auto workerCreate = [&]()
- {
- return apiWorker(config, mysql, in, out);
- };
- threads::Supervisor sResult(workerCreate);
- sResult.resize(config.get()->api.worker_count);
- return sResult;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement