Class SnowflakeProperties
java.lang.Object
com.fayupable.snowflake.jpaspring.SnowflakeProperties
Binds to the
snowflake prefix in application.yml / application.properties.
Example configuration:
snowflake:
node-id: 3
epoch: 2024-01-01T00:00:00Z
nodeId has no valid default on purpose: SnowflakeConfig
rejects a negative nodeId, so an application that forgets to set
snowflake.node-id fails fast at startup instead of silently colliding
with another node that happens to use the same default value.
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
SnowflakeProperties
public SnowflakeProperties()
-
-
Method Details
-
getNodeId
public long getNodeId()- Returns:
- the node identifier this application instance will embed in every
generated id; must be unique across all concurrently running
instances sharing the same
epoch, or -1 if unconfigured
-
setNodeId
public void setNodeId(long nodeId) - Parameters:
nodeId- the node identifier to embed in every id generated by this application instance; bound fromsnowflake.node-id
-
getEpoch
- Returns:
- the reference instant (millisecond zero) that generated timestamps are measured from; defaults to 2024-01-01T00:00:00Z if unconfigured
-
setEpoch
- Parameters:
epoch- the reference instant to measure generated timestamps from; bound fromsnowflake.epoch. Choosing a recent epoch maximizes how many years the 41-bit timestamp field can cover before it overflows.
-