proemergotech / correlate-php-core
PHP编写的微服务关联ID生成的核心接口包。
dev-master
2017-10-11 09:11 UTC
Requires
- webpatser/laravel-uuid: ^2.0
Requires (Dev)
- fzaninotto/faker: ~1.4
- mockery/mockery: ~0.9
- phpunit/phpunit: ^5.0
- squizlabs/php_codesniffer: ^2.8
This package is not auto-updated.
Last update: 2024-09-15 01:22:33 UTC
README
概述
在处理微服务时,跨系统追踪请求非常困难。我们为此找到了解决方案。我们为每个请求和每个服务生成一个唯一的版本4 uuid,并通过请求头将此id传递给其他服务。我们称之为 关联ID。
包
- proemergotech/correlate-php-laravel
- Laravel和Lumen框架的中间件。
- proemergotech/correlate-php-psr-7
- 适用于任何PSR-7兼容框架(如 Slim Framework)的中间件。
- proemergotech/correlate-php-monolog
- 关联中间件的Monolog处理器(您无需直接使用此处理器)。
- proemergotech/correlate-php-guzzle
- 添加关联ID到每个请求的Guzzle中间件。
- proemergotech/correlate-php-core
- 为关联ID中间件提供一致的头名称的通用包。
安装
您不应直接使用此包。
顺便说一句,如果您想直接使用它,您可以通过composer安装。
$ composer require proemergotech/correlate-php-core
默认值
默认头名称为 X-Correlation-ID
,默认参数名称为 x_correlation_id
。
使用方法
生成关联ID
\ProEmergotech\Correlate\Correlate\Correlate::id();
其他方法
\ProEmergotech\Correlate\Correlate::getHeaderName(); \ProEmergotech\Correlate\Correlate::getParamName(); \ProEmergotech\Correlate\Correlate::getGeneratorFunc(); // You can override defaults... \ProEmergotech\Correlate\Correlate::setHeaderName('X-My-Correlation-ID'); \ProEmergotech\Correlate\Correlate::setParamName('my_correlation_id'); \ProEmergotech\Correlate\Correlate::setGeneratorFunc(function(){ return uniqid(); });
贡献
请参阅 CONTRIBUTING.md
文件。
鸣谢
此包由 Soma Szélpál 在 Pro Emergotech Ltd. 开发。
许可证
此项目遵循 MIT 许可证。