From eed10ce514f28e4acf772f76c92ca05eebec105f Mon Sep 17 00:00:00 2001 From: Brian Picciano Date: Thu, 5 May 2022 21:20:22 -0600 Subject: Fix various problems with the srv build --- srv/src/chat/util.go | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 srv/src/chat/util.go (limited to 'srv/src/chat/util.go') 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 +} -- cgit v1.2.3