aboutsummaryrefslogtreecommitdiffhomepage
path: root/internal/state/join.go
diff options
context:
space:
mode:
authorOphestra <cat@gensokyo.uk>2025-07-02 20:42:51 +0900
committerOphestra <cat@gensokyo.uk>2025-07-02 20:42:51 +0900
commiteb22a8bcc1ac03357d4073e5d3ed6d0ab5246a37 (patch)
treed27d1f724a18bb47bf48816a444dccac28b5248c /internal/state/join.go
parent31aef905fa819310ee7694775a836c294ff742e4 (diff)
cmd/hakurei: move to cmd
Having it at the project root never made sense since the "ego" name was deprecated. This change finally addresses it. Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'internal/state/join.go')
-rw-r--r--internal/state/join.go60
1 files changed, 0 insertions, 60 deletions
diff --git a/internal/state/join.go b/internal/state/join.go
deleted file mode 100644
index 2b4011fe..00000000
--- a/internal/state/join.go
+++ /dev/null
@@ -1,60 +0,0 @@
-package state
-
-import (
- "errors"
- "maps"
-)
-
-var (
- ErrDuplicate = errors.New("store contains duplicates")
-)
-
-/*
-Joiner is the interface that wraps the Join method.
-
-The Join function uses Joiner if available.
-*/
-type Joiner interface{ Join() (Entries, error) }
-
-// Join returns joined state entries of all active aids.
-func Join(s Store) (Entries, error) {
- if j, ok := s.(Joiner); ok {
- return j.Join()
- }
-
- var (
- aids []int
- entries = make(Entries)
-
- el int
- res Entries
- loadErr error
- )
-
- if ln, err := s.List(); err != nil {
- return nil, err
- } else {
- aids = ln
- }
-
- for _, aid := range aids {
- if _, err := s.Do(aid, func(c Cursor) {
- res, loadErr = c.Load()
- }); err != nil {
- return nil, err
- }
-
- if loadErr != nil {
- return nil, loadErr
- }
-
- // save expected length
- el = len(entries) + len(res)
- maps.Copy(entries, res)
- if len(entries) != el {
- return nil, ErrDuplicate
- }
- }
-
- return entries, nil
-}