You've already forked Traefik-Redis-Api
Is there an award for this?
This commit is contained in:
@@ -20,7 +20,7 @@ class RedisClient
|
||||
* @param ProtocolEnum $type
|
||||
* @return void
|
||||
*/
|
||||
public static function createOrReplace(
|
||||
public function createOrReplace(
|
||||
string $name,
|
||||
array $data,
|
||||
EntityEnum $entity,
|
||||
@@ -47,7 +47,7 @@ class RedisClient
|
||||
* @param ProtocolEnum $protocol
|
||||
* @return bool
|
||||
*/
|
||||
public static function deleteAllKeys(
|
||||
public function deleteAllKeys(
|
||||
string $name,
|
||||
EntityEnum $entity,
|
||||
ProtocolEnum $protocol = ProtocolEnum::HTTP
|
||||
@@ -66,33 +66,33 @@ class RedisClient
|
||||
* @param ProtocolEnum $type
|
||||
* @return array
|
||||
*/
|
||||
public static function getMiddleware(string $name, ProtocolEnum $type = ProtocolEnum::HTTP): array
|
||||
public function getMiddleware(string $name, ProtocolEnum $type = ProtocolEnum::HTTP): array
|
||||
{
|
||||
$pattern = 'traefik/' . $type->getValue() . '/' . EntityEnum::MIDDLEWARE->getValue() . "/$name/*";
|
||||
|
||||
return self::fetchValuesToArray($pattern);
|
||||
return $this->fetchValuesToArray($pattern);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ProtocolEnum $type
|
||||
* @return array
|
||||
*/
|
||||
public static function getAllMiddlewares(ProtocolEnum $type = ProtocolEnum::HTTP): array
|
||||
public function getAllMiddlewares(ProtocolEnum $type = ProtocolEnum::HTTP): array
|
||||
{
|
||||
$pattern = 'traefik/' . $type->getValue() . '/' . EntityEnum::MIDDLEWARE->getValue() . '/*';
|
||||
|
||||
return self::getUniqueKeys($pattern, 3);
|
||||
return $this->getUniqueKeys($pattern);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ProtocolEnum $type
|
||||
* @return array
|
||||
*/
|
||||
public static function getAllServices(ProtocolEnum $type = ProtocolEnum::HTTP): array
|
||||
public function getAllServices(ProtocolEnum $type = ProtocolEnum::HTTP): array
|
||||
{
|
||||
$pattern = 'traefik/' . $type->getValue() . '/' . EntityEnum::SERVICE->getValue() . '/*';
|
||||
|
||||
return self::getUniqueKeys($pattern, 3);
|
||||
return $this->getUniqueKeys($pattern);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -100,22 +100,22 @@ class RedisClient
|
||||
* @param ProtocolEnum $type
|
||||
* @return array
|
||||
*/
|
||||
public static function getService(string $serviceName, ProtocolEnum $type = ProtocolEnum::HTTP): array
|
||||
public function getService(string $serviceName, ProtocolEnum $type = ProtocolEnum::HTTP): array
|
||||
{
|
||||
$pattern = 'traefik/' . $type->getValue() . '/' . EntityEnum::SERVICE->getValue() . "/$serviceName/*";
|
||||
|
||||
return self::fetchValuesToArray($pattern);
|
||||
return $this->fetchValuesToArray($pattern);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ProtocolEnum $type
|
||||
* @return array
|
||||
*/
|
||||
public static function getAllRouters(ProtocolEnum $type = ProtocolEnum::HTTP): array
|
||||
public function getAllRouters(ProtocolEnum $type = ProtocolEnum::HTTP): array
|
||||
{
|
||||
$pattern = 'traefik/' . $type->getValue() . '/' . EntityEnum::ROUTER->getValue() . '/*';
|
||||
|
||||
return self::getUniqueKeys($pattern, 3);
|
||||
return $this->getUniqueKeys($pattern);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -123,27 +123,26 @@ class RedisClient
|
||||
* @param ProtocolEnum $type
|
||||
* @return array
|
||||
*/
|
||||
public static function getRouter(string $name, ProtocolEnum $type = ProtocolEnum::HTTP): array
|
||||
public function getRouter(string $name, ProtocolEnum $type = ProtocolEnum::HTTP): array
|
||||
{
|
||||
$pattern = 'traefik/' . $type->getValue() . '/' . EntityEnum::ROUTER->getValue() . "/$name/*";
|
||||
|
||||
return self::fetchValuesToArray($pattern);
|
||||
return $this->fetchValuesToArray($pattern);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $pattern
|
||||
* @param int $position
|
||||
* @return array
|
||||
*/
|
||||
private static function getUniqueKeys(string $pattern, int $position): array
|
||||
private function getUniqueKeys(string $pattern): array
|
||||
{
|
||||
$values = new Collection();
|
||||
$redis = Redis::getFacadeRoot();
|
||||
|
||||
foreach (new Keyspace($redis, $pattern) as $key) {
|
||||
$parts = explode('/', $key);
|
||||
if (isset($parts[$position])) {
|
||||
$values->push($parts[$position]);
|
||||
if (isset($parts[3])) {
|
||||
$values->push($parts[3]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -154,7 +153,7 @@ class RedisClient
|
||||
* @param string $pattern
|
||||
* @return array
|
||||
*/
|
||||
private static function fetchValuesToArray(string $pattern): array
|
||||
private function fetchValuesToArray(string $pattern): array
|
||||
{
|
||||
$redis = Redis::getFacadeRoot();
|
||||
|
||||
@@ -174,7 +173,7 @@ class RedisClient
|
||||
* @param array $data
|
||||
* @return array
|
||||
*/
|
||||
public static function flattenToDotArray(array $data): array
|
||||
public function flattenToDotArray(array $data): array
|
||||
{
|
||||
$collection = new Collection($data);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user