feat: add option to enable worker tasks queue
[poolifier.git] / src / pools / abstract-pool.ts
CommitLineData
fc3e6586 1import crypto from 'node:crypto'
2740a743 2import type { MessageValue, PromiseResponseWrapper } from '../utility-types'
78099a15 3import { EMPTY_FUNCTION, median } from '../utils'
34a0cfab 4import { KillBehaviors, isKillBehavior } from '../worker/worker-options'
aee46736 5import { PoolEvents, type PoolOptions } from './pool'
b4904890 6import { PoolEmitter } from './pool'
f06e48d8 7import type { IPoolInternal } from './pool-internal'
b4904890 8import { PoolType } from './pool-internal'
f06e48d8 9import type { IWorker, Task, TasksUsage, WorkerNode } from './worker'
a35560ba
S
10import {
11 WorkerChoiceStrategies,
63220255 12 type WorkerChoiceStrategy
bdaf31cd
JB
13} from './selection-strategies/selection-strategies-types'
14import { WorkerChoiceStrategyContext } from './selection-strategies/worker-choice-strategy-context'
78099a15 15import { CircularArray } from '../circular-array'
c97c7edb 16
729c563d 17/**
ea7a90d3 18 * Base class that implements some shared logic for all poolifier pools.
729c563d 19 *
38e795c1
JB
20 * @typeParam Worker - Type of worker which manages this pool.
21 * @typeParam Data - Type of data sent to the worker. This can only be serializable data.
22 * @typeParam Response - Type of response of execution. This can only be serializable data.
729c563d 23 */
c97c7edb 24export abstract class AbstractPool<
f06e48d8 25 Worker extends IWorker,
d3c8a1a8
S
26 Data = unknown,
27 Response = unknown
9b2fdd9f 28> implements IPoolInternal<Worker, Data, Response> {
afc003b2 29 /** @inheritDoc */
f06e48d8 30 public readonly workerNodes: Array<WorkerNode<Worker, Data>> = []
4a6952ff 31
afc003b2 32 /** @inheritDoc */
7c0ba920
JB
33 public readonly emitter?: PoolEmitter
34
be0676b3 35 /**
2740a743 36 * The promise response map.
be0676b3 37 *
2740a743 38 * - `key`: The message id of each submitted task.
c923ce56 39 * - `value`: An object that contains the worker, the promise resolve and reject callbacks.
be0676b3 40 *
2740a743 41 * When we receive a message from the worker we get a map entry with the promise resolve/reject bound to the message.
be0676b3 42 */
c923ce56
JB
43 protected promiseResponseMap: Map<
44 string,
45 PromiseResponseWrapper<Worker, Response>
46 > = new Map<string, PromiseResponseWrapper<Worker, Response>>()
c97c7edb 47
a35560ba 48 /**
51fe3d3c 49 * Worker choice strategy context referencing a worker choice algorithm implementation.
a35560ba 50 *
51fe3d3c 51 * Default to a round robin algorithm.
a35560ba
S
52 */
53 protected workerChoiceStrategyContext: WorkerChoiceStrategyContext<
78cea37e
JB
54 Worker,
55 Data,
56 Response
a35560ba
S
57 >
58
729c563d
S
59 /**
60 * Constructs a new poolifier pool.
61 *
38e795c1
JB
62 * @param numberOfWorkers - Number of workers that this pool should manage.
63 * @param filePath - Path to the worker-file.
64 * @param opts - Options for the pool.
729c563d 65 */
c97c7edb 66 public constructor (
5c5a1fb7 67 public readonly numberOfWorkers: number,
c97c7edb 68 public readonly filePath: string,
1927ee67 69 public readonly opts: PoolOptions<Worker>
c97c7edb 70 ) {
78cea37e 71 if (!this.isMain()) {
c97c7edb
S
72 throw new Error('Cannot start a pool from a worker!')
73 }
8d3782fa 74 this.checkNumberOfWorkers(this.numberOfWorkers)
c510fea7 75 this.checkFilePath(this.filePath)
7c0ba920 76 this.checkPoolOptions(this.opts)
1086026a 77
adc3c320 78 this.chooseWorkerNode.bind(this)
1086026a 79 this.internalExecute.bind(this)
ff733df7 80 this.checkAndEmitEvents.bind(this)
1086026a
JB
81 this.sendToWorker.bind(this)
82
c97c7edb
S
83 this.setupHook()
84
5c5a1fb7 85 for (let i = 1; i <= this.numberOfWorkers; i++) {
280c2a77 86 this.createAndSetupWorker()
c97c7edb
S
87 }
88
6bd72cd0 89 if (this.opts.enableEvents === true) {
7c0ba920
JB
90 this.emitter = new PoolEmitter()
91 }
d59df138
JB
92 this.workerChoiceStrategyContext = new WorkerChoiceStrategyContext<
93 Worker,
94 Data,
95 Response
17393ac8 96 >(this, this.opts.workerChoiceStrategy)
c97c7edb
S
97 }
98
a35560ba 99 private checkFilePath (filePath: string): void {
ffcbbad8
JB
100 if (
101 filePath == null ||
102 (typeof filePath === 'string' && filePath.trim().length === 0)
103 ) {
c510fea7
APA
104 throw new Error('Please specify a file with a worker implementation')
105 }
106 }
107
8d3782fa
JB
108 private checkNumberOfWorkers (numberOfWorkers: number): void {
109 if (numberOfWorkers == null) {
110 throw new Error(
111 'Cannot instantiate a pool without specifying the number of workers'
112 )
78cea37e 113 } else if (!Number.isSafeInteger(numberOfWorkers)) {
473c717a 114 throw new TypeError(
8d3782fa
JB
115 'Cannot instantiate a pool with a non integer number of workers'
116 )
117 } else if (numberOfWorkers < 0) {
473c717a 118 throw new RangeError(
8d3782fa
JB
119 'Cannot instantiate a pool with a negative number of workers'
120 )
7c0ba920 121 } else if (this.type === PoolType.FIXED && numberOfWorkers === 0) {
8d3782fa
JB
122 throw new Error('Cannot instantiate a fixed pool with no worker')
123 }
124 }
125
7c0ba920 126 private checkPoolOptions (opts: PoolOptions<Worker>): void {
e843b904
JB
127 this.opts.workerChoiceStrategy =
128 opts.workerChoiceStrategy ?? WorkerChoiceStrategies.ROUND_ROBIN
aee46736
JB
129 this.checkValidWorkerChoiceStrategy(this.opts.workerChoiceStrategy)
130 this.opts.enableEvents = opts.enableEvents ?? true
ff733df7 131 this.opts.enableTasksQueue = opts.enableTasksQueue ?? false
aee46736
JB
132 }
133
134 private checkValidWorkerChoiceStrategy (
135 workerChoiceStrategy: WorkerChoiceStrategy
136 ): void {
137 if (!Object.values(WorkerChoiceStrategies).includes(workerChoiceStrategy)) {
b529c323 138 throw new Error(
aee46736 139 `Invalid worker choice strategy '${workerChoiceStrategy}'`
b529c323
JB
140 )
141 }
7c0ba920
JB
142 }
143
afc003b2 144 /** @inheritDoc */
7c0ba920
JB
145 public abstract get type (): PoolType
146
c2ade475 147 /**
ff733df7 148 * Number of tasks running in the pool.
c2ade475
JB
149 */
150 private get numberOfRunningTasks (): number {
ff733df7
JB
151 return this.workerNodes.reduce(
152 (accumulator, workerNode) => accumulator + workerNode.tasksUsage.running,
153 0
154 )
155 }
156
157 /**
158 * Number of tasks queued in the pool.
159 */
160 private get numberOfQueuedTasks (): number {
161 if (this.opts.enableTasksQueue === false) {
162 return 0
163 }
164 return this.workerNodes.reduce(
165 (accumulator, workerNode) => accumulator + workerNode.tasksQueue.length,
166 0
167 )
a35560ba
S
168 }
169
ffcbbad8 170 /**
f06e48d8 171 * Gets the given worker its worker node key.
ffcbbad8
JB
172 *
173 * @param worker - The worker.
f06e48d8 174 * @returns The worker node key if the worker is found in the pool worker nodes, `-1` otherwise.
ffcbbad8 175 */
f06e48d8
JB
176 private getWorkerNodeKey (worker: Worker): number {
177 return this.workerNodes.findIndex(
178 workerNode => workerNode.worker === worker
179 )
bf9549ae
JB
180 }
181
afc003b2 182 /** @inheritDoc */
a35560ba
S
183 public setWorkerChoiceStrategy (
184 workerChoiceStrategy: WorkerChoiceStrategy
185 ): void {
aee46736 186 this.checkValidWorkerChoiceStrategy(workerChoiceStrategy)
b98ec2e6 187 this.opts.workerChoiceStrategy = workerChoiceStrategy
f06e48d8
JB
188 for (const [index, workerNode] of this.workerNodes.entries()) {
189 this.setWorkerNode(
190 index,
191 workerNode.worker,
192 {
193 run: 0,
194 running: 0,
195 runTime: 0,
196 runTimeHistory: new CircularArray(),
197 avgRunTime: 0,
198 medRunTime: 0,
199 error: 0
200 },
201 workerNode.tasksQueue
202 )
ea7a90d3 203 }
a35560ba
S
204 this.workerChoiceStrategyContext.setWorkerChoiceStrategy(
205 workerChoiceStrategy
206 )
207 }
208
afc003b2 209 /** @inheritDoc */
c2ade475
JB
210 public abstract get full (): boolean
211
afc003b2 212 /** @inheritDoc */
7c0ba920
JB
213 public abstract get busy (): boolean
214
c2ade475 215 protected internalBusy (): boolean {
7c0ba920
JB
216 return (
217 this.numberOfRunningTasks >= this.numberOfWorkers &&
f06e48d8 218 this.findFreeWorkerNodeKey() === -1
7c0ba920
JB
219 )
220 }
221
afc003b2 222 /** @inheritDoc */
f06e48d8
JB
223 public findFreeWorkerNodeKey (): number {
224 return this.workerNodes.findIndex(workerNode => {
225 return workerNode.tasksUsage?.running === 0
c923ce56 226 })
7c0ba920
JB
227 }
228
afc003b2 229 /** @inheritDoc */
78cea37e 230 public async execute (data: Data): Promise<Response> {
adc3c320
JB
231 const [workerNodeKey, workerNode] = this.chooseWorkerNode()
232 const submittedTask: Task<Data> = {
e5a5c0fc
JB
233 // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
234 data: data ?? ({} as Data),
adc3c320
JB
235 id: crypto.randomUUID()
236 }
237 const res = this.internalExecute(workerNodeKey, workerNode, submittedTask)
ff733df7
JB
238 let currentTask: Task<Data> = submittedTask
239 if (
240 this.opts.enableTasksQueue === true &&
241 (this.busy || this.tasksQueueLength(workerNodeKey) > 0)
242 ) {
adc3c320 243 this.enqueueTask(workerNodeKey, submittedTask)
ff733df7 244 currentTask = this.dequeueTask(workerNodeKey) as Task<Data>
adc3c320
JB
245 }
246 this.sendToWorker(workerNode.worker, currentTask)
ff733df7 247 this.checkAndEmitEvents()
78cea37e 248 // eslint-disable-next-line @typescript-eslint/return-await
280c2a77
S
249 return res
250 }
c97c7edb 251
afc003b2 252 /** @inheritDoc */
c97c7edb 253 public async destroy (): Promise<void> {
1fbcaa7c 254 await Promise.all(
f06e48d8 255 this.workerNodes.map(async workerNode => {
ff733df7 256 this.flushTasksQueueByWorker(workerNode.worker)
f06e48d8 257 await this.destroyWorker(workerNode.worker)
1fbcaa7c
JB
258 })
259 )
c97c7edb
S
260 }
261
4a6952ff 262 /**
f06e48d8 263 * Shutdowns the given worker.
4a6952ff 264 *
f06e48d8 265 * @param worker - A worker within `workerNodes`.
4a6952ff
JB
266 */
267 protected abstract destroyWorker (worker: Worker): void | Promise<void>
c97c7edb 268
729c563d 269 /**
f06e48d8 270 * Setup hook to run code before worker node are created in the abstract constructor.
d99ba5a8 271 * Can be overridden
afc003b2
JB
272 *
273 * @virtual
729c563d 274 */
280c2a77 275 protected setupHook (): void {
d99ba5a8 276 // Intentionally empty
280c2a77 277 }
c97c7edb 278
729c563d 279 /**
280c2a77
S
280 * Should return whether the worker is the main worker or not.
281 */
282 protected abstract isMain (): boolean
283
284 /**
bf9549ae
JB
285 * Hook executed before the worker task promise resolution.
286 * Can be overridden.
729c563d 287 *
f06e48d8 288 * @param workerNodeKey - The worker node key.
729c563d 289 */
f06e48d8
JB
290 protected beforePromiseResponseHook (workerNodeKey: number): void {
291 ++this.workerNodes[workerNodeKey].tasksUsage.running
c97c7edb
S
292 }
293
c01733f1 294 /**
bf9549ae
JB
295 * Hook executed after the worker task promise resolution.
296 * Can be overridden.
c01733f1 297 *
c923ce56 298 * @param worker - The worker.
38e795c1 299 * @param message - The received message.
c01733f1 300 */
2740a743 301 protected afterPromiseResponseHook (
c923ce56 302 worker: Worker,
2740a743 303 message: MessageValue<Response>
bf9549ae 304 ): void {
c923ce56 305 const workerTasksUsage = this.getWorkerTasksUsage(worker) as TasksUsage
3032893a
JB
306 --workerTasksUsage.running
307 ++workerTasksUsage.run
2740a743
JB
308 if (message.error != null) {
309 ++workerTasksUsage.error
310 }
97a2abc3 311 if (this.workerChoiceStrategyContext.getRequiredStatistics().runTime) {
aee46736 312 workerTasksUsage.runTime += message.runTime ?? 0
c6bd2650
JB
313 if (
314 this.workerChoiceStrategyContext.getRequiredStatistics().avgRunTime &&
315 workerTasksUsage.run !== 0
316 ) {
3032893a
JB
317 workerTasksUsage.avgRunTime =
318 workerTasksUsage.runTime / workerTasksUsage.run
319 }
78099a15
JB
320 if (this.workerChoiceStrategyContext.getRequiredStatistics().medRunTime) {
321 workerTasksUsage.runTimeHistory.push(message.runTime ?? 0)
322 workerTasksUsage.medRunTime = median(workerTasksUsage.runTimeHistory)
323 }
3032893a 324 }
c01733f1 325 }
326
280c2a77 327 /**
f06e48d8 328 * Chooses a worker node for the next task.
280c2a77 329 *
51fe3d3c 330 * The default uses a round robin algorithm to distribute the load.
280c2a77 331 *
adc3c320 332 * @returns [worker node key, worker node].
280c2a77 333 */
adc3c320 334 protected chooseWorkerNode (): [number, WorkerNode<Worker, Data>] {
f06e48d8 335 let workerNodeKey: number
17393ac8
JB
336 if (
337 this.type === PoolType.DYNAMIC &&
338 !this.full &&
f06e48d8 339 this.findFreeWorkerNodeKey() === -1
17393ac8 340 ) {
adc3c320
JB
341 const workerCreated = this.createAndSetupWorker()
342 this.registerWorkerMessageListener(workerCreated, message => {
17393ac8
JB
343 if (
344 isKillBehavior(KillBehaviors.HARD, message.kill) ||
d2097c13 345 (message.kill != null &&
adc3c320 346 this.getWorkerTasksUsage(workerCreated)?.running === 0)
17393ac8 347 ) {
ff733df7
JB
348 // Kill message received from the worker: no new tasks are submitted to that worker for a while ( > maxInactiveTime)
349 this.flushTasksQueueByWorker(workerCreated)
adc3c320 350 void this.destroyWorker(workerCreated)
17393ac8
JB
351 }
352 })
adc3c320 353 workerNodeKey = this.getWorkerNodeKey(workerCreated)
17393ac8 354 } else {
f06e48d8 355 workerNodeKey = this.workerChoiceStrategyContext.execute()
17393ac8 356 }
adc3c320 357 return [workerNodeKey, this.workerNodes[workerNodeKey]]
c97c7edb
S
358 }
359
280c2a77 360 /**
675bb809 361 * Sends a message to the given worker.
280c2a77 362 *
38e795c1
JB
363 * @param worker - The worker which should receive the message.
364 * @param message - The message.
280c2a77
S
365 */
366 protected abstract sendToWorker (
367 worker: Worker,
368 message: MessageValue<Data>
369 ): void
370
4a6952ff 371 /**
f06e48d8 372 * Registers a listener callback on the given worker.
4a6952ff 373 *
38e795c1
JB
374 * @param worker - The worker which should register a listener.
375 * @param listener - The message listener callback.
4a6952ff
JB
376 */
377 protected abstract registerWorkerMessageListener<
4f7fa42a 378 Message extends Data | Response
78cea37e 379 >(worker: Worker, listener: (message: MessageValue<Message>) => void): void
c97c7edb 380
729c563d
S
381 /**
382 * Returns a newly created worker.
383 */
280c2a77 384 protected abstract createWorker (): Worker
c97c7edb 385
729c563d 386 /**
f06e48d8 387 * Function that can be hooked up when a worker has been newly created and moved to the pool worker nodes.
729c563d 388 *
38e795c1 389 * Can be used to update the `maxListeners` or binding the `main-worker`\<-\>`worker` connection if not bind by default.
729c563d 390 *
38e795c1 391 * @param worker - The newly created worker.
729c563d 392 */
280c2a77 393 protected abstract afterWorkerSetup (worker: Worker): void
c97c7edb 394
4a6952ff 395 /**
f06e48d8 396 * Creates a new worker and sets it up completely in the pool worker nodes.
4a6952ff
JB
397 *
398 * @returns New, completely set up worker.
399 */
400 protected createAndSetupWorker (): Worker {
bdacc2d2 401 const worker = this.createWorker()
280c2a77 402
35cf1c03 403 worker.on('message', this.opts.messageHandler ?? EMPTY_FUNCTION)
a35560ba
S
404 worker.on('error', this.opts.errorHandler ?? EMPTY_FUNCTION)
405 worker.on('online', this.opts.onlineHandler ?? EMPTY_FUNCTION)
406 worker.on('exit', this.opts.exitHandler ?? EMPTY_FUNCTION)
a974afa6 407 worker.once('exit', () => {
f06e48d8 408 this.removeWorkerNode(worker)
a974afa6 409 })
280c2a77 410
f06e48d8 411 this.pushWorkerNode(worker)
280c2a77
S
412
413 this.afterWorkerSetup(worker)
414
c97c7edb
S
415 return worker
416 }
be0676b3
APA
417
418 /**
ff733df7 419 * This function is the listener registered for each worker message.
be0676b3 420 *
bdacc2d2 421 * @returns The listener function to execute when a message is received from a worker.
be0676b3
APA
422 */
423 protected workerListener (): (message: MessageValue<Response>) => void {
4a6952ff 424 return message => {
b1989cfd 425 if (message.id != null) {
aee46736 426 // Task response received
2740a743 427 const promiseResponse = this.promiseResponseMap.get(message.id)
b1989cfd 428 if (promiseResponse != null) {
78cea37e 429 if (message.error != null) {
2740a743 430 promiseResponse.reject(message.error)
a05c10de 431 } else {
2740a743 432 promiseResponse.resolve(message.data as Response)
a05c10de 433 }
c923ce56 434 this.afterPromiseResponseHook(promiseResponse.worker, message)
2740a743 435 this.promiseResponseMap.delete(message.id)
ff733df7
JB
436 const workerNodeKey = this.getWorkerNodeKey(promiseResponse.worker)
437 if (
438 this.opts.enableTasksQueue === true &&
439 this.tasksQueueLength(workerNodeKey) > 0
440 ) {
441 this.sendToWorker(
442 promiseResponse.worker,
443 this.dequeueTask(workerNodeKey) as Task<Data>
444 )
445 }
be0676b3
APA
446 }
447 }
448 }
be0676b3 449 }
7c0ba920 450
78cea37e 451 private async internalExecute (
f06e48d8 452 workerNodeKey: number,
adc3c320
JB
453 workerNode: WorkerNode<Worker, Data>,
454 task: Task<Data>
78cea37e 455 ): Promise<Response> {
f06e48d8 456 this.beforePromiseResponseHook(workerNodeKey)
78cea37e 457 return await new Promise<Response>((resolve, reject) => {
adc3c320
JB
458 this.promiseResponseMap.set(task.id, {
459 resolve,
460 reject,
461 worker: workerNode.worker
462 })
78cea37e
JB
463 })
464 }
465
ff733df7
JB
466 private checkAndEmitEvents (): void {
467 if (this.opts.enableEvents === true) {
468 if (this.busy) {
469 this.emitter?.emit(PoolEvents.busy)
470 }
471 if (this.type === PoolType.DYNAMIC && this.full) {
472 this.emitter?.emit(PoolEvents.full)
473 }
164d950a
JB
474 }
475 }
476
c923ce56 477 /**
f06e48d8 478 * Gets the given worker its tasks usage in the pool.
c923ce56
JB
479 *
480 * @param worker - The worker.
481 * @returns The worker tasks usage.
482 */
483 private getWorkerTasksUsage (worker: Worker): TasksUsage | undefined {
f06e48d8
JB
484 const workerNodeKey = this.getWorkerNodeKey(worker)
485 if (workerNodeKey !== -1) {
486 return this.workerNodes[workerNodeKey].tasksUsage
ffcbbad8 487 }
f06e48d8 488 throw new Error('Worker could not be found in the pool worker nodes')
a05c10de
JB
489 }
490
491 /**
f06e48d8 492 * Pushes the given worker in the pool worker nodes.
ea7a90d3 493 *
38e795c1 494 * @param worker - The worker.
f06e48d8 495 * @returns The worker nodes length.
ea7a90d3 496 */
f06e48d8
JB
497 private pushWorkerNode (worker: Worker): number {
498 return this.workerNodes.push({
ffcbbad8 499 worker,
f06e48d8
JB
500 tasksUsage: {
501 run: 0,
502 running: 0,
503 runTime: 0,
504 runTimeHistory: new CircularArray(),
505 avgRunTime: 0,
506 medRunTime: 0,
507 error: 0
508 },
509 tasksQueue: []
ea7a90d3
JB
510 })
511 }
c923ce56
JB
512
513 /**
f06e48d8 514 * Sets the given worker in the pool worker nodes.
c923ce56 515 *
f06e48d8 516 * @param workerNodeKey - The worker node key.
c923ce56
JB
517 * @param worker - The worker.
518 * @param tasksUsage - The worker tasks usage.
f06e48d8 519 * @param tasksQueue - The worker task queue.
c923ce56 520 */
f06e48d8
JB
521 private setWorkerNode (
522 workerNodeKey: number,
c923ce56 523 worker: Worker,
f06e48d8
JB
524 tasksUsage: TasksUsage,
525 tasksQueue: Array<Task<Data>>
c923ce56 526 ): void {
f06e48d8 527 this.workerNodes[workerNodeKey] = {
c923ce56 528 worker,
f06e48d8
JB
529 tasksUsage,
530 tasksQueue
c923ce56
JB
531 }
532 }
51fe3d3c
JB
533
534 /**
f06e48d8 535 * Removes the given worker from the pool worker nodes.
51fe3d3c 536 *
f06e48d8 537 * @param worker - The worker.
51fe3d3c 538 */
f06e48d8
JB
539 protected removeWorkerNode (worker: Worker): void {
540 const workerNodeKey = this.getWorkerNodeKey(worker)
541 this.workerNodes.splice(workerNodeKey, 1)
542 this.workerChoiceStrategyContext.remove(workerNodeKey)
51fe3d3c 543 }
adc3c320
JB
544
545 protected enqueueTask (workerNodeKey: number, task: Task<Data>): void {
546 this.workerNodes[workerNodeKey].tasksQueue.push(task)
547 }
548
549 protected dequeueTask (workerNodeKey: number): Task<Data> | undefined {
550 return this.workerNodes[workerNodeKey].tasksQueue.shift()
551 }
552
553 protected tasksQueueLength (workerNodeKey: number): number {
554 return this.workerNodes[workerNodeKey].tasksQueue.length
555 }
ff733df7
JB
556
557 protected flushTasksQueue (workerNodeKey: number): void {
558 if (this.tasksQueueLength(workerNodeKey) > 0) {
559 for (const task of this.workerNodes[workerNodeKey].tasksQueue) {
560 this.sendToWorker(this.workerNodes[workerNodeKey].worker, task)
561 }
562 this.workerNodes[workerNodeKey].tasksQueue = []
563 }
564 }
565
566 protected flushTasksQueueByWorker (worker: Worker): void {
567 const workerNodeKey = this.getWorkerNodeKey(worker)
568 this.flushTasksQueue(workerNodeKey)
569 }
c97c7edb 570}