定制 umbrellio/php-table-sync 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

umbrellio/php-table-sync

Composer 安装命令:

composer require umbrellio/php-table-sync

包简介

PHP's implementation of the library providing data synchronization between microservices

README 文档

README

PHP's implementation of the library providing data synchronization between microservices

Github Status Coverage Status Latest Stable Version Total Downloads Code Intelligence Status Build Status Code Coverage Scrutinizer Code Quality

Installation

composer require umbrellio/php-table-sync
php artisan vendor:publish --tag=config-table-sync

Usage

Let's describe the model that needs to be synchronized using an example User.php

...
User extends Model implements SyncableModel
{
    use TableSyncable;

...

    public function routingKey(): string
    {
        return 'users';
    }

    public function getTableSyncableAttributes(): array
    {
        return [
            'id' => $this->external_id,
            'login' => $this->name,
            'email' => $this->email,
        ];
    }
...

When the model changes, the data will be sent according to the rules of TableSyncObserver, to get the data you need to run the command table_sync:work

Logging

Logging based on the Monolog package and contains some extensions for it.

  • specify the logging channel in config/table_sync.php
...
'log' => [
    'channel' => 'table_sync',
],
...
  • and describe this channel in config/logging.php
...
'table_sync' => [
    'driver' => 'stack',
    'channels' => ['table_sync_daily', 'influxdb'],
],
'table_sync_daily' => [
    'driver' => 'daily',
    'formatter' => LineTableSyncFormatter::class,
    'formatter_with' => [
        'format' => '[%datetime%] %message% - %model% %event%',
    ],
    'path' => storage_path('logs/table_sync/daily.log'),
],
'influxdb' => [
    'driver' => 'influxdb',
    'measurement' => 'table_sync',
],
...
You can use the built-in LineTableSyncFormatter::class with the available parameters: %datetime% %message% %direction% %model% %event% %routing% %attributes% %exception%
Driver influxdb is an additional option and is not required to add in config
...
'table_sync' => [
    'driver' => 'daily',
],
...

Authors

Created by Korben Dallas.

Supported by Umbrellio

统计信息

  • 总下载量: 47.97k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 5
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 5
  • Watchers: 2
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-12-26

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固