mongo

package
v0.0.0-...-61fb44a Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2022 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Store

type Store[T any] struct {
	// contains filtered or unexported fields
}

Store represents MongoDB repository storage

func NewClient

func NewClient[T any](url string, collectionName string) *Store[T]

NewClient returns a new MongoDB storage url format mongodb://mongodb0.example.com:27017

func (*Store[T]) FetchDocs

func (s *Store[T]) FetchDocs() ([]*T, error)

FetchDocs is a function which returns all documents present the MongoDB store used for testing purposes in `e2e_test.go`

func (*Store[T]) Upload

func (s *Store[T]) Upload(callback func() error, payloads []*T) error

Upload uploads all payloads to a MongoDB collection with a callback function attached This uses a MongoDB transaction https://www.mongodb.com/docs/manual/core/transactions/ for ACID transactions in tandem with the callback function provided This ensures either both MongoDB and the callback succeed or they both fail the callback in this case is `upload to GRPC server` as per the problem statement Note:- MongoDB transaction feature requires replica sets https://www.mongodb.com/docs/manual/replication/

Jump to

Keyboard shortcuts

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