Skip to content

Commit 426e5c2

Browse files
committed
docs: added more comments
1 parent e3ba6c2 commit 426e5c2

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

snowflake.go

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,12 +98,17 @@ func (id *ID) NextID() uint64 {
9898
return timestampSegment | discriminatorSegment | sequenceSegment
9999
}
100100

101+
// SID is the parsed representation of a snowflake ID.
101102
type SID struct {
102-
Timestamp int64
103-
Sequence uint64
103+
// Timestamp is the timestamp of the snowflake ID.
104+
Timestamp int64
105+
// Sequence is the sequence number of the snowflake ID.
106+
Sequence uint64
107+
// Discriminator is the discriminator value of the snowflake ID.
104108
Discriminator uint64
105109
}
106110

111+
// Parse parses an existing snowflake ID
107112
func Parse(sid uint64) SID {
108113
return SID{
109114
Timestamp: getTimestamp(sid),
@@ -169,13 +174,19 @@ func (id *ID2) NextID() uint64 {
169174
return timestampSegment | discriminator2Segment | discriminator1Segment | sequenceSegment
170175
}
171176

177+
// SID2 is the parsed representation of a snowflake ID with 2 discriminator fields.
172178
type SID2 struct {
179+
// Timestamp is the timestamp of the snowflake ID.
173180
Timestamp int64
181+
// Sequence is the sequence number of the snowflake ID.
174182
Sequence uint64
183+
// Discriminator1 is the first discriminator value of the snowflake ID.
175184
Discriminator1 uint64
185+
// Discriminator2 is the second discriminator value of the snowflake ID.
176186
Discriminator2 uint64
177187
}
178188

189+
// Parse2 parses an existing snowflake ID with 2 discriminator fields.
179190
func Parse2(sid uint64) SID2 {
180191
return SID2{
181192
Timestamp: getTimestamp(sid),

0 commit comments

Comments
 (0)