proemergotech/correlate-php-core

PHP编写的微服务关联ID生成的核心接口包。

dev-master 2017-10-11 09:11 UTC

This package is not auto-updated.

Last update: 2024-09-15 01:22:33 UTC


README

概述

在处理微服务时,跨系统追踪请求非常困难。我们为此找到了解决方案。我们为每个请求和每个服务生成一个唯一的版本4 uuid,并通过请求头将此id传递给其他服务。我们称之为 关联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álPro Emergotech Ltd. 开发。

许可证

此项目遵循 MIT 许可证