phauthentic/correlation-id-symfony-bundle

1.2.0 2024-04-01 22:14 UTC

This package is auto-updated.

Last update: 2024-08-31 00:27:02 UTC


README

PHP >= 8.1 phpstan Level 8 License: MIT Code Quality

这是一个用于框架无关的 Correlation ID 库 的 Symfony 桥接器。

功能

  • 自动将 Correlation ID 添加到请求和响应中。
    • 可以为每个分别配置头部名称。
  • 提供消息传递戳记和中间件,将为每条消息添加 CorrelationIDStamp。

安装

composer require phauthentic/correlation-id-symfony-bundle

配置

您可以通过配置三个不同的设置来控制行为

  • response_header_name - ID 的响应头部名称。
  • request_header_name - ID 的请求头部名称。
  • pass_through - 如果请求中的 ID 应该传递到响应中,请启用此选项。这对于您正在处理的微服务未公开但由入口点进一步委托操作并必须保留原始 ID 的情况很有用。

config/correlation_id.yaml:

correlation_id:
    response_header_name: 'X-Correlation-ID'
    request_header_name: 'X-Correlation-ID'
    pass_through: false

消息传递中间件

消息传递中间件将为您的消息添加 Correlation ID。只需将中间件添加到您的总线即可。

版权 & 许可

根据 MIT 许可证 许可。

版权 (c) Phauthentic / Florian Krämer