diff options
author | Ben Morrison <ben@gbmor.dev> | 2019-05-14 03:40:02 -0400 |
---|---|---|
committer | Ben Morrison <ben@gbmor.dev> | 2019-05-14 03:59:47 -0400 |
commit | faad3621aea68c05d67e86e3b1b3dfc983c7b620 (patch) | |
tree | cce34987043b5fdf793fcffc51a855d975e6693e /registry/index.go | |
parent | 1dcdbca485394818381549a98b7d4c809842526c (diff) | |
download | getwtxt-faad3621aea68c05d67e86e3b1b3dfc983c7b620.tar.gz |
fleshing out Indexer interface
Diffstat (limited to 'registry/index.go')
-rw-r--r-- | registry/index.go | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/registry/index.go b/registry/index.go index c3ea178..c5f8d2c 100644 --- a/registry/index.go +++ b/registry/index.go @@ -5,11 +5,6 @@ import ( "time" ) -// NewUserIndex returns a new instance of a user index -func NewUserIndex() *UserIndex { - return &UserIndex{} -} - // AddUser inserts a new user into the index. The *Data struct // contains the nickname and the time the user was added. func (index UserIndex) AddUser(nick string, url string) { @@ -28,3 +23,24 @@ func (index UserIndex) DelUser(url string) { delete(index, url) imutex.Unlock() } + +// GetUserStatuses returns a TimeMap containing a user's statuses +func (index UserIndex) GetUserStatuses(url string) TimeMap { + imutex.RLock() + status := index[url].Status + imutex.RUnlock() + return status +} + +// GetStatuses returns a TimeMap containing all statuses +func (index UserIndex) GetStatuses() TimeMap { + statuses := NewTimeMap() + imutex.RLock() + for _, v := range index { + for a, b := range v.Status { + statuses[a] = b + } + } + imutex.RUnlock() + return statuses +} |