native

package
v0.2.12 Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2023 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckMongoURLs added in v0.2.12

func CheckMongoURLs(providedMongoUrls string, expectedMongoNodeCount int) error

func Hash

func Hash(payload []byte) (string, error)

Hash hashes the given payload in SHA224 + Hex

Types

type Content

type Content struct {
	Body           map[string]interface{} `bson:"content"`
	ContentType    string                 `bson:"content-type"`
	OriginSystemID string                 `bson:"origin-system-id"`
}

type DB

type DB interface {
	Open() (TX, error)
	Close()
}

DB contains database functions

func NewMongoDatabase

func NewMongoDatabase(connection string, timeout int) DB

type DBIter

type DBIter interface {
	Done() bool
	Next(result interface{}) bool
	Err() error
	Timeout() bool
	Close() error
}

type InMemoryCollectionBuilder added in v0.2.12

type InMemoryCollectionBuilder struct {
	// contains filtered or unexported fields
}

func NewInMemoryCollectionBuilder added in v0.2.12

func NewInMemoryCollectionBuilder(s3ReadWriter s3.ReadWriter) *InMemoryCollectionBuilder

func (*InMemoryCollectionBuilder) LoadIntoMemory added in v0.2.12

func (b *InMemoryCollectionBuilder) LoadIntoMemory(ctx context.Context, uuidCollection UUIDCollection, collection string, skip int, blist blacklist.IsBlacklisted) (UUIDCollection, error)

type InMemoryUUIDCollection added in v0.2.12

type InMemoryUUIDCollection struct {
	// contains filtered or unexported fields
}

func (*InMemoryUUIDCollection) Close added in v0.2.12

func (i *InMemoryUUIDCollection) Close() error

func (*InMemoryUUIDCollection) Done added in v0.2.12

func (i *InMemoryUUIDCollection) Done() bool

func (*InMemoryUUIDCollection) Length added in v0.2.12

func (i *InMemoryUUIDCollection) Length() int

func (*InMemoryUUIDCollection) Next added in v0.2.12

func (i *InMemoryUUIDCollection) Next() (bool, string, error)

type MockDB

type MockDB struct {
	mock.Mock
}

func (*MockDB) Close

func (m *MockDB) Close()

func (*MockDB) Open

func (m *MockDB) Open() (TX, error)

type MockDBIter

type MockDBIter struct {
	mock.Mock
}

func (*MockDBIter) Close

func (m *MockDBIter) Close() error

func (*MockDBIter) Done

func (m *MockDBIter) Done() bool

func (*MockDBIter) Err

func (m *MockDBIter) Err() error

func (*MockDBIter) Next

func (m *MockDBIter) Next(result interface{}) bool

func (*MockDBIter) Timeout

func (m *MockDBIter) Timeout() bool

type MockReader

type MockReader struct {
	mock.Mock
}

func (*MockReader) Get

func (m *MockReader) Get(collection string, uuid string) (*Content, error)

type MockTX

type MockTX struct {
	mock.Mock
}

func (*MockTX) Close

func (t *MockTX) Close()

func (*MockTX) FindUUIDs

func (t *MockTX) FindUUIDs(collectionID string, skip int, batchsize int) (DBIter, int, error)

func (*MockTX) FindUUIDsInTimeWindow

func (t *MockTX) FindUUIDsInTimeWindow(collectionID string, start time.Time, end time.Time, batchsize int) (DBIter, int, error)

func (*MockTX) Ping

func (t *MockTX) Ping(ctx context.Context) error

func (*MockTX) ReadNativeContent

func (t *MockTX) ReadNativeContent(collectionID string, uuid string) (*Content, error)

type MockUUIDCollection added in v0.2.12

type MockUUIDCollection struct {
	mock.Mock
	// contains filtered or unexported fields
}

func (*MockUUIDCollection) Close added in v0.2.12

func (m *MockUUIDCollection) Close() error

func (*MockUUIDCollection) Done added in v0.2.12

func (m *MockUUIDCollection) Done() bool

func (*MockUUIDCollection) Length added in v0.2.12

