dendrite/syncapi/streams/template_stream.go
Quentin Gliech 6e6c3de0a6
Rename the go package
github.com/matrix-org/dendrite to github.com/element-hq/dendrite
2024-10-17 17:33:45 +02:00

40 lines
729 B
Go

package streams
import (
"context"
"sync"
"github.com/element-hq/dendrite/syncapi/storage"
"github.com/element-hq/dendrite/syncapi/types"
)
type DefaultStreamProvider struct {
DB storage.Database
latest types.StreamPosition
latestMutex sync.RWMutex
}
func (p *DefaultStreamProvider) Setup(
ctx context.Context, snapshot storage.DatabaseTransaction,
) {
}
func (p *DefaultStreamProvider) Advance(
latest types.StreamPosition,
) {
p.latestMutex.Lock()
defer p.latestMutex.Unlock()
if latest > p.latest {
p.latest = latest
}
}
func (p *DefaultStreamProvider) LatestPosition(
ctx context.Context,
) types.StreamPosition {
p.latestMutex.RLock()
defer p.latestMutex.RUnlock()
return p.latest
}