Documentation
¶
Index ¶
- Constants
- Variables
- type Creator
- type DocumentKey
- type Listener
- type Mongo
- type NS
- type Processor
- func (p *Processor[T]) Create(ctx context.Context, ps T) (id string, err error)
- func (p *Processor[T]) Delete(ctx context.Context, id string) (err error)
- func (p *Processor[T]) PrepareCreate(ctx context.Context, ps T) (prepared T, doc bson.D, err error)
- func (p *Processor[T]) PrepareUpdate(ctx context.Context, ps T) (prepared T, set bson.D, unset bson.D, err error)
- func (p *Processor[T]) Update(ctx context.Context, ps T) (T, error)
- type Remover
- type Searcher
- type Stream
- type StreamDelete
- type StreamInsert
- type StreamListener
- type StreamType
- type StreamUpdate
- type StreamingNS
- type UpdateDescription
- type Updater
- type Upsert
Constants ¶
View Source
const ( // InsertOperationType ... InsertOperationType = "insert" // UpdateOperationType ... UpdateOperationType = "update" // DeleteOperationType ... DeleteOperationType = "delete" )
Variables ¶
Functions ¶
This section is empty.
Types ¶
type Creator ¶
type Creator struct {
// contains filtered or unexported fields
}
Creator ...
func NewCreator ¶
func NewCreator(client *mongo.Client, db string, collection string, connectionTimeout time.Duration) *Creator
NewCreator ...
type DocumentKey ¶
DocumentKey ...
type Listener ¶
type Listener[T d] struct {
// contains filtered or unexported fields
}
Listener ...
func NewListener ¶
NewListener ...
type Mongo ¶
type Mongo[T d] struct {
Searcher searcher[T]
Processor processor[T]
Listener StreamListener
Creator creator
Updater updater
Upserter upserter
Remover remover
}
Mongo ...
type Processor ¶
type Processor[T d] struct {
// contains filtered or unexported fields
}
Processor ...
func NewProcessor ¶
func NewProcessor[T d]( cache cache[T], creator creator, updater updater, remover remover, ) *Processor[T]
NewProcessor ...
func (*Processor[T]) PrepareCreate ¶
PrepareCreate ...
func (*Processor[T]) PrepareUpdate ¶
type Remover ¶
type Remover struct {
// contains filtered or unexported fields
}
Remover ...
func NewRemover ¶
func NewRemover(client *mongo.Client, db string, collection string, connectionTimeout time.Duration) *Remover
NewRemover ...
type Searcher ¶
type Searcher[T d] struct {
// contains filtered or unexported fields
}
Searcher ...
type Stream ¶
Stream ...
func NewStream ¶
func NewStream( change *mongo.ChangeStream, listeners map[string]map[string]StreamListener, ) *Stream
NewStream ...
func (*Stream) AddListener ¶
func (s *Stream) AddListener(ctx context.Context, db, col string, listener StreamListener)
AddListener ...
type StreamDelete ¶
type StreamDelete struct {
DocumentKey DocumentKey `json:"documentKey" bson:"documentKey"`
}
StreamDelete ...
type StreamInsert ¶
type StreamInsert[T any] struct { FullDocument T `json:"fullDocument" bson:"fullDocument"` }
StreamInsert ...
type StreamListener ¶
StreamListener ...
type StreamType ¶
type StreamType struct {
OperationType string `json:"operationType" bson:"operationType"`
}
StreamType ...
type StreamUpdate ¶
type StreamUpdate[T any] struct { DocumentKey DocumentKey `json:"documentKey" bson:"documentKey"` UpdateDescription UpdateDescription[T] `json:"updateDescription" bson:"updateDescription"` }
StreamUpdate ...
type UpdateDescription ¶
type UpdateDescription[T any] struct { UpdatedFields T `json:"updatedFields" bson:"updatedFields"` RemovedFields []string `json:"removedFields" bson:"removedFields"` }
UpdateDescription ...
type Updater ¶
type Updater struct {
// contains filtered or unexported fields
}
Updater ...
func NewUpdater ¶
func NewUpdater(client *mongo.Client, db string, collection string, connectionTimeout time.Duration) *Updater
NewUpdater ...
func (*Updater) UpdateOne ¶
func (s *Updater) UpdateOne(ctx context.Context, id string, version *int64, set bson.D, unset bson.D) (found bool, err error)
UpdateOne ... Алгоритм записи данных в монго 1. Взяли данные с версией, например 1 2. Подготовили изменение в данных 3. Вытаемся обновить данные с версией 1 4. Если не получилось (версия ушла дальше), то берем снова данные с новой версией, например 3, и пытаемся их записать
Click to show internal directories.
Click to hide internal directories.