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/types.go | |
parent | 1dcdbca485394818381549a98b7d4c809842526c (diff) | |
download | getwtxt-faad3621aea68c05d67e86e3b1b3dfc983c7b620.tar.gz |
fleshing out Indexer interface
Diffstat (limited to 'registry/types.go')
-rw-r--r-- | registry/types.go | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/registry/types.go b/registry/types.go index 429c55c..6e8e7b1 100644 --- a/registry/types.go +++ b/registry/types.go @@ -9,6 +9,10 @@ import ( type Indexer interface { AddUser(string, string) DelUser(string) + GetUserStatuses() TimeMap + GetStatuses() TimeMap + QueryUser(string) []string + QueryTag(string) []string } // UserIndex provides an index of users by URL @@ -39,6 +43,21 @@ var imutex = sync.RWMutex{} // TimeSlice is used for sorting by timestamp. type TimeSlice []time.Time +// NewUserIndex returns a new instance of a user index +func NewUserIndex() *UserIndex { + return &UserIndex{} +} + +// NewTimeMap returns an initialized TimeMap. +func NewTimeMap() TimeMap { + return make(TimeMap) +} + +// NewTimeMapSlice returns an initialized slice of TimeMaps with zero length. +func NewTimeMapSlice() TimeMapSlice { + return make(TimeMapSlice, 0) +} + // Len returns the length of the slice to be sorted. // This helps satisfy sort.Interface with respect to TimeSlice. func (t TimeSlice) Len() int { |