Documentation
¶
Index ¶
- Constants
- func NewSuffixIndex[T d](cache Cache[T], btreeDegree int, from []string, to *string) (SuffixIndex[T], SuffixIndex[T])
- type AddCallbackListener
- type Cache
- type CacheWithEventListener
- type DeleteCallbackListener
- type Entity
- type EventListener
- type F
- type Idx
- type InMemory
- type Intersect
- func (s *Intersect) Intersect(in1 []string, in ...[]string) (res []string)
- func (s *Intersect) IntersectInt(in1, in2 []int) (res []int)
- func (s *Intersect) LeftOutter(in1, in2 []string) (res []string)
- func (s *Intersect) Union(in1, in2 []string) (res []string)
- func (s *Intersect) UnionInt(in1, in2 []int) (res []int)
- type InverseIndex
- type InverseUniqueIndex
- type Listener
- func (c *Listener[T]) Add(ctx context.Context, v T)
- func (c *Listener[T]) AddListener(listener StreamEventListener[T], before bool) (idx int)
- func (c *Listener[T]) Delete(ctx context.Context, _id primitive.ObjectID)
- func (c *Listener[T]) Update(ctx context.Context, _id primitive.ObjectID, updatedFields T, ...)
- type M
- type MongoDeps
- type Notifier
- func (s *Notifier[T]) Add(ctx context.Context, v T)
- func (s *Notifier[T]) AddListenerCreate(id string, c func()) string
- func (s *Notifier[T]) AddListenerDelete(id string, c func()) string
- func (s *Notifier[T]) AddListenerUpdate(id string, c func()) string
- func (s *Notifier[T]) Delete(ctx context.Context, _id primitive.ObjectID)
- func (s *Notifier[T]) DeleteListenerCreate(id, ui string)
- func (s *Notifier[T]) DeleteListenerDelete(id, ui string)
- func (s *Notifier[T]) DeleteListenerUpdate(id, ui string)
- func (s *Notifier[T]) Update(ctx context.Context, _id primitive.ObjectID, updatedFields T, ...)
- type Notify
- type Pool
- type S
- type Sorted
- type SortedIndex
- type StreamEventListener
- type Suffix
- func (s *Suffix[T]) Add(ctx context.Context, it T)
- func (s *Suffix[T]) Delete(ctx context.Context, _id primitive.ObjectID)
- func (s *Suffix[T]) Find(ctx context.Context, text string) (items []string)
- func (s *Suffix[T]) Search(ctx context.Context, text string) (items []string)
- func (s *Suffix[T]) Update(ctx context.Context, id primitive.ObjectID, updatedFields T, ...)
- type SuffixIndex
- type UpdateCallbackListener
- type UpdateSuffix
- func (s *UpdateSuffix[T]) Add(ctx context.Context, it T)
- func (s *UpdateSuffix[T]) Delete(ctx context.Context, _id primitive.ObjectID)
- func (s *UpdateSuffix[T]) Search(ctx context.Context, text string) (items []string)
- func (s *UpdateSuffix[T]) Update(ctx context.Context, id primitive.ObjectID, updatedFields T, ...)
Constants ¶
const ( InverseIndexType = "inverse" InverseUniqueIndexType = "inverse_unique" SortdIndexType = "sorted" SuffixIndexType = "suffix" )
Variables ¶
This section is empty.
Functions ¶
func NewSuffixIndex ¶
func NewSuffixIndex[T d](cache Cache[T], btreeDegree int, from []string, to *string) (SuffixIndex[T], SuffixIndex[T])
Types ¶
type AddCallbackListener ¶ added in v0.0.56
type AddCallbackListener[T d] struct {
// contains filtered or unexported fields
}
func NewAddCallbackListener ¶ added in v0.0.56
func NewAddCallbackListener[T d](callback func(ctx context.Context, v T)) *AddCallbackListener[T]
func (*AddCallbackListener[T]) Add ¶ added in v0.0.56
func (s *AddCallbackListener[T]) Add(ctx context.Context, v T)
type Cache ¶
type Cache[T d] interface {
All(ctx context.Context) (ids []string)
Get(ctx context.Context, id string) (b T, found bool)
GetByIndex(ctx context.Context, idx int) (r T, f bool)
GetIndexByID(id string) (idx int, found bool)
GetIDByIndex(idx int) (id string, found bool)
Add(ctx context.Context, v T)
Update(ctx context.Context, _id primitive.ObjectID, updatedFields T, removedFields []string)
Delete(ctx context.Context, _id primitive.ObjectID)
}
type CacheWithEventListener ¶
type CacheWithEventListener[T d] struct {
Cache Cache[T]
EventListener EventListener[T]
Notify Notify[T]
InverseIndexes map[string]InverseIndex[T]
InverseUniqueIndexes map[string]InverseUniqueIndex[T]
SortedIndexes map[string]SortedIndex[T]
SuffixIndexes map[string]SuffixIndex[T]
AwaitNotify Notify[T]
}
CacheWithEventListener ...
func NewCacheWithEventListener ¶
func NewCacheWithEventListener[T d]( beforeListeners []StreamEventListener[T], afterListeners []StreamEventListener[T], notify Notify[T], ) *CacheWithEventListener[T]
NewCacheWithEventListener ...
type DeleteCallbackListener ¶ added in v0.0.56
type DeleteCallbackListener[T d] struct {
// contains filtered or unexported fields
}
func NewDeleteCallbackListener ¶ added in v0.0.56
func NewDeleteCallbackListener[T d](callback func(ctx context.Context, id string)) *DeleteCallbackListener[T]
func (*DeleteCallbackListener[T]) Add ¶ added in v0.0.56
func (s *DeleteCallbackListener[T]) Add(ctx context.Context, v T)
type Entity ¶
type Entity[T d] struct {
Collection string
BeforeListeners []StreamEventListener[T]
AfterListeners []StreamEventListener[T]
Notify Notify[T]
Option func(InMemory[T])
}
Entity ...
type EventListener ¶
type EventListener[T d] interface {
StreamEventListener[T]
AddListener(listener StreamEventListener[T], before bool) (idx int)
}
type Idx ¶
Idx ...
func NewIdx ¶
func NewIdx( maxIdx *atomic.Int64, itemsByIndex map[int64]string, indexByID map[string]int64, ) *Idx
NewIdx ...
func (*Idx) GetIDByIndex ¶
GetIDByIndex ...
type InMemory ¶
type InMemory[T d] interface {
GetCacheWithEventListener() *CacheWithEventListener[T]
GetMongo() *mongo.Mongo[T]
Spawn(ctx context.Context) T
AwaitCreate(ctx context.Context, ps T) (id string, err error)
AwaitUpdate(ctx context.Context, ps T) (res T, err error)
AwaitUpdateDoc(ctx context.Context, id string, set, unset bson.D) (found bool, err error)
AwaitDelete(ctx context.Context, ps T) (err error)
}
type Intersect ¶
type Intersect struct {
}
Intersect ...
func (*Intersect) IntersectInt ¶
IntersectInt ...
func (*Intersect) LeftOutter ¶ added in v0.0.53
type InverseIndex ¶
type InverseIndex[T d] interface {
StreamEventListener[T]
Get(ctx context.Context, val ...*string) (ids []string)
}
func NewInverseIndex ¶
type InverseUniqueIndex ¶ added in v0.0.10
type InverseUniqueIndex[T d] interface {
StreamEventListener[T]
Get(ctx context.Context, val ...string) (id string, found bool)
}
func NewInverseUniqIndex ¶
type Listener ¶
type Listener[T d] struct {
// contains filtered or unexported fields
}
Listener ...
func (*Listener[T]) AddListener ¶
func (c *Listener[T]) AddListener(listener StreamEventListener[T], before bool) (idx int)
AddListener ...
type M ¶
type Notifier ¶
Notifier используется для ожидания обновления в кеше например, надо произвести запись в хранилище и дождаться обновления в inmemory 1) подписались на notify 2) сделали запись в хранилище 3) дождались обновления в inmemory подписка на ожидание самостоятельно удаляется
func NewNotifier ¶
func NewNotifier[T d]( listenersCreate map[string]map[string]func(), listenersUpdate map[string]map[string]func(), listenersDelete map[string]map[string]func(), ) *Notifier[T]
NewNotifier ...
func (*Notifier[T]) AddListenerCreate ¶
AddListenerCreate ...
func (*Notifier[T]) AddListenerDelete ¶
AddListenerDelete ...
func (*Notifier[T]) AddListenerUpdate ¶
AddListenerUpdate ...
func (*Notifier[T]) DeleteListenerCreate ¶
func (*Notifier[T]) DeleteListenerDelete ¶
func (*Notifier[T]) DeleteListenerUpdate ¶
type Notify ¶
type Notify[T d] interface {
StreamEventListener[T]
AddListenerCreate(id string, c func()) string
AddListenerUpdate(id string, c func()) string
AddListenerDelete(id string, c func()) string
DeleteListenerCreate(id, ui string)
DeleteListenerUpdate(id, ui string)
DeleteListenerDelete(id, ui string)
}
Notify ...
type Sorted ¶ added in v0.0.24
type Sorted interface {
Intersect(in []string) (res []string)
Add(ctx context.Context, id string, title string)
Update(ctx context.Context, id string, old string, title string)
Delete(ctx context.Context, id string, title string)
}
func BuildSorted ¶ added in v0.0.23
func BuildSorted() Sorted
type SortedIndex ¶
type SortedIndex[T d] interface {
StreamEventListener[T]
Intersect(in []string) (res []string)
}
func NewSortedIndex ¶
func NewSortedIndex[T d]( sorted Sorted, cache Cache[T], from []string, to *string, ) SortedIndex[T]
NewSortedIndex ...
type StreamEventListener ¶ added in v0.0.10
type StreamEventListener[T d] interface {
Add(ctx context.Context, v T)
Update(ctx context.Context, _id primitive.ObjectID, updatedFields T, removedFields []string)
Delete(ctx context.Context, _id primitive.ObjectID)
}
StreamEventListener ...
type Suffix ¶
type Suffix[T d] struct {
M
// contains filtered or unexported fields
}
type SuffixIndex ¶ added in v0.0.10
type SuffixIndex[T d] interface {
StreamEventListener[T]
Search(ctx context.Context, text string) (items []string)
Find(ctx context.Context, text string) (items []string)
}
func NewSuffix ¶
func NewSuffix[T d](index M, cache Cache[T], from []string, to *string) SuffixIndex[T]
func NewUpdateSuffix ¶ added in v0.0.38
func NewUpdateSuffix[T d](index M, cache Cache[T], from []string, to *string) SuffixIndex[T]
type UpdateCallbackListener ¶ added in v0.0.56
type UpdateCallbackListener[T d] struct {
// contains filtered or unexported fields
}
func NewUpdateCallbackListener ¶ added in v0.0.56
func NewUpdateCallbackListener[T d](callback func(ctx context.Context, id string, v T, removedFields []string)) *UpdateCallbackListener[T]
func (*UpdateCallbackListener[T]) Add ¶ added in v0.0.56
func (s *UpdateCallbackListener[T]) Add(ctx context.Context, v T)
type UpdateSuffix ¶ added in v0.0.38
type UpdateSuffix[T d] struct {
M
// contains filtered or unexported fields
}
func (*UpdateSuffix[T]) Add ¶ added in v0.0.38
func (s *UpdateSuffix[T]) Add(ctx context.Context, it T)
func (*UpdateSuffix[T]) Delete ¶ added in v0.0.38
func (s *UpdateSuffix[T]) Delete(ctx context.Context, _id primitive.ObjectID)
func (*UpdateSuffix[T]) Search ¶ added in v0.0.38
func (s *UpdateSuffix[T]) Search(ctx context.Context, text string) (items []string)
func (*UpdateSuffix[T]) Update ¶ added in v0.0.38
func (s *UpdateSuffix[T]) Update(ctx context.Context, id primitive.ObjectID, updatedFields T, removedFields []string)
Update удаляет старое значение из индекса сделано так, потому что основной суффиксный индекс включается в цепочку после обновления кеша а удалить данные мы можем только до обновления кеша, чтобы иметь в кеше старые данные с помощью такого решения мы ухоидим от необходимости ребилда кеша, он у нас актуальный всегда