MCPcopy Index your code
hub / github.com/Effect-TS/effect / makeEncoded

Function makeEncoded

packages/cluster/src/RunnerStorage.ts:136–175  ·  view source on GitHub ↗
(encoded: Encoded)

Source from the content-addressed store, hash-verified

134 * @category layers
135 */
136export const makeEncoded = (encoded: Encoded) =>
137 RunnerStorage.of({
138 getRunners: Effect.gen(function*() {
139 const runners = yield* encoded.getRunners
140 const results: Array<[Runner, boolean]> = []
141 for (let i = 0; i < runners.length; i++) {
142 const [runner, healthy] = runners[i]
143 try {
144 results.push([Runner.decodeSync(runner), healthy])
145 } catch {
146 //
147 }
148 }
149 return results
150 }),
151 register: (runner, healthy) =>
152 Effect.map(
153 encoded.register(encodeRunnerAddress(runner.address), Runner.encodeSync(runner), healthy),
154 MachineId.make
155 ),
156 unregister: (address) => encoded.unregister(encodeRunnerAddress(address)),
157 setRunnerHealth: (address, healthy) => encoded.setRunnerHealth(encodeRunnerAddress(address), healthy),
158 acquire: (address, shardIds) => {
159 const arr = Array.from(shardIds, (id) => id.toString())
160 if (!isNonEmptyArray(arr)) return Effect.succeed([])
161 return encoded.acquire(encodeRunnerAddress(address), arr).pipe(
162 Effect.map((shards) => shards.map(ShardId.fromString))
163 )
164 },
165 refresh: (address, shardIds) =>
166 encoded.refresh(encodeRunnerAddress(address), Array.from(shardIds, (id) => id.toString())).pipe(
167 Effect.map((shards) => shards.map(ShardId.fromString))
168 ),
169 release(address, shardId) {
170 return encoded.release(encodeRunnerAddress(address), shardId.toString())
171 },
172 releaseAll(address) {
173 return encoded.releaseAll(encodeRunnerAddress(address))
174 }
175 })
176
177/**
178 * @since 1.0.0

Callers 1

MemoryDriverClass · 0.85

Calls 9

encodeRunnerAddressFunction · 0.85
isNonEmptyArrayFunction · 0.85
ofMethod · 0.65
mapMethod · 0.65
registerMethod · 0.65
toStringMethod · 0.65
pipeMethod · 0.65
acquireMethod · 0.65
refreshMethod · 0.65

Tested by

no test coverage detected