summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRandomChars <random@chars.jp>2021-10-05 22:04:42 +0900
committerRandomChars <random@chars.jp>2021-10-05 22:04:42 +0900
commit5c0d5069c3e8f3ce2ca3c038bedff8121abce936 (patch)
tree3421f04bee13f5b875e61e9d760162d9e1bc55a8
parentb6f32b12516dc9623a721bd527e25ad7c7420f98 (diff)
export constants for snowflake node IDs, fix snowflake node creation error handling (not that it would be useful anyway)v1.3.9
-rw-r--r--store/store.go16
1 files changed, 12 insertions, 4 deletions
diff --git a/store/store.go b/store/store.go
index 3d3ab5f..bf359da 100644
--- a/store/store.go
+++ b/store/store.go
@@ -14,6 +14,11 @@ import (
const revision = 1
+const (
+ UserSnowflakeNodeID = 7
+ ImageSnowflakeNodeID = 9
+)
+
var (
imageNode *snowflake.Node
userNode *snowflake.Node
@@ -49,12 +54,15 @@ func init() {
// Set Epoch to beginning of time (01/01/1970)
snowflake.Epoch = 0
- // Create a single node
+ // Create snowflake nodes
var err error
- imageNode, err = snowflake.NewNode(9)
- userNode, err = snowflake.NewNode(7)
+ userNode, err = snowflake.NewNode(UserSnowflakeNodeID)
+ if err != nil {
+ log.Fatalf("Error creating user snowflake node, %s", err)
+ }
+ imageNode, err = snowflake.NewNode(ImageSnowflakeNodeID)
if err != nil {
- log.Fatalf("Error creating snowflake generation node, %s", err)
+ log.Fatalf("Error creating image snowflake node, %s", err)
}
}