dsh 0.2.0-rc.2: in-container update (experimental channel), path-agnostic compose, upstream patches adapted to 0.1.x/0.2.x
This commit is contained in:
commit
e6dcef9bf5
302 files changed
+75178
No files matched your search
@@ -0,0 +1,38 @@
|
||||
import { PROXY_PORTS } from './contracts.mjs'
|
||||
|
||||
function enabled(configuration, scope) {
|
||||
if (!configuration.enabled) return false
|
||||
if (scope === 'sharedDsh') return configuration.scopes.dshCore || configuration.scopes.dshPlugins
|
||||
if (scope === 'modelApi') {
|
||||
return configuration.modelApi.default.proxyEnabled
|
||||
|| Object.values(configuration.modelApi.providers).some(policy => policy.proxyEnabled)
|
||||
}
|
||||
return configuration.scopes[scope] === true
|
||||
}
|
||||
|
||||
export class ProxyRouteHealth {
|
||||
constructor() {
|
||||
this.revision = null
|
||||
this.routes = new Map()
|
||||
}
|
||||
|
||||
observe(snapshot, scope, outcome) {
|
||||
if (snapshot.revision !== this.revision) {
|
||||
this.revision = snapshot.revision
|
||||
this.routes.clear()
|
||||
}
|
||||
if (!['ready', 'degraded'].includes(outcome)) throw new TypeError('proxy route health outcome is invalid')
|
||||
this.routes.set(scope, outcome)
|
||||
}
|
||||
|
||||
status(snapshot) {
|
||||
if (snapshot.revision !== this.revision) {
|
||||
this.revision = snapshot.revision
|
||||
this.routes.clear()
|
||||
}
|
||||
return Object.freeze(Object.fromEntries(Object.keys(PROXY_PORTS).map(scope => [
|
||||
scope,
|
||||
enabled(snapshot.configuration, scope) ? (this.routes.get(scope) ?? 'unknown') : 'direct',
|
||||
])))
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user