update
This commit is contained in:
39
src/Trait/RpcContextTrait.php
Normal file
39
src/Trait/RpcContextTrait.php
Normal 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');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user