func (m *MockUUIDCollection) Length() int

func (*MockUUIDCollection) Next added in v0.2.12

func (m *MockUUIDCollection) Next() (bool, string, error)

type MongoDB

type MongoDB struct {
	Urls    string
	Timeout int
	// contains filtered or unexported fields
}

MongoDB wraps a mango mongo session

func (*MongoDB) Close

func (db *MongoDB) Close()

Close closes the entire database connection

func (*MongoDB) Open

func (db *MongoDB) Open() (TX, error)

type MongoReader

type MongoReader struct {
	// contains filtered or unexported fields
}

func (*MongoReader) Get

func (m *MongoReader) Get(collection string, uuid string) (*Content, error)

type MongoTX

type MongoTX struct {
	// contains filtered or unexported fields
}

MongoTX wraps a mongo session

func (*MongoTX) Close

func (tx *MongoTX) Close()

Close closes the transaction

func (*MongoTX) FindUUIDs

func (tx *MongoTX) FindUUIDs(collectionID string, skip int, batchsize int) (DBIter, int, error)

FindUUIDs returns all uuids for a collection sorted by lastodified date, if no lastmodified exists records are returned at the end of the list

func (*MongoTX) FindUUIDsInTimeWindow

func (tx *MongoTX) FindUUIDsInTimeWindow(collectionID string, start time.Time, end time.Time, batchsize int) (DBIter, int, error)

FindUUIDsInTimeWindow queries mongo for a list of uuids and returns an iterator

func (*MongoTX) Ping

func (tx *MongoTX) Ping(ctx context.Context) error

Ping returns a mongo ping response

func (*MongoTX) ReadNativeContent

func (tx *MongoTX) ReadNativeContent(collectionID string, uuid string) (*Content, error)

ReadNativeContent queries mongo for a uuid and returns the native document

type NativeUUIDCollection

type NativeUUIDCollection struct {
	// contains filtered or unexported fields
}

func (*NativeUUIDCollection) Close

func (n *NativeUUIDCollection) Close() error

func (*NativeUUIDCollection) Done

func (n *NativeUUIDCollection) Done() bool

func (*NativeUUIDCollection) Length

func (n *NativeUUIDCollection) Length() int

func (*NativeUUIDCollection) Next

func (n *NativeUUIDCollection) Next() (bool, string, error)

type NativeUUIDCollectionBuilder added in v0.2.12

type NativeUUIDCollectionBuilder struct {
	// contains filtered or unexported fields
}

func NewNativeUUIDCollectionBuilder added in v0.2.12

func NewNativeUUIDCollectionBuilder(mongo DB, rw s3.ReadWriter, isBlacklisted blacklist.IsBlacklisted) *NativeUUIDCollectionBuilder

func (*NativeUUIDCollectionBuilder) NewNativeUUIDCollection added in v0.2.12

func (b *NativeUUIDCollectionBuilder) NewNativeUUIDCollection(ctx context.Context, collection string, skip int) (UUIDCollection, error)

func (*NativeUUIDCollectionBuilder) NewNativeUUIDCollectionForTimeWindow added in v0.2.12

func (b *NativeUUIDCollectionBuilder) NewNativeUUIDCollectionForTimeWindow(collection string, start time.Time, end time.Time, maximumThrottle time.Duration) (UUIDCollection, error)

type Reader

type Reader interface {
	Get(collection string, uuid string) (*Content, error)
}

func NewMongoNativeReader

func NewMongoNativeReader(mongo DB) Reader

type TX

type TX interface {
	ReadNativeContent(collectionId string, uuid string) (*Content, error)
	FindUUIDsInTimeWindow(collectionId string, start time.Time, end time.Time, batchsize int) (DBIter, int, error)
	FindUUIDs(collectionId string, skip int, batchsize int) (DBIter, int, error)
	Ping(ctx context.Context) error
	Close()
}

TX contains database transaction functions

type UUIDCollection

type UUIDCollection interface {
	io.Closer
	Next() (bool, string, error)
	Length() int
	Done() bool
}

Jump to

Keyboard shortcuts

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