webalternatif/flysystem-failover-bundle
Composer 安装命令:
composer require webalternatif/flysystem-failover-bundle
包简介
A bundle to create failover Flysystem adapters.
README 文档
README
This bundle allows creating failover Flysystem adapters and provides tooling to keep underlying storages synchronized.
💡 Tip: you may want to use this bundle through webalternatif/flysystem-dsn-bundle, which makes the configuration much easier.
How it works
This bundle allows you to create failover adapters for Flysystem. A failover adapter is an adapter that is built upon multiple (already existing) adapters.
When you use a failover adapter, it will forward method calls to inner adapters.
- For reading, it will use the first that works.
- For writing, it will use the first that works and will push messages into a repository to keep underlying storages of all adapters synchronized.
Messages in the repository can then be asynchronously processed by a console command call (see Processing messages section).
Installation
Make sure Composer is installed globally, as explained in the installation chapter of the Composer documentation.
Applications that use Symfony Flex
Open a command console, enter your project directory and execute:
$ composer require webalternatif/flysystem-failover-bundle
Applications that don't use Symfony Flex
Step 1: Download the Bundle
Open a command console, enter your project directory and execute the following command to download the latest stable version of this bundle:
$ composer require webalternatif/flysystem-failover-bundle
Step 2: Enable the Bundle
Then, enable the bundle by adding it to the list of registered bundles in the
config/bundles.php file of your project:
// config/bundles.php return [ // ... Webf\FlysystemFailoverBundle\WebfFlysystemFailoverBundle::class => ['all' => true], ];
Usage
Configuration
Failover adapters are configured under the webf_flysystem_failover.adapters
Symfony config path, and are then available as services with id
webf_flysystem_failover.adapter.{name}.
Each failover adapter must have at least 2 inner adapters. An inner adapter could be a string to reference a service id, or an array with the following attributes:
service_id: (required) identifier of the inner adapter service,time_shift: a time shift for when the synchronization command compares modification dates between inner adapters.
Message repository is customizable under the
webf_flysystem_failover.message_repository_dsn Symfony config path. For now,
only doctrine://<connection_name> and service://<service_id> are available.
webf_flysystem_failover: adapters: adapter1: # service: webf_flysystem_failover.adapter.adapter1 adapters: - service_id_of_adapter_1 - service_id: service_id_of_adapter_2 time_shift: 7200 # underlying storage of this adapter use a +02:00 timezone adapter2: # service: webf_flysystem_failover.adapter.adapter2 adapters: - service_id_of_adapter_3 - service_id_of_adapter_4 - service_id_of_adapter_5 message_repository_dsn: doctrine://my_connection
Run bin/console config:dump-reference webf_flysystem_failover for more info.
Processing messages
To process messages created by failover adapters, the following command is available:
$ bin/console webf:flysystem-failover:process-messages
It will process and remove the oldest messages present in the repository.
Listing messages to be processed
To list messages without removing them from the repository, run the following command:
$ bin/console webf:flysystem-failover:list-messages
Results are paginated by default, you can use --limit (-l) and --page
(-p) to configure pagination.
If symfony/serializer is installed, the --format (-f) becomes
available and allows you to display output in csv, json or xml.
Use --help for more info.
Synchronize existing storages
If you start to use this bundle on an existing project, you may want to manually synchronize an existing non-empty storage with other new empty ones.
It is possible with the following command:
$ bin/console webf:flysystem-failover:sync
Use --help for more info.
Tests
To run all tests, execute the command:
$ composer test
This will run Psalm, PHPUnit, Infection and a PHP-CS-Fixer check, but you can run them individually like this:
$ composer psalm $ composer phpunit $ composer infection $ composer cs-check
webalternatif/flysystem-failover-bundle 适用场景与选型建议
webalternatif/flysystem-failover-bundle 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 2.84k 次下载、GitHub Stars 达 2, 最近一次更新时间为 2021 年 09 月 10 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「filesystem」 「storage」 「bundle」 「adapter」 「failover」 「Flysystem」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 webalternatif/flysystem-failover-bundle 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 webalternatif/flysystem-failover-bundle 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 webalternatif/flysystem-failover-bundle 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A SDK for working with B2 cloud storage.
A PHP class providing static methods for reading, writing, copying, moving, and deleting files and directories, MIME type detection, image size detection, and file permission management
Small library to access Microsoft Windows Azure Blob Storage with a Service or a StreamWrapper.
2lenet/EasyAdminPlusBundle
The bundle for easy using json-rpc api on your project
The flysystem adapter for yandex disk rest api.
统计信息
- 总下载量: 2.84k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 17
- 依赖项目数: 3
- 推荐数: 1
其他信息
- 授权协议: MIT
- 更新时间: 2021-09-10