Skip to content

Commit

Permalink
feat: Job 支持多租户 TencentBlueKing#3369
Browse files Browse the repository at this point in the history
  • Loading branch information
wangyu096 committed Jan 9, 2025
1 parent 6b248d1 commit 67e66ac
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public StandardLoginClient(BkLoginApiClient bkLoginApiClient) {
}

/**
* 获取指定用户信息
* 根据 token 获取指定用户信息
*
* @param bkToken 用户登录 token
* @return 用户信息
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package com.tencent.bk.job.common.paas.user;

import com.tencent.bk.job.common.paas.model.OpenApiTenant;

import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.locks.ReadWriteLock;
import java.util.concurrent.locks.ReentrantReadWriteLock;

/**
* 租户信息缓存
*/
public class TenantLocalCache {

private final UserMgrApiClient userMgrApiClient;

private ScheduledThreadPoolExecutor refresher = new ScheduledThreadPoolExecutor(1);


private final Map<String, OpenApiTenant> tenantCache = new HashMap<>();

private volatile boolean initialed = false;

private final ReadWriteLock lock = new ReentrantReadWriteLock();


public TenantLocalCache(UserMgrApiClient userMgrApiClient) {
this.userMgrApiClient = userMgrApiClient;
// refresher.scheduleAtFixedRate(this::loadCache, )
}

public OpenApiTenant get(String tenantId) {
if (!initialed) {
loadCache();
initialed = true;
}
return null;
}

private void loadCache() {

}
}

0 comments on commit 67e66ac

Please sign in to comment.