Webman plugin workbunny/webman-nacos

Overview

webman-nacos

webman的nacos-client插件包


简介

  • 目前这套代码在我司生产环境运行,我会做及时的维护;

  • 整体代码与Tinywan/nacos差不多,但实现思路不一样,主要体现在配置的同步处理上;

  • nacos的配置监听项采用了服务端长轮询,有点类似于stream_select,当配置没有改变的时候,会阻塞至请求结束;但当配置有变化时候,会立即返回其配置dataId;

  • 这里我的做法是开启一个Timer对配置进行监听,定时器间隔与长轮询最大阻塞时间一致:

    1. ConfigListenerProcess使用Guzzle的异步请求对配置监听器进行请求处理, onWorkerStart中的Guzzle客户端会阻塞请求,workerman status中会显示BUSY状态;

    2. AsyncConfigListenerProcess使用wokerman/http-client异步请求对配置监听 器进行请求,workerman/http-client使用了workerman的event-loop进行I/O处理, 不会阻塞当前进程,推荐使用;

  • 所有的配置同步后会调用workerman::reloadAllWorkers对所有进程进行重载,保证了config的刷新,包括已经在内存中的各种单例,如 数据库连接、Redis连接等,保证即时将配置传达至需要的业务点;

安装

composer require workbunny/webman-nacos

使用

1. Nacos文档地址

Nacos Open-API文档

2. 代码示例

1. 以获取配置举例

$client = new Workbunny\WebmanNacos\Client();
$response = $client->config->get('database', 'DEFAULT_GROUP');
if (false === $response) {
    var_dump($nacos->config->getMessage());
}

2. 其他接口

# 配置相关接口
$client->config;

# 鉴权相关接口
$client->auth;

# 实例相关接口
$client->instance;

# 系统相关接口
$client->operator;

# 服务相关接口
$client->service;

3. 后缀为Async的方法是Guzzle异步请求,在workerman的on回调中依旧是阻塞,只是多个请求可以并发执行

4. 后缀为AsyncUseEventLoop的方法是workerman/http-client异步请求,在workerman的on回调中是非阻塞的

3. 说明

  1. 整体使用除了配置监听同步部分与 Tinywan/nacos 没有区别,对 Tinywan 表示感谢

  2. workbunny/src/AsyncConfigListenerProcess 为异步非阻塞监听器

  3. workbunny/src/ConfigListenerProcess 为异步阻塞监听器,在同一个进程的Timer周期中会阻塞下一个Timer周期

  4. 配置监听器会reload进程,保证配置即时触达业务点,刷新单例或者常驻的连接

  5. 使用配置方式不必改变,使用webman的config即可,降低封装组件的心智负担

You might also like...
Api.video-wordpress-plugin - The official api.video plugin for WordPress
Api.video-wordpress-plugin - The official api.video plugin for WordPress

api.video WordPress Plugin api.video is the video infrastructure for product builders. Lightning fast video APIs for integrating, scaling, and managin

Ied plugin composer - Inspired Plugin Composer: Create, publish and edit plugins from within Textpattern CMS.

ied_plugin_composer Create, publish and edit plugins from within Textpattern CMS. Creates a new page under the Extensions tab where you can edit and e

BetterMobs - a plugin Remixed, by MadoxMC, the original plugin is maked by tgwaste

BetterMobsOverworld BetterMobs is a plugin Remixed, by MadoxMC, the original plugin is maked by tgwaste. MadoxMC Just Edited This plugin to Make 3 Compatible Plugins to add Mobs on your Overworld Worlds, NetherWorlds & EndWorlds, MadoxMC Idea.

BetterMobs is a plugin Remixed, by MadoxMC, the original plugin is maked by tgwaste.

BetterMobs is a plugin Remixed, by MadoxMC, the original plugin is maked by tgwaste. MadoxMC Just Edited This plugin to Make 3 Compatible Plugins to add Mobs on your Overworld Worlds, NetherWorlds & EndWorlds, MadoxMC Idea.

Opinionated version of Wikimedia composer-merge-plugin to work in pair with Bamarni composer-bin-plugin.

Composer Inheritance Plugin Opinionated version of Wikimedia composer-merge-plugin to work in pair with bamarni/composer-bin-plugin. Usage If you are

jMQTT is a plugin for Jeedom aiming to connect Jeedom to an MQTT broker to subscribe and publish messages
jMQTT is a plugin for Jeedom aiming to connect Jeedom to an MQTT broker to subscribe and publish messages

jMQTT is a plugin for Jeedom aiming to connect Jeedom to an MQTT broker to subscribe and publish messages

Formcreator is a plugin which allow creation of custom forms of easy access
Formcreator is a plugin which allow creation of custom forms of easy access

Formcreator is a plugin which allow creation of custom forms of easy access. At the same time, the plugin allow the creation of one or more tickets when the form is filled.

vPOS Official Wordpres WooCommerce Plugin
vPOS Official Wordpres WooCommerce Plugin

vPOS - WooCommerce The number #1 payment solution in Angola This plugin currently works for the solutions listed below: EMIS GPO (Multicaixa Express)

