dynamo

package
v0.0.0-...-3382da6 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2021 License: AGPL-3.0 Imports: 17 Imported by: 0

Documentation

Overview

Package dynamodb package store all the data in a single multi-tenant table:

  • OWNER > Album X meta > Album Y meta
  • MEDIA (OWNER#SIGNATURE) > #META > LOCATION > MOVE LOCATION > MOVE LOCATION
  • MOVE TRANSACTION (...#uniqueID)

Index

Constants

View Source
const (
	IsoTime = "2006-01-02T15:04:05"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AlbumData

type AlbumData struct {
	TablePk
	AlbumIndexKey
	AlbumName       string
	AlbumFolderName string
	AlbumStart      time.Time
	AlbumEnd        time.Time
}

type AlbumIndexKey

type AlbumIndexKey struct {
	AlbumIndexPK string // AlbumIndexPK is same than album's TablePk.PK
	AlbumIndexSK string
}

type MediaData

type MediaData struct {
	TablePk
	AlbumIndexKey
	Type          string           // Type is either PHOTO or VIDEO
	DateTime      time.Time        // DateTime time used in AlbumIndexKey
	Details       MediaDetailsData // Details are other attributes from domain model, stored as it
	Filename      string           // Filename is the original filename for display purpose only ; physical filename is in MediaLocationData
	SignatureSize int
	SignatureHash string
}

type MediaDetailsData

type MediaDetailsData map[string]interface{}

MediaDetailsData is a sub-object ; not stored directly

type MediaLocationData

type MediaLocationData struct {
	TablePk
	FolderName    string // FolderName is where the media is physically located: its current album folder or previous album if the physical move haven't been flushed yet
	Filename      string // Filename is the physical name of the image
	SignatureSize int
	SignatureHash string
}

type MediaMoveOrderData

type MediaMoveOrderData struct {
	TablePk                  // TablePk.PK is the same than the media, TablePk.SK is the transaction
	MoveTransaction   string // MoveTransaction is a copy of TablePk.SK used by 'MoveOrder' index (thus, only orders are in the index, not transactions)
	DestinationFolder string // DestinationFolder is the folder name of the album to which media must be moved.
}

type MediaMoveTransactionData

type MediaMoveTransactionData struct {
	TablePk
	MoveTransactionStatus MediaMoveTransactionStatus // MoveTransactionStatus is false until all media to be moved have a MediaMoveOrderData created and their album updated
}

type MediaMoveTransactionStatus

type MediaMoveTransactionStatus string

type Rep

type Rep struct {
	RootOwner string // RootOwner is the tenant id, 'ROOT' if single tenant.
	// contains filtered or unexported fields
}

func Must

func Must(rep *Rep, err error) *Rep

Must panics if there is an error

func NewRepository

func NewRepository(awsSession *session.Session, owner string, tableName string) (*Rep, error)

NewRepository creates the repository and connect to the database

func (*Rep) CountMedias

func (r *Rep) CountMedias(folderName string) (int, error)

func (*Rep) CreateTableIfNecessary

func (r *Rep) CreateTableIfNecessary() error

CreateTableIfNecessary creates the table if it doesn't exists ; or update it.

func (*Rep) DeleteEmptyAlbum

func (r *Rep) DeleteEmptyAlbum(folderName string) error

func (*Rep) DeleteEmptyMoveTransaction

func (r *Rep) DeleteEmptyMoveTransaction(transactionId string) error

func (*Rep) FindAlbum

func (r *Rep) FindAlbum(folderName string) (*catalog.Album, error)

func (*Rep) FindAllAlbums

func (r *Rep) FindAllAlbums() ([]*catalog.Album, error)

func (*Rep) FindExistingSignatures

func (r *Rep) FindExistingSignatures(signatures []*catalog.MediaSignature) ([]*catalog.MediaSignature, error)

func (*Rep) FindFilesToMove

func (r *Rep) FindFilesToMove(transactionId, pageToken string) ([]*catalog.MovedMedia, string, error)

FindFilesToMove returns a page of media to move (25 like a write batch of dynamodb) and the next page token

func (*Rep) FindMediaLocations

func (r *Rep) FindMediaLocations(signature catalog.MediaSignature) ([]*catalog.MediaLocation, error)

func (*Rep) FindMediaLocationsSignatures

func (r *Rep) FindMediaLocationsSignatures(signatures []*catalog.MediaSignature) ([]*catalog.MediaSignatureAndLocation, error)

func (*Rep) FindMedias

func (r *Rep) FindMedias(folderName string, filter catalog.FindMediaFilter) (*catalog.MediaPage, error)

func (*Rep) FindReadyMoveTransactions

func (r *Rep) FindReadyMoveTransactions() ([]*catalog.MoveTransaction, error)

func (*Rep) InsertAlbum

func (r *Rep) InsertAlbum(album catalog.Album) error

func (*Rep) InsertMedias

func (r *Rep) InsertMedias(medias []catalog.CreateMediaRequest) error

func (*Rep) UpdateAlbum

func (r *Rep) UpdateAlbum(album catalog.Album) error

func (*Rep) UpdateMedias

func (r *Rep) UpdateMedias(filter *catalog.UpdateMediaFilter, newFolderName string) (string, int, error)

func (*Rep) UpdateMediasLocation

func (r *Rep) UpdateMediasLocation(transactionId string, moves []*catalog.MovedMedia) error

type Stream

type Stream interface {
	HasNext() bool                             // HasNext returns true if it has another element
	Next() map[string]*dynamodb.AttributeValue // Next return current element and move forward the cursor
	Error() error                              // Error returns the error that interrupted the Stream
	Count() int64                              // Count return the number of element found so far
}

Stream is inspired from Java streams to chain transformations in a functional programming style

func NewArrayStream

func NewArrayStream(results []map[string]*dynamodb.AttributeValue) Stream

func NewGetStream

func NewGetStream(rep *Rep, keys []map[string]*dynamodb.AttributeValue, projectionExpression *string, bufferSize int64) Stream

func NewQueryStream

func NewQueryStream(rep *Rep, queries []*dynamodb.QueryInput) Stream

type TablePk

type TablePk struct {
	PK string // Partition key ; see what's used depending on object types
	SK string // Sort key ; see what's used depending on object types
}

Jump to

Keyboard shortcuts

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