mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-30 12:11:56 +00:00
add error status (#2746)
* add error status * update types * ṗ̶̰̙̓͒̈́ͅü̵̢̙̫̣ŗ̷̪̺̺͛g̴̲͉͎̬̒̇e̵̪̎̅͌ ̶̡̜̘͐͛t̶͎͍̣̿̍̐h̴͕̩͗̈́̎̑e̵͚͒̂͝ ̸̛͙̦͈͝v̶̱͙̬̽̔ọ̶̧̡̒̓i̸̬̲͍̋̈́d̴͉̀ * fix some extra voids * add `package.rebuild` * introduce error status and pkg rebuild and fix mocks * minor fixes * fix build --------- Co-authored-by: Matt Hill <mattnine@protonmail.com>
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import * as T from "../types"
|
||||
import { once } from "../util"
|
||||
import { AddressReceipt } from "./AddressReceipt"
|
||||
|
||||
declare const UpdateServiceInterfacesProof: unique symbol
|
||||
@@ -21,34 +22,36 @@ export const setupServiceInterfaces: SetupServiceInterfaces = <
|
||||
Output extends ServiceInterfacesReceipt,
|
||||
>(
|
||||
fn: SetServiceInterfaces<Output>,
|
||||
) =>
|
||||
((options: { effects: T.Effects }) => {
|
||||
const updater = async (options: { effects: T.Effects }) => {
|
||||
const bindings: T.BindId[] = []
|
||||
const interfaces: T.ServiceInterfaceId[] = []
|
||||
const res = await fn({
|
||||
effects: {
|
||||
...options.effects,
|
||||
bind: (params: T.BindParams) => {
|
||||
bindings.push({ id: params.id, internalPort: params.internalPort })
|
||||
return options.effects.bind(params)
|
||||
},
|
||||
exportServiceInterface: (params: T.ExportServiceInterfaceParams) => {
|
||||
interfaces.push(params.id)
|
||||
return options.effects.exportServiceInterface(params)
|
||||
},
|
||||
},
|
||||
})
|
||||
await options.effects.clearBindings({ except: bindings })
|
||||
await options.effects.clearServiceInterfaces({ except: interfaces })
|
||||
return res
|
||||
) => {
|
||||
const cell = {
|
||||
updater: (async (options: { effects: T.Effects }) =>
|
||||
[] as any as Output) as UpdateServiceInterfaces<Output>,
|
||||
}
|
||||
cell.updater = (async (options: { effects: T.Effects }) => {
|
||||
options.effects = {
|
||||
...options.effects,
|
||||
constRetry: once(() => {
|
||||
cell.updater(options)
|
||||
}),
|
||||
}
|
||||
const updaterCtx = { options }
|
||||
updaterCtx.options = {
|
||||
const bindings: T.BindId[] = []
|
||||
const interfaces: T.ServiceInterfaceId[] = []
|
||||
const res = await fn({
|
||||
effects: {
|
||||
...options.effects,
|
||||
constRetry: () => updater(updaterCtx.options),
|
||||
bind: (params: T.BindParams) => {
|
||||
bindings.push({ id: params.id, internalPort: params.internalPort })
|
||||
return options.effects.bind(params)
|
||||
},
|
||||
exportServiceInterface: (params: T.ExportServiceInterfaceParams) => {
|
||||
interfaces.push(params.id)
|
||||
return options.effects.exportServiceInterface(params)
|
||||
},
|
||||
},
|
||||
}
|
||||
return updater(updaterCtx.options)
|
||||
})
|
||||
await options.effects.clearBindings({ except: bindings })
|
||||
await options.effects.clearServiceInterfaces({ except: interfaces })
|
||||
return res
|
||||
}) as UpdateServiceInterfaces<Output>
|
||||
return cell.updater
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user