mongo_kvstore

package
v0.0.0-...-ba64992 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DocumentLike

type DocumentLike interface {
	GetId() string
}

type FindByObjectId

type FindByObjectId[D DocumentLike] func(store map[string]D, id primitive.ObjectID) (string, D)

type Handler

type Handler[D DocumentLike] interface {
	OnInserted(doc D)
	OnUpdated(doc D)
	OnDeleted(key string, doc D)
}

type MongoKVStore

type MongoKVStore[D DocumentLike] struct {
	UseStore       bool
	Handler        Handler[D]
	NewDocument    NewDocument[D]
	FindByObjectId FindByObjectId[D]

	Lock  sync.RWMutex
	Store map[string]D
	// contains filtered or unexported fields
}

func NewMongoKVStore

func NewMongoKVStore[D DocumentLike]() *MongoKVStore[D]

func (*MongoKVStore[D]) Start

func (s *MongoKVStore[D]) Start(ctx context.Context, collection *mongo.Collection) error

func (*MongoKVStore[D]) Stop

func (s *MongoKVStore[D]) Stop()

type NewDocument

type NewDocument[D DocumentLike] func() D

Jump to

Keyboard shortcuts

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