Comments
Releases(1.1.4)
  • 1.1.4(Dec 18, 2022)

    What's Changed

    • Update README.md by @Tinywan in https://github.com/workbunny/webman-nacos/pull/5

    Full Changelog: https://github.com/workbunny/webman-nacos/compare/1.1.3...1.1.4

    Source code(tar.gz)
    Source code(zip)
  • 1.1.3(Sep 1, 2022)

  • 1.1.2(Aug 27, 2022)

    What's Changed

    • 功能优化 by @krissss in https://github.com/workbunny/webman-nacos/pull/4

    Full Changelog: https://github.com/workbunny/webman-nacos/compare/1.1.1...1.1.2

    Source code(tar.gz)
    Source code(zip)
  • 1.1.1(Aug 23, 2022)

    What's Changed

    • 修复requestAsyncUseEventLoop中的uri与config中的错误配置 by @sunsgneayo in https://github.com/workbunny/webman-nacos/pull/3

    New Contributors

    • @sunsgneayo made their first contribution in https://github.com/workbunny/webman-nacos/pull/3

    Full Changelog: https://github.com/workbunny/webman-nacos/compare/1.1.0...1.1.1

    Source code(tar.gz)
    Source code(zip)
  • 1.1.0(Aug 22, 2022)

  • 1.0.2(Jun 15, 2022)

    What's Changed

    • Update README.md by @Tinywan in https://github.com/workbunny/webman-nacos/pull/1
    • nacos 2.0.3 下 beat 问题处理 by @krissss in https://github.com/workbunny/webman-nacos/pull/2

    New Contributors

    • @Tinywan made their first contribution in https://github.com/workbunny/webman-nacos/pull/1
    • @krissss made their first contribution in https://github.com/workbunny/webman-nacos/pull/2

    Full Changelog: https://github.com/workbunny/webman-nacos/compare/1.0.1...1.0.2

    Source code(tar.gz)
    Source code(zip)
  • 1.0.1(May 13, 2022)

  • 1.0.0(May 12, 2022)

    正式版发布

    1. 配置监听器非侵入,在webman环境下直接使用config()即可,无需侵入改造
    2. 配置更新可触达常驻连接等业务点,自动触发Workers的reload
    3. 文件接近零延迟的同步
    4. 提供以下两种配置监听器使用,在process.php中进行配置:
      • 异步非阻塞配置监听器
      • 同步并发阻塞配置监听器
    5. 提供常规的Nacos API方法
    Source code(tar.gz)
    Source code(zip)
  • 0.0.1(May 10, 2022)

Owner
workbunny
workbunny
A PHP implementation of RabbitMQ Client for webman plugin.

workbunny/webman-rabbitmq ?? A PHP implementation of RabbitMQ Client for webman plugin. ?? A PHP implementation of RabbitMQ Client for webman plugin 常

workbunny 15 Dec 15, 2022
Webman quickly creates a verification code tool similar to Google verification code

webman-captcha-grid webman quickly creates a verification code tool similar to Google verification code webman 快速创建一个类似于 Google 点图验证码的本地验证码扩展 介绍 webma

听风吹雨 6 Dec 5, 2022
Very easy to use a current limiting component, the code is very simple, based on the webman framework.

Very easy to use a current limiting component, the code is very simple, based on the webman framework.

nsp-team 13 Dec 29, 2022
Laravel illuminate/filesystem for webman

webman-tech/laravel-filesystem Laravel illuminate/filesystem for webman 介绍 站在巨人(laravel)的肩膀上使文件存储使用更加可靠和便捷 所有方法和配置与 laravel 几乎一模一样,因此使用方式完全参考 Laravel文

null 5 Dec 15, 2022
A plugin manager for PocketMine-MP downloads plugin from PocketMine-MP official plugin repository

oh-my-pmmp A plugin manager for PocketMine-MP Getting Started Prerequisites Your server MUST RUN the latest version of PocketMine. Installation From P

thebigcrafter 6 Jan 4, 2023
Integrates the ClassicPress Plugin Directory and any plugin stored in GitHub (tagged with classicpress-plugin) in the ClassicPress Admin

ClassicPress Plugin Directory Adds a new screen in a ClassicPress Install where you can browse, install, activate, deactivate, update, delete and pagi

TukuToi 3 Dec 27, 2022
This Pocketmine-MP plugin is a plugin including a complete faction system.

SimpleFaction Simple faction plugin replacing FactionsPro which is no longer updated. Commands Command Name Command Description Available for /f help

Ayzrix 33 Dec 19, 2022
SpawnInLobby Pocketmine-MP plugin. With this plugin the player will always join the game at the default world spawn point

SpawnInLobby Pocketmine-MP plugin. With this plugin the player will always join the game at the default world spawn point

null 1 Jan 7, 2022
Ratio plugin is a luck plugin. The more lucky you are, the more you win!

Ratio Ratio plugin is a luck plugin. The more lucky you are, the more you win Features When you break a block (Cobblestone), it gives/puts you somethi

Ali Tura Çetin 2 Apr 25, 2022
actionMaster is a new faction plugin that aims at flexibility and customization of the plugin by the user and the developers.

FactionMaster is a new faction plugin that aims at flexibility and customization of the plugin by the user and the developers. It includes all the basic functionality of a faction plugin and data storage in MySQL or SQLITE. This is done by adding an extension system and a translation system. FactionMaster has a will of accessibility to the players and especially not to have to remember a lot of commands to play, all is done via interface.

FactionMaster 21 Dec 26, 2022