This commit is contained in:
2026-07-29 15:29:51 +08:00
parent e33dc56982
commit 641d3ffac5
12 changed files with 603 additions and 1 deletions

View File

@@ -0,0 +1,39 @@
<?php
/**
* RPC上下文内容
*/
declare(strict_types=1);
namespace Dhd\Micro\Core\Trait;
use Hyperf\Rpc\Context as RpcContext;
use Dhd\Micro\Core\Library\Util;
trait RpcContextTrait
{
/**
* 获取traceId
*/
public function getTraceId(): ?string
{
return Util::get(RpcContext::class)->get('trace_id');
}
/**
* 获取app版本号
*/
public function getAppVersion(): ?string
{
return Util::get(RpcContext::class)->get('app_version');
}
/**
* 获取平台名称
*/
public function getPlatformName(): ?string
{
return Util::get(RpcContext::class)->get('platform_name');
}
}