<?php
|
namespace JVBase\managers\queue;
|
if (!defined('ABSPATH')) {
|
exit;
|
}
|
|
final class TypeRegistry
|
{
|
private array $configs = [];
|
|
public function register(string $type, TypeConfig $config): void
|
{
|
$this->configs[$type] = $config;
|
}
|
|
public function has(string $type): bool
|
{
|
return isset($this->configs[$type]);
|
}
|
|
public function getExecutor(string $type): ?Executor
|
{
|
return $this->configs[$type]?->executor;
|
}
|
|
public function getMergeable(string $type): ?Mergeable
|
{
|
return $this->configs[$type]?->mergeable;
|
}
|
|
public function getConfig(string $type): ?TypeConfig
|
{
|
return $this->configs[$type] ?? null;
|
}
|
|
public function getChunkConfig(string $type): ?array
|
{
|
$config = $this->configs[$type] ?? null;
|
if (!$config || empty($config->chunkKey)) {
|
return null;
|
}
|
return [
|
'key' => $config->chunkKey,
|
'size' => $config->chunkSize,
|
];
|
}
|
|
public function getMaxRetries(string $type): int
|
{
|
return $this->configs[$type]?->maxRetries ?? 3;
|
}
|
}
|