-
Notifications
You must be signed in to change notification settings - Fork 84
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: proxy mode [sql changed] (#571)
closes #366 开启代理模式时如果找不到依赖会直接返回上游仓库的manifest信息并缓存于nfs,当请求的tgz文件不存在时从上游仓库获取并返回,同时创建对应版本的同步任务。每小时检查更新已缓存的manifest文件保证上游仓库发布新版本时不会因为缓存落后而404。 <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Introduced proxy cache management for package manifests and versions. - Added new HTTP methods for managing proxy caches. - Implemented scheduled workers for updating and synchronizing proxy cache. - **Updates** - Expanded `SyncMode` enum to include a new value `proxy`. - Updated constants with `PROXY_CACHE_DIR_NAME` and `ABBREVIATED_META_TYPE`. - **Tests** - Added comprehensive test cases for `ProxyCacheService`, `ProxyCacheRepository`, and related controllers. - Verified functionality of scheduled workers for proxy cache updates and synchronization. - Enhanced testing coverage for handling package downloads in proxy mode. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: fengmk2 <[email protected]>
- Loading branch information
1 parent
75d3a66
commit 91aea0f
Showing
28 changed files
with
1,605 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { Entity, EntityData } from './Entity'; | ||
import { EasyData } from '../util/EntityUtil'; | ||
import { DIST_NAMES } from './Package'; | ||
import { isPkgManifest } from '../service/ProxyCacheService'; | ||
import { PROXY_CACHE_DIR_NAME } from '../../common/constants'; | ||
interface ProxyCacheData extends EntityData { | ||
fullname: string; | ||
fileType: DIST_NAMES; | ||
version?: string; | ||
} | ||
|
||
export type CreateProxyCacheData = Omit<EasyData<ProxyCacheData, 'id'>, 'id'| 'filePath'>; | ||
|
||
export class ProxyCache extends Entity { | ||
readonly fullname: string; | ||
readonly fileType: DIST_NAMES; | ||
readonly filePath: string; | ||
readonly version?: string; | ||
|
||
constructor(data: ProxyCacheData) { | ||
super(data); | ||
this.fullname = data.fullname; | ||
this.fileType = data.fileType; | ||
this.version = data.version; | ||
if (isPkgManifest(data.fileType)) { | ||
this.filePath = `/${PROXY_CACHE_DIR_NAME}/${data.fullname}/${data.fileType}`; | ||
} else { | ||
this.filePath = `/${PROXY_CACHE_DIR_NAME}/${data.fullname}/${data.version}/${data.fileType}`; | ||
} | ||
} | ||
|
||
public static create(data: CreateProxyCacheData): ProxyCache { | ||
const newData = { ...data, createdAt: new Date(), updatedAt: new Date() }; | ||
return new ProxyCache(newData); | ||
} | ||
|
||
public static update(data: ProxyCache): ProxyCache { | ||
data.updatedAt = new Date(); | ||
return data; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.