namelesscoder/typo3-cms-progressor
Composer 安装命令:
composer require namelesscoder/typo3-cms-progressor
包简介
Progress monitoring in backend of long-running TYPO3 tasks
README 文档
README
Renders progress bars in the TYPO3 backend header for long-running tasks.
Installing
Available only through Composer/Packagist:
composer require namelesscoder/typo3-cms-progressor
Features
- Uses an absolute minimum of configuration to start a monitoring process.
- Fire-and-forget progress monitoring integration for your own tasks via one-liner method calls.
- Integration for DataHandler tasks which makes one progress bar per backend user.
- Integration with database tables via prepared QueryBuilder instances that select "pending" records.
The DataHandler integration can be enabled via extension configuration. The other features require writing code either
inside your own long-running tasks, or in ext_localconf.php files to register QueryBuilder instances that will then
be monitored automatically whenever there are pending records.
How to use: QueryBuilder integration
Using the QueryBuilder integration to monitor pending records in any table requires creating and preparing the QueryBuilder instance and then handing it off to Progressor - the rest is handled automatically.
Your QueryBuilder instance can be registered anywhere (as long as that place is executed during any request) - for
example in your ext_localconf.php file:
// Example: consider all hidden records in table "pages" to be a "pending" queue item. This shows a progress bar if // there are any hidden pages in the site and adds progress as each page gets enabled. // Note that in order to select hidden records you do need to remove the restriction for such records. $queryBuilder = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Database\ConnectionPool::class) ->getQueryBuilderForTable('pages'); $queryBuilder->getRestrictions()->removeByType(\TYPO3\CMS\Core\Database\Query\Restriction\HiddenRestriction::class); $queryBuilder->select('uid')->from('pages')->where('hidden = 1'); \NamelessCoder\Progressor\Progressor::trackProgressWithQuery($queryBuilder, 60, 'Hidden Pages');
This registers that QueryBuilder instance as the way Progressor reads progress information. The query is fired and all rows are counted, then this initial row count is stored in a transient storage which auto-expires and each time the progress information is read from the TYPO3 backend the progress is calculated based on current number of pending rows vs initial number of pending rows. Once no more pending records remain the progress bar expires after 60 seconds.
The query should be as light as possible - one way to do that is to make sure it selects a minimum of columns and
definitely not select *. A good column to select which is usually there, is the uid column. The query must return
the rows that are "pending" and must not use dynamic values that change throughout a request because this causes skew
in the expected number of updates. Aside from that, it has no other side effects such as inability to execute the query.
- The first parameter is the QueryBuilder instance.
- The second parameter is the expected maximum time between each "tick" (you should multiply by 1.5 for safety).
- The third parameters is a label for your progress bar.
How to use: Fire and forget API
Another way to use Progressor is from inside your own code, for example in loops which handle large amounts of records or files and does one iteration for each resource. By calling a single method from such places you can initialize and continually update a progress bar with the same method:
$expectedUpdates = 123; // This can be continually updated if loop skips/appends entries along the way \NamelessCoder\Progressor\Progressor::recordProgress('myprogress', $expectedUpdates, 'My progress');
The first time this method is called, or if the $expectedUpdates changes, the internal counter is (re-)initialized
with that new value. If the counter already exists, 1 unit of progress is added. When your loop finishes it should
then have reached a state where the internal counter has counted exactly the number of items you specified as expected.
Like the other integrations, after 60 seconds such an ad-hoc progress bar is automatically removed.
- The first parameter for the
recordProgressmethod is unique name for your instance of the progress bar. - The second parameter is optional and can contain the expected number of updates.
- The third parameter is a label for your progress bar (which should remain the same throughout the loop)
Limitations
- Progressor's monitoring is relatively naive with minimal safeguards, but one of the safeguards is that any values that are out of range (for example causing a completeness above 100%) will be truncated to the maximum logical value.
- The memory of Progressor is currently based on the caching framework and requires a cache backend which supports tags. This unfortunately means that the default implementation is a database table and causes additional database queries.
namelesscoder/typo3-cms-progressor 适用场景与选型建议
namelesscoder/typo3-cms-progressor 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 10 次下载、GitHub Stars 达 3, 最近一次更新时间为 2019 年 04 月 05 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 namelesscoder/typo3-cms-progressor 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 namelesscoder/typo3-cms-progressor 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 10
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 6
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: GPL-2.0
- 更新时间: 2019-04-05