Skip to content

Commit

Permalink
feat: add sequence resolver info to about command
Browse files Browse the repository at this point in the history
  • Loading branch information
calebdw committed Jul 19, 2024
1 parent 97c4b6d commit 60323ec
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion src/ServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,14 @@
use CalebDW\Laraflake\Mixins\RuleMixin;
use CalebDW\Laraflake\Mixins\StrMixin;
use Composer\InstalledVersions;
use Godruoyi\Snowflake\FileLockResolver;
use Godruoyi\Snowflake\LaravelSequenceResolver;
use Godruoyi\Snowflake\PredisSequenceResolver;
use Godruoyi\Snowflake\RandomSequenceResolver;
use Godruoyi\Snowflake\RedisSequenceResolver;
use Godruoyi\Snowflake\SequenceResolver;
use Godruoyi\Snowflake\Snowflake;
use Godruoyi\Snowflake\SwooleSequenceResolver;
use Illuminate\Contracts\Cache\Repository;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Foundation\Console\AboutCommand;
Expand All @@ -38,7 +42,8 @@ public function boot(): void
$this->registerMixins();

AboutCommand::add('Laraflake', fn () => [
'Version' => InstalledVersions::getPrettyVersion('calebdw/laraflake'),
'Sequence Resolver' => $this->getPrettyResolver(),
'Version' => InstalledVersions::getPrettyVersion('calebdw/laraflake'),
]);
}

Expand Down Expand Up @@ -78,4 +83,21 @@ protected function registerSequenceResolver(): void
return new LaravelSequenceResolver($repository);
});
}

/** @codeCoverageIgnore */
protected function getPrettyResolver(): string
{
/** @var SequenceResolver $resolver */
$resolver = $this->app->make(SequenceResolver::class);

return match ($resolver::class) {
LaravelSequenceResolver::class => 'Laravel Cache',
RandomSequenceResolver::class => 'Random (unsafe)',
SwooleSequenceResolver::class => 'Swoole',
RedisSequenceResolver::class => 'Redis',
FileLockResolver::class => 'File',
PredisSequenceResolver::class => 'Predis',
default => $resolver::class,
};
}
}

0 comments on commit 60323ec

Please sign in to comment.