summaryrefslogtreecommitdiff
path: root/srv/src/chat/util.go
diff options
context:
space:
mode:
authorBrian Picciano <mediocregopher@gmail.com>2022-05-05 21:20:22 -0600
committerBrian Picciano <mediocregopher@gmail.com>2022-05-05 21:20:22 -0600
commiteed10ce514f28e4acf772f76c92ca05eebec105f (patch)
treed76820d7a3cd23f09f7dd0e6065bb0cef7ba16dc /srv/src/chat/util.go
parentcc8b6289ac3f7d1abb648217949beb89827d7374 (diff)
Fix various problems with the srv build
Diffstat (limited to 'srv/src/chat/util.go')
-rw-r--r--srv/src/chat/util.go28
1 files changed, 28 insertions, 0 deletions
diff --git a/srv/src/chat/util.go b/srv/src/chat/util.go
new file mode 100644
index 0000000..05f4830
--- /dev/null
+++ b/srv/src/chat/util.go
@@ -0,0 +1,28 @@
+package chat
+
+import (
+ "strconv"
+ "strings"
+
+ "github.com/mediocregopher/radix/v4"
+)
+
+func parseStreamEntryID(str string) (radix.StreamEntryID, error) {
+
+ split := strings.SplitN(str, "-", 2)
+ if len(split) != 2 {
+ return radix.StreamEntryID{}, errInvalidMessageID
+ }
+
+ time, err := strconv.ParseUint(split[0], 10, 64)
+ if err != nil {
+ return radix.StreamEntryID{}, errInvalidMessageID
+ }
+
+ seq, err := strconv.ParseUint(split[1], 10, 64)
+ if err != nil {
+ return radix.StreamEntryID{}, errInvalidMessageID
+ }
+
+ return radix.StreamEntryID{Time: time, Seq: seq}, nil
+}