db

package
v0.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 10, 2023 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetCache

func SetCache(s CacheDBer)

func SetStream

func SetStream(s StreamDBer)

func SetSyncTask

func SetSyncTask(s SyncTaskDBer)

func SetWatchCollection

func SetWatchCollection(s WatchCollectionDBer)

Types

type CacheDBer

type CacheDBer interface {
	ResumeToken(ctx context.Context) (token ResumeToken, ok bool)
	SaveResumeToken(ctx context.Context, token ResumeToken)

	SentStreamId(ctx context.Context) (id StreamId, ok bool)
	DelSentStreamId(ctx context.Context)
	SaveSentStreamId(ctx context.Context, id StreamId)
}

func Cache

func Cache() CacheDBer

type ResumeToken

type ResumeToken = bson.Raw

type StreamDBer

type StreamDBer interface {
	// Save token: StreamValue的一个唯一值,常用 resume token
	Save(ctx context.Context, token []byte, value StreamValue) (id StreamId)
	Get(ctx context.Context, id StreamId) (value StreamValue, ok bool)

	All(ctx context.Context) StreamIterator
	StartWith(ctx context.Context, id StreamId) StreamIterator

	GetLastOne(ctx context.Context) (id StreamId, ok bool)
}

func Stream

func Stream() StreamDBer

type StreamId

type StreamId = []byte

type StreamIterator

type StreamIterator interface {
	First(ctx context.Context) (id StreamId, value StreamValue, ok bool)
	Last(ctx context.Context) (id StreamId, ok bool)

	// Next 必须按照StreamId顺序返回
	Next(ctx context.Context, limit int) (values []StreamValue, lastId StreamId, ok bool)

	Release()
}

type StreamValue

type StreamValue = bson.Raw

type SyncTaskDBer

type SyncTaskDBer interface {
	All(ctx context.Context) SyncTaskIterator

	// InsertOrUpdate task.Id 是唯一标识符,相同的id进行覆盖
	InsertOrUpdate(ctx context.Context, task Task)
	InsertOrUpdateBatch(ctx context.Context, tasks []Task)

	Del(ctx context.Context, id string)
	DelBatch(ctx context.Context, ids []string)
	DelAll(ctx context.Context)
}

func SyncTask

func SyncTask() SyncTaskDBer

type SyncTaskIterator

type SyncTaskIterator interface {
	First(ctx context.Context) (task Task, ok bool)
	Next(ctx context.Context) (task Task, ok bool)
	Release()
}

type Task

type Task struct {
	config.WatchInfo

	// _id
	StartDocId []byte
}

type WatchCollectionDBer

type WatchCollectionDBer interface {
	All(ctx context.Context) []config.WatchInfo
	Save(ctx context.Context, w []config.WatchInfo)
}

func WatchCollection

func WatchCollection() WatchCollectionDBer

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL