Skip to content

Commit

Permalink
create snowflake
Browse files Browse the repository at this point in the history
  • Loading branch information
凉之 committed Feb 20, 2019
1 parent 63e35a6 commit cf47146
Show file tree
Hide file tree
Showing 3 changed files with 98 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* Copyright 2016-2018 shardingsphere.io.
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* </p>
*/
package io.shardingsphere.api.config.rule;

import io.shardingsphere.core.constant.KeyGeneratorEnum;
import lombok.Builder;
import lombok.Data;

/**
* @author:zhaodong.xzd
* @github https://github.com/Yaccc
*/
@Data
@Builder
public class KeyGeneratorConfiguration implements RuleConfiguration {
private KeyGeneratorEnum keyGeneratorType;


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* Copyright 2016-2018 shardingsphere.io.
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* </p>
*/
package io.shardingsphere.core.constant;

import lombok.RequiredArgsConstructor;

/**
* @author:zhaodong.xzd
* @github https://github.com/Yaccc
*/
@RequiredArgsConstructor
public enum KeyGeneratorEnum {
/**
* default snowflake
*/
DEFAULT("default"),
/**
* leaf snowflake with zookeeper
*/
LEAF_SNOWFLAKE("leaf_snowflake"),
/**
* leaf segement
*/
LEAF_SEGMENT("leaf_segment");

private final String typeName;

}
Original file line number Diff line number Diff line change
@@ -1,7 +1,30 @@
/*
* Copyright 2016-2018 shardingsphere.io.
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* </p>
*/
package io.shardingsphere.core.keygen.leaf;

import io.shardingsphere.core.keygen.KeyGenerator;

/**
* snowflake from leaf
*
* @url https://github.com/Meituan-Dianping/Leaf
* @author:zhaodong.xzd
*
*/
public class SnowFlakeKeyGenerator implements KeyGenerator {
@Override
public Number generateKey() {
Expand Down

0 comments on commit cf47146

Please sign in to comment.