/*
|
* Copyright (c) 2018-2028, DreamLu All rights reserved.
|
*
|
* Redistribution and use in source and binary forms, with or without
|
* modification, are permitted provided that the following conditions are met:
|
*
|
* Redistributions of source code must retain the above copyright notice,
|
* this list of conditions and the following disclaimer.
|
* Redistributions in binary form must reproduce the above copyright
|
* notice, this list of conditions and the following disclaimer in the
|
* documentation and/or other materials provided with the distribution.
|
* Neither the name of the dreamlu.net developer nor the names of its
|
* contributors may be used to endorse or promote products derived from
|
* this software without specific prior written permission.
|
* Author: DreamLu 卢春梦 (596392912@qq.com)
|
*/
|
package org.springblade.core.context;
|
|
import org.springframework.lang.Nullable;
|
|
import java.util.function.Function;
|
|
/**
|
* Blade微服务上下文
|
*
|
* @author L.cm
|
*/
|
public interface BladeContext {
|
|
/**
|
* 获取 请求 id
|
*
|
* @return 请求id
|
*/
|
@Nullable
|
String getRequestId();
|
|
/**
|
* 账号id
|
*
|
* @return 账号id
|
*/
|
@Nullable
|
String getAccountId();
|
|
/**
|
* 获取租户id
|
*
|
* @return 租户id
|
*/
|
@Nullable
|
String getTenantId();
|
|
/**
|
* 获取上下文中的数据
|
*
|
* @param ctxKey 上下文中的key
|
* @return 返回对象
|
*/
|
@Nullable
|
String get(String ctxKey);
|
|
/**
|
* 获取上下文中的数据
|
*
|
* @param ctxKey 上下文中的key
|
* @param function 函数式
|
* @param <T> 泛型对象
|
* @return 返回对象
|
*/
|
@Nullable
|
<T> T get(String ctxKey, Function<String, T> function);
|
}
|