mirror of
https://gitee.com/hyperf/hyperf.git
synced 2024-12-02 11:48:08 +08:00
Moved ConfigInterface to the last.
This commit is contained in:
parent
e7c1d05b59
commit
21170d123d
@ -14,7 +14,6 @@ namespace Hyperf\Snowflake;
|
||||
|
||||
class Meta
|
||||
{
|
||||
|
||||
/**
|
||||
* @var int [0, 31]
|
||||
*/
|
||||
|
@ -25,7 +25,7 @@ class RedisMilliSecondMetaGenerator extends MetaGenerator
|
||||
|
||||
protected $dataCenterId;
|
||||
|
||||
public function __construct(ConfigInterface $config, ConfigurationInterface $configuration, int $beginTimestamp = self::DEFAULT_BEGIN_SECOND)
|
||||
public function __construct(ConfigurationInterface $configuration, int $beginTimestamp = self::DEFAULT_BEGIN_SECOND, ConfigInterface $config)
|
||||
{
|
||||
parent::__construct($configuration, $beginTimestamp * 1000);
|
||||
|
||||
|
@ -25,7 +25,7 @@ class RedisSecondMetaGenerator extends MetaGenerator
|
||||
|
||||
protected $dataCenterId;
|
||||
|
||||
public function __construct(ConfigInterface $config, ConfigurationInterface $configuration, int $beginTimestamp = self::DEFAULT_BEGIN_SECOND)
|
||||
public function __construct(ConfigurationInterface $configuration, int $beginTimestamp = self::DEFAULT_BEGIN_SECOND, ConfigInterface $config)
|
||||
{
|
||||
parent::__construct($configuration, $beginTimestamp);
|
||||
|
||||
|
@ -48,7 +48,7 @@ class RedisMetaGeneratorTest extends TestCase
|
||||
{
|
||||
$container = $this->getContainer();
|
||||
$config = $container->get(ConfigInterface::class);
|
||||
$metaGenerator = new RedisMilliSecondMetaGenerator($config, new SnowflakeConfig());
|
||||
$metaGenerator = new RedisMilliSecondMetaGenerator(new SnowflakeConfig(), MetaGeneratorInterface::DEFAULT_BEGIN_SECOND, $config);
|
||||
|
||||
$meta = $metaGenerator->generate();
|
||||
$this->assertInstanceOf(Meta::class, $meta);
|
||||
@ -61,7 +61,7 @@ class RedisMetaGeneratorTest extends TestCase
|
||||
$container = $this->getContainer();
|
||||
$hConfig = $container->get(ConfigInterface::class);
|
||||
$config = new SnowflakeConfig();
|
||||
$metaGenerator = new RedisMilliSecondMetaGenerator($hConfig, $config);
|
||||
$metaGenerator = new RedisMilliSecondMetaGenerator($config, MetaGeneratorInterface::DEFAULT_BEGIN_SECOND, $hConfig);
|
||||
$generator = new SnowflakeIdGenerator($metaGenerator);
|
||||
|
||||
$id = $generator->generate();
|
||||
@ -78,7 +78,7 @@ class RedisMetaGeneratorTest extends TestCase
|
||||
$container = $this->getContainer();
|
||||
$hConfig = $container->get(ConfigInterface::class);
|
||||
$config = new SnowflakeConfig();
|
||||
$metaGenerator = new RedisSecondMetaGenerator($hConfig, $config);
|
||||
$metaGenerator = new RedisSecondMetaGenerator($config, MetaGeneratorInterface::DEFAULT_BEGIN_SECOND, $hConfig);
|
||||
$meta = $metaGenerator->generate();
|
||||
$this->assertInstanceOf(Meta::class, $meta);
|
||||
$this->assertSame(0, $meta->getDataCenterId());
|
||||
@ -90,7 +90,7 @@ class RedisMetaGeneratorTest extends TestCase
|
||||
$container = $this->getContainer();
|
||||
$hConfig = $container->get(ConfigInterface::class);
|
||||
$config = new SnowflakeConfig();
|
||||
$metaGenerator = new RedisSecondMetaGenerator($hConfig, $config);
|
||||
$metaGenerator = new RedisSecondMetaGenerator($config, MetaGeneratorInterface::DEFAULT_BEGIN_SECOND, $hConfig);
|
||||
$generator = new SnowflakeIdGenerator($metaGenerator);
|
||||
|
||||
$id = $generator->generate();
|
||||
@ -107,7 +107,7 @@ class RedisMetaGeneratorTest extends TestCase
|
||||
$container = $this->getContainer();
|
||||
$hConfig = $container->get(ConfigInterface::class);
|
||||
$config = new SnowflakeConfig();
|
||||
$metaGenerator = new RedisSecondMetaGenerator($hConfig, $config);
|
||||
$metaGenerator = new RedisSecondMetaGenerator($config, MetaGeneratorInterface::DEFAULT_BEGIN_SECOND, $hConfig);
|
||||
$generator = new SnowflakeIdGenerator($metaGenerator);
|
||||
|
||||
$meta = $generator->degenerate(PHP_INT_MAX);
|
||||
@ -124,7 +124,7 @@ class RedisMetaGeneratorTest extends TestCase
|
||||
$container = $this->getContainer();
|
||||
$hConfig = $container->get(ConfigInterface::class);
|
||||
$config = new SnowflakeConfig();
|
||||
$metaGenerator = new RedisSecondMetaGenerator($hConfig, $config);
|
||||
$metaGenerator = new RedisSecondMetaGenerator($config, MetaGeneratorInterface::DEFAULT_BEGIN_SECOND, $hConfig);
|
||||
$generator = new SnowflakeIdGenerator($metaGenerator);
|
||||
$generator = new UserDefinedIdGenerator($generator);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user