catalog

package
v1.6.27 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2024 License: AGPL-3.0 Imports: 15 Imported by: 4

Documentation

Overview

Package state provides tools to maintain an index of all medias that have been backed up.

Index

Constants

This section is empty.

Variables

View Source
var (
	AlbumNameMandatoryErr            = errors.New("Album name is mandatory")
	AlbumStartAndEndDateMandatoryErr = errors.New("Start and End times are mandatory")
	AlbumEndDateMustBeAfterStartErr  = errors.New("Album end must be strictly after its start")
	AlbumFolderNameAlreadyTakenErr   = errors.New("Album folder name is already taken")
)
View Source
var (
	OrphanedMediasError  = errors.New("albums cannot be deleted if it make medias orphaned")
	AlbumIsNotEmptyError = errors.New("album is not empty")
)
View Source
var (
	AlbumNotFoundError = errors.New("album hasn't been found")

	EmptyFolderNameError = errors.New("folderName is mandatory and must be not empty")
)
View Source
var (
	DuplicatedAlbumError = errors.New("Timeline cannot contains duplicated albums")
)
View Source
var (
	MediaNotFoundError = fmt.Errorf("media not found")
)
View Source
var (
	NoAlbumLookedUpError = errors.New("no album matching")
)

Functions

func Init

func Init(repositoryAdapter RepositoryAdapter)

Init must be called before using this package.

Types

type Album

type Album struct {
	AlbumId
	Name  string    // Name for displaying purpose, not unique
	Start time.Time // Start is datetime inclusive
	End   time.Time // End is the datetime exclusive
}

Album is a logical grouping of medias ; also used to physically store media next to each others.

func (Album) IsEqual

func (a Album) IsEqual(other *Album) bool

IsEqual uses unique identifier to compare both albums

func (Album) String

func (a Album) String() string

type AlbumAutoCreateLookupStrategy added in v1.5.58

type AlbumAutoCreateLookupStrategy struct {
	Delegate CreateAlbumWithTimeline
}

func (*AlbumAutoCreateLookupStrategy) LookupAlbum added in v1.5.58

func (a *AlbumAutoCreateLookupStrategy) LookupAlbum(ctx context.Context, owner ownermodel.Owner, timeline *TimelineAggregate, mediaTime time.Time) (AlbumReference, error)

type AlbumDatesAmendedObserver added in v1.5.58

type AlbumDatesAmendedObserver interface {
	OnAlbumDatesAmended(ctx context.Context, amendedAlbum DatesUpdate) error
}

type AlbumDatesAmendedObserverFunc added in v1.5.58

type AlbumDatesAmendedObserverFunc func(ctx context.Context, amendedAlbum DatesUpdate) error

func (AlbumDatesAmendedObserverFunc) OnAlbumDatesAmended added in v1.5.58

func (f AlbumDatesAmendedObserverFunc) OnAlbumDatesAmended(ctx context.Context, amendedAlbum DatesUpdate) error

type AlbumDatesAmendedObserverWithTimeline added in v1.5.58

type AlbumDatesAmendedObserverWithTimeline interface {
	OnAlbumDatesAmendedWithTimeline(ctx context.Context, timeline *TimelineAggregate, amendedAlbum DatesUpdate) error
}

type AlbumDatesAmendedObserverWrapper added in v1.5.58

type AlbumDatesAmendedObserverWrapper struct {
	AlbumDatesAmendedObserver
}

func (*AlbumDatesAmendedObserverWrapper) OnAlbumDatesAmendedWithTimeline added in v1.6.4

func (a *AlbumDatesAmendedObserverWrapper) OnAlbumDatesAmendedWithTimeline(ctx context.Context, _ *TimelineAggregate, amendedAlbum DatesUpdate) error

type AlbumId

type AlbumId struct {
	Owner      ownermodel.Owner
	FolderName FolderName
}

func NewAlbumIdFromStrings added in v1.5.33

func NewAlbumIdFromStrings(owner, folderName string) AlbumId

NewAlbumIdFromStrings creates an AlbumId from 2 strings ; it doesn't guaranty its validity, use AlbumId.IsValid to check if any error.

func (AlbumId) IsEqual added in v1.5.33

func (a AlbumId) IsEqual(other AlbumId) bool

IsEqual uses unique identifier to compare both albums

func (AlbumId) IsValid added in v1.5.33

func (a AlbumId) IsValid() error

func (AlbumId) String

func (a AlbumId) String() string

type AlbumLookupStrategy added in v1.5.58

type AlbumLookupStrategy interface {
	// LookupAlbum returns the AlbumReference for the given mediaTime, or NoAlbumLookedUpError if it can't find any (or a technical error)
	LookupAlbum(ctx context.Context, owner ownermodel.Owner, timeline *TimelineAggregate, mediaTime time.Time) (AlbumReference, error)
}

type AlbumQueries added in v1.5.49

type AlbumQueries struct {
	Repository RepositoryAdapter
}

func (*AlbumQueries) CountMedia added in v1.5.50

func (a *AlbumQueries) CountMedia(ctx context.Context, album ...AlbumId) (map[AlbumId]int, error)

func (*AlbumQueries) FindAlbum added in v1.6.4

func (a *AlbumQueries) FindAlbum(ctx context.Context, albumId AlbumId) (*Album, error)

func (*AlbumQueries) FindAlbumsById added in v1.5.49

func (a *AlbumQueries) FindAlbumsById(ctx context.Context, ids []AlbumId) ([]*Album, error)

func (*AlbumQueries) FindAlbumsByOwner added in v1.5.49

func (a *AlbumQueries) FindAlbumsByOwner(ctx context.Context, owner ownermodel.Owner) ([]*Album, error)

type AlbumReference added in v1.5.54

type AlbumReference struct {
	AlbumId          *AlbumId // AlbumId if no album fit the time and the implementation doesn't support creation.
	AlbumJustCreated bool     // AlbumJustCreated is true if the album was created during the reference process (depending on the implementation capability).
}

type AmendAlbumDateRepositoryPort added in v1.5.45

type AmendAlbumDateRepositoryPort interface {
	AmendDates(ctx context.Context, album AlbumId, start, end time.Time) error
}

type AmendAlbumDates added in v1.5.45

type AmendAlbumDates struct {
	FindAlbumsByOwnerPort       FindAlbumsByOwnerPort
	AmendAlbumDatesWithTimeline AmendAlbumDatesWithTimeline
}

AmendAlbumDates is building the TimelineAggregate and passing it to methods requiring it.

func NewAmendAlbumDates added in v1.5.45

func NewAmendAlbumDates(
	findAlbumsByOwner FindAlbumsByOwnerPort,
	countMediasBySelectors CountMediasBySelectorsPort,
	amendAlbumDateRepository AmendAlbumDateRepositoryPort,
	transferMedias TransferMediasRepositoryPort,
	timelineMutationObservers ...TimelineMutationObserver,
) *AmendAlbumDates

func (*AmendAlbumDates) AmendAlbumDates added in v1.5.45

func (a *AmendAlbumDates) AmendAlbumDates(ctx context.Context, albumId AlbumId, start, end time.Time) error

type AmendAlbumDatesExecutor added in v1.5.45

type AmendAlbumDatesExecutor struct {
	AmendAlbumDateRepository AmendAlbumDateRepositoryPort
}

func (*AmendAlbumDatesExecutor) OnAlbumDatesAmended added in v1.5.45

func (a *AmendAlbumDatesExecutor) OnAlbumDatesAmended(ctx context.Context, update DatesUpdate) error

type AmendAlbumDatesStateless added in v1.5.58

type AmendAlbumDatesStateless struct {
	Observers []AlbumDatesAmendedObserverWithTimeline
}

func (*AmendAlbumDatesStateless) AmendAlbumDates added in v1.5.58

func (a *AmendAlbumDatesStateless) AmendAlbumDates(ctx context.Context, timeline *TimelineAggregate, albumId AlbumId, start, end time.Time) error

type AmendAlbumDatesWithTimeline added in v1.5.58

type AmendAlbumDatesWithTimeline interface {
	AmendAlbumDates(ctx context.Context, timeline *TimelineAggregate, albumId AlbumId, start, end time.Time) error
}

type AmendAlbumMediaTransfer added in v1.5.45

type AmendAlbumMediaTransfer struct {
	CountMediasBySelectors CountMediasBySelectorsPort
	MediaTransfer          MediaTransfer
}

func (*AmendAlbumMediaTransfer) OnAlbumDatesAmendedWithTimeline added in v1.6.4

func (a *AmendAlbumMediaTransfer) OnAlbumDatesAmendedWithTimeline(ctx context.Context, timeline *TimelineAggregate, updatedAlbum DatesUpdate) error

type CountMediasBySelectorsFunc added in v1.5.41

type CountMediasBySelectorsFunc func(ctx context.Context, owner ownermodel.Owner, selectors []MediaSelector) (int, error)

func (CountMediasBySelectorsFunc) CountMediasBySelectors added in v1.5.41

func (f CountMediasBySelectorsFunc) CountMediasBySelectors(ctx context.Context, owner ownermodel.Owner, selectors []MediaSelector) (int, error)

type CountMediasBySelectorsPort added in v1.5.41

type CountMediasBySelectorsPort interface {
	CountMediasBySelectors(ctx context.Context, owner ownermodel.Owner, selectors []MediaSelector) (int, error)
}

type CreateAlbum

type CreateAlbum struct {
	FindAlbumsByOwnerPort   FindAlbumsByOwnerPort
	CreateAlbumWithTimeline CreateAlbumWithTimeline
}

func NewAlbumCreate added in v1.5.42

func NewAlbumCreate(
	FindAlbumsByOwnerPort FindAlbumsByOwnerPort,
	InsertAlbumPort InsertAlbumPort,
	TransferMediasPort TransferMediasRepositoryPort,
	TimelineMutationObservers ...TimelineMutationObserver,
) *CreateAlbum

NewAlbumCreate creates the service to create a new album, including the transfer of medias

func (*CreateAlbum) Create added in v1.5.33

func (c *CreateAlbum) Create(ctx context.Context, request CreateAlbumRequest) (*AlbumId, error)

Create creates a new album

type CreateAlbumExecutor added in v1.5.42

type CreateAlbumExecutor struct {
	InsertAlbumPort InsertAlbumPort
}

func (*CreateAlbumExecutor) ObserveCreateAlbum added in v1.5.42

func (c *CreateAlbumExecutor) ObserveCreateAlbum(ctx context.Context, createdAlbum Album) error

type CreateAlbumMediaTransfer added in v1.5.42

type CreateAlbumMediaTransfer struct {
	MediaTransfer MediaTransfer
}

func (*CreateAlbumMediaTransfer) ObserveCreateAlbum added in v1.5.42

func (c *CreateAlbumMediaTransfer) ObserveCreateAlbum(ctx context.Context, timeline *TimelineAggregate, createdAlbum Album) error

type CreateAlbumObserver added in v1.5.42

type CreateAlbumObserver interface {
	ObserveCreateAlbum(ctx context.Context, createdAlbum Album) error
}

type CreateAlbumObserverFunc added in v1.5.42

type CreateAlbumObserverFunc func(ctx context.Context, createdAlbum Album) error

func (CreateAlbumObserverFunc) ObserveCreateAlbum added in v1.5.42

func (f CreateAlbumObserverFunc) ObserveCreateAlbum(ctx context.Context, createdAlbum Album) error

type CreateAlbumObserverWithTimeline added in v1.5.58

type CreateAlbumObserverWithTimeline interface {
	ObserveCreateAlbum(ctx context.Context, timeline *TimelineAggregate, createdAlbum Album) error
}

type CreateAlbumObserverWrapper added in v1.5.58

type CreateAlbumObserverWrapper struct {
	CreateAlbumObserver
}

func (*CreateAlbumObserverWrapper) ObserveCreateAlbum added in v1.5.58

func (c *CreateAlbumObserverWrapper) ObserveCreateAlbum(ctx context.Context, _ *TimelineAggregate, createdAlbum Album) error

type CreateAlbumRequest added in v1.5.33

type CreateAlbumRequest struct {
	Owner            ownermodel.Owner
	Name             string
	Start            time.Time
	End              time.Time
	ForcedFolderName string
}

CreateAlbumRequest is a request to create a new album

func (*CreateAlbumRequest) IsValid added in v1.5.33

func (c *CreateAlbumRequest) IsValid() error

func (*CreateAlbumRequest) String added in v1.5.33

func (c *CreateAlbumRequest) String() string

type CreateAlbumStateless added in v1.5.58

type CreateAlbumStateless struct {
	Observers []CreateAlbumObserverWithTimeline
}

func (*CreateAlbumStateless) Create added in v1.5.58

func (c *CreateAlbumStateless) Create(ctx context.Context, timeline *TimelineAggregate, request CreateAlbumRequest) (*AlbumId, error)

type CreateAlbumWithTimeline added in v1.5.58

type CreateAlbumWithTimeline interface {
	Create(ctx context.Context, timeline *TimelineAggregate, request CreateAlbumRequest) (*AlbumId, error)
}

type CreateMediaRequest

type CreateMediaRequest struct {
	Id         MediaId        // Id is generated from its signature with GenerateMediaId(MediaSignature)
	Signature  MediaSignature // Signature is the business key of a media
	FolderName FolderName     // FolderName is the name of the album the media is in
	Filename   string         // Filename is a user-friendly name that have the right extension.
	Type       MediaType
	Details    MediaDetails
}

CreateMediaRequest is the request to add a new media to an album belonging to the same Owner

type DatesUpdate added in v1.5.58

type DatesUpdate struct {
	UpdatedAlbum  Album
	PreviousStart time.Time
	PreviousEnd   time.Time
}

func (*DatesUpdate) DatesNotChanged added in v1.5.58

func (a *DatesUpdate) DatesNotChanged() bool

type DeleteAlbum

type DeleteAlbum struct {
	FindAlbumsByOwner      FindAlbumsByOwnerPort
	CountMediasBySelectors CountMediasBySelectorsPort
	Observers              []DeleteAlbumObserver
}

func NewDeleteAlbum added in v1.5.41

func NewDeleteAlbum(
	FindAlbumsByOwner FindAlbumsByOwnerPort,
	CountMediasBySelectors CountMediasBySelectorsPort,
	TransferMediasPort TransferMediasRepositoryPort,
	DeleteAlbumRepository DeleteAlbumRepositoryPort,
	TimelineMutationObservers ...TimelineMutationObserver,
) *DeleteAlbum

NewDeleteAlbum creates a new DeleteAlbum service.

func (*DeleteAlbum) DeleteAlbum added in v1.5.41

func (d *DeleteAlbum) DeleteAlbum(ctx context.Context, albumId AlbumId) error

DeleteAlbum delete an album, medias it contains are dispatched to other albums.

type DeleteAlbumMediaTransfer added in v1.5.41

type DeleteAlbumMediaTransfer struct {
	MediaTransferExecutor
}

func (*DeleteAlbumMediaTransfer) OnDeleteAlbum added in v1.5.42

func (d *DeleteAlbumMediaTransfer) OnDeleteAlbum(ctx context.Context, deletedAlbum AlbumId, records MediaTransferRecords) error

type DeleteAlbumMetadata added in v1.5.41

type DeleteAlbumMetadata struct {
	DeleteAlbumRepository DeleteAlbumRepositoryPort
}

func (*DeleteAlbumMetadata) OnDeleteAlbum added in v1.5.42

func (d *DeleteAlbumMetadata) OnDeleteAlbum(ctx context.Context, deletedAlbum AlbumId, transfers MediaTransferRecords) error

type DeleteAlbumObserver added in v1.5.42

type DeleteAlbumObserver interface {
	OnDeleteAlbum(ctx context.Context, deletedAlbum AlbumId, transfers MediaTransferRecords) error
}

type DeleteAlbumRepositoryFunc added in v1.5.41

type DeleteAlbumRepositoryFunc func(ctx context.Context, albumId AlbumId) error

func (DeleteAlbumRepositoryFunc) DeleteAlbum added in v1.5.41

func (f DeleteAlbumRepositoryFunc) DeleteAlbum(ctx context.Context, albumId AlbumId) error

type DeleteAlbumRepositoryPort added in v1.5.41

type DeleteAlbumRepositoryPort interface {
	DeleteAlbum(ctx context.Context, albumId AlbumId) error
}

type DryRunLookupStrategy added in v1.5.58

type DryRunLookupStrategy struct{}

func (*DryRunLookupStrategy) LookupAlbum added in v1.5.58

func (d *DryRunLookupStrategy) LookupAlbum(ctx context.Context, owner ownermodel.Owner, timeline *TimelineAggregate, mediaTime time.Time) (AlbumReference, error)

type FindAlbumByIdFunc added in v1.5.43

type FindAlbumByIdFunc func(ctx context.Context, id AlbumId) (*Album, error)

func (FindAlbumByIdFunc) FindAlbumById added in v1.5.43

func (f FindAlbumByIdFunc) FindAlbumById(ctx context.Context, id AlbumId) (*Album, error)

type FindAlbumByIdPort added in v1.5.43

type FindAlbumByIdPort interface {
	FindAlbumById(ctx context.Context, id AlbumId) (*Album, error)
}

type FindAlbumsByOwnerFunc added in v1.5.41

type FindAlbumsByOwnerFunc func(ctx context.Context, owner ownermodel.Owner) ([]*Album, error)

func (FindAlbumsByOwnerFunc) FindAlbumsByOwner added in v1.5.41

func (f FindAlbumsByOwnerFunc) FindAlbumsByOwner(ctx context.Context, owner ownermodel.Owner) ([]*Album, error)

type FindAlbumsByOwnerPort added in v1.5.33

type FindAlbumsByOwnerPort interface {
	FindAlbumsByOwner(ctx context.Context, owner ownermodel.Owner) ([]*Album, error)
}

type FindExistingSignaturePort added in v1.5.54

type FindExistingSignaturePort interface {
	FindSignatures(ctx context.Context, owner ownermodel.Owner, signatures []MediaSignature) (map[MediaSignature]MediaId, error)
}

type FindMediaRequest

type FindMediaRequest struct {
	Owner            ownermodel.Owner
	AlbumFolderNames map[FolderName]interface{} // AlbumFolderNames is a set of folder names (map value is nil)
	Ranges           []TimeRange                // Ranges is optional, if empty no restriction will be applied
}

FindMediaRequest is a filter that is applied to find medias within a time range.

func NewFindMediaRequest

func NewFindMediaRequest(owner ownermodel.Owner) *FindMediaRequest

func (*FindMediaRequest) String

func (m *FindMediaRequest) String() string

func (*FindMediaRequest) WithAlbum

func (m *FindMediaRequest) WithAlbum(folderNames ...FolderName) *FindMediaRequest

func (*FindMediaRequest) WithinRange

func (m *FindMediaRequest) WithinRange(start, end time.Time) *FindMediaRequest

type FolderName added in v1.5.33

type FolderName string

FolderName is a normalised ID unique per Owner

func NewFolderName added in v1.5.33

func NewFolderName(name string) FolderName

NewFolderName creates a FolderName with a normalised value ; it can still be invalid (empty)

func (FolderName) IsValid added in v1.5.33

func (n FolderName) IsValid() error

func (FolderName) String added in v1.5.33

func (n FolderName) String() string

type InMemoryMedia added in v1.6.4

type InMemoryMedia struct {
	MediaMeta
	AlbumId AlbumId
}

func NewInMemoryMedia added in v1.6.4

func NewInMemoryMedia(id MediaId, albumId AlbumId) InMemoryMedia

type InsertAlbumPort added in v1.5.33

type InsertAlbumPort interface {
	InsertAlbum(ctx context.Context, album Album) error
}

type InsertAlbumPortFunc added in v1.5.33

type InsertAlbumPortFunc func(ctx context.Context, album Album) error

func (InsertAlbumPortFunc) InsertAlbum added in v1.5.33

func (f InsertAlbumPortFunc) InsertAlbum(ctx context.Context, album Album) error

type InsertMedias

type InsertMedias struct {
	InsertMediasRepository InsertMediasRepositoryPort
	InsertMediasObservers  []InsertMediasObserver
}

InsertMedias is a use case to pre-generate ids and store media metadata

func NewInsertMedias added in v1.5.47

func NewInsertMedias(
	InsertMediasRepository InsertMediasRepositoryPort,
	InsertMediasObservers ...InsertMediasObserver,
) *InsertMedias

func (*InsertMedias) Insert added in v1.5.47

func (i *InsertMedias) Insert(ctx context.Context, owner ownermodel.Owner, medias []CreateMediaRequest) error

type InsertMediasObserver added in v1.5.47

type InsertMediasObserver interface {
	OnMediasInserted(context.Context, map[AlbumId][]MediaId) error
}

type InsertMediasRepositoryPort added in v1.5.47

type InsertMediasRepositoryPort interface {
	// InsertMedias bulks insert medias
	InsertMedias(ctx context.Context, owner ownermodel.Owner, media []CreateMediaRequest) error
}

type MediaDetails

type MediaDetails struct {
	Width, Height             int
	DateTime                  time.Time
	Orientation               MediaOrientation
	Make                      string
	Model                     string
	GPSLatitude, GPSLongitude float64
	Duration                  int64  // Duration is the length, in milliseconds, of a video
	VideoEncoding             string // VideoEncoding is the codec used to encode the video (ex: 'H264')
}

MediaDetails are extracted from the metadata within photos and videos and stored as it.

type MediaFutureReference added in v1.5.54

type MediaFutureReference struct {
	Signature          MediaSignature
	ProvisionalMediaId MediaId
	AlreadyExists      bool
}

MediaFutureReference is the response of a simulation of inserting the media: the unique ID (if the media already exists) or a unique ID the media can use.

type MediaId added in v1.5.33

type MediaId string

func GenerateMediaId

func GenerateMediaId(signature MediaSignature) (MediaId, error)

GenerateMediaId generate a unique ID for a media.

func (MediaId) Value added in v1.5.47

func (m MediaId) Value() string

type MediaMeta

type MediaMeta struct {
	Id        MediaId        // Id is the unique identifier to use across all domains
	Signature MediaSignature // Signature is the key used to get the image (or its location)
	Filename  string         // Filename original filename when image was uploaded
	Type      MediaType
	Details   MediaDetails
}

MediaMeta is an entry (read) of a media in the state

type MediaOrientation

type MediaOrientation string

type MediaPage

type MediaPage struct {
	NextPage string // NextPage is empty if no other pages
	Content  []*MediaMeta
}

MediaPage is the current page MediaMeta, and the token of the next page

type MediaQueries added in v1.6.4

type MediaQueries struct {
	MediaReadRepository MediaReadRepository
}

func (*MediaQueries) FindMediaOwnership added in v1.6.4

func (q *MediaQueries) FindMediaOwnership(ctx context.Context, owner ownermodel.Owner, mediaId MediaId) (*AlbumId, error)

FindMediaOwnership returns the folderName containing the media, or AlbumNotFoundError.

func (*MediaQueries) ListMedias added in v1.6.4

func (q *MediaQueries) ListMedias(ctx context.Context, albumId AlbumId) ([]*MediaMeta, error)

type MediaQueriesInMemory added in v1.6.4

type MediaQueriesInMemory struct {
	Medias []InMemoryMedia
}

MediaQueriesInMemory is a copy of MediaQueries with an in-memory implementation

func (*MediaQueriesInMemory) FindMediaOwnership added in v1.6.4

func (q *MediaQueriesInMemory) FindMediaOwnership(ctx context.Context, owner ownermodel.Owner, mediaId MediaId) (*AlbumId, error)

FindMediaOwnership returns the folderName containing the media, or AlbumNotFoundError.

func (*MediaQueriesInMemory) ListMedias added in v1.6.4

func (q *MediaQueriesInMemory) ListMedias(ctx context.Context, albumId AlbumId) ([]*MediaMeta, error)

type MediaReadRepository added in v1.6.4

type MediaReadRepository interface {
	FindMedias(ctx context.Context, request *FindMediaRequest) (medias []*MediaMeta, err error)
	FindMediaCurrentAlbum(ctx context.Context, owner ownermodel.Owner, mediaId MediaId) (id *AlbumId, err error)
}

type MediaSelector added in v1.5.33

type MediaSelector struct {
	//ExclusiveAlbum *AlbumId  // ExclusiveAlbum is the Album in which medias are NOT (optional)
	FromAlbums []AlbumId // FromAlbums is a list of potential origins of medias ; is mandatory on CreateAlbum case because media are not indexed by date, only per album.
	Start      time.Time // Start is the first date of matching medias, included
	End        time.Time // End is the last date of matching media, excluded at the second
}

func (MediaSelector) String added in v1.5.33

func (m MediaSelector) String() string

type MediaSignature

type MediaSignature struct {
	SignatureSha256 string
	SignatureSize   int
}

func DecodeMediaId

func DecodeMediaId(encodedId MediaId) (*MediaSignature, error)

DecodeMediaId reverse what the GenerateMediaId has done to find original signature.

func (MediaSignature) String

func (s MediaSignature) String() string

func (MediaSignature) Value added in v1.5.57

func (s MediaSignature) Value() string

type MediaTransfer added in v1.5.42

type MediaTransfer interface {
	Transfer(ctx context.Context, records MediaTransferRecords) error
}

type MediaTransferExecutor added in v1.5.43

type MediaTransferExecutor struct {
	TransferMediasRepository  TransferMediasRepositoryPort
	TimelineMutationObservers []TimelineMutationObserver
}

func (*MediaTransferExecutor) Transfer added in v1.5.43

type MediaTransferFunc added in v1.5.43

type MediaTransferFunc func(ctx context.Context, records MediaTransferRecords) error

func (MediaTransferFunc) Transfer added in v1.5.43

func (f MediaTransferFunc) Transfer(ctx context.Context, records MediaTransferRecords) error

type MediaTransferRecords added in v1.5.33

type MediaTransferRecords map[AlbumId][]MediaSelector

MediaTransferRecords is a description of all medias that needs to be moved accordingly to the Timeline change

func (MediaTransferRecords) String added in v1.5.33

func (r MediaTransferRecords) String() string

type MediaType

type MediaType string

type MediasInsertSimulator added in v1.5.54

type MediasInsertSimulator struct {
	FindExistingSignaturePort FindExistingSignaturePort
}

func (*MediasInsertSimulator) SimulateInsertingMedia added in v1.5.54

func (m *MediasInsertSimulator) SimulateInsertingMedia(ctx context.Context, owner ownermodel.Owner, signatures []MediaSignature) ([]MediaFutureReference, error)

type PageRequest

type PageRequest struct {
	Size     int64
	NextPage string
}

type PrioritySegment

type PrioritySegment struct {
	Start  time.Time
	End    time.Time
	Albums []Album // sorted by priority
}

type RenameAlbum

type RenameAlbum struct {
	FindAlbumById        FindAlbumByIdPort
	UpdateAlbumName      UpdateAlbumNamePort
	RenameAlbumObservers []RenameAlbumObserver
}

func NewRenameAlbum added in v1.5.43

func NewRenameAlbum(
	FindAlbumById FindAlbumByIdPort,
	UpdateAlbumName UpdateAlbumNamePort,
	InsertAlbumPort InsertAlbumPort,
	DeleteAlbumRepositoryPort DeleteAlbumRepositoryPort,
	TransferMedias TransferMediasRepositoryPort,
	FindAlbumsByOwner FindAlbumsByOwnerPort,
	TimelineMutationObservers ...TimelineMutationObserver,
) *RenameAlbum

NewRenameAlbum creates the service to rename an album

func (*RenameAlbum) RenameAlbum added in v1.5.43

func (r *RenameAlbum) RenameAlbum(ctx context.Context, request RenameAlbumRequest) error

type RenameAlbumObserver added in v1.5.43

type RenameAlbumObserver interface {
	OnRenameAlbum(ctx context.Context, current AlbumId, creationRequest CreateAlbumRequest) error
}

type RenameAlbumReplacer added in v1.5.43

type RenameAlbumReplacer struct {
	CreateAlbum               CreateAlbum
	MediaTransfer             MediaTransfer
	DeleteAlbumRepositoryPort DeleteAlbumRepositoryPort
}

func (*RenameAlbumReplacer) OnRenameAlbum added in v1.5.43

func (r *RenameAlbumReplacer) OnRenameAlbum(ctx context.Context, current AlbumId, creationRequest CreateAlbumRequest) error

type RenameAlbumRequest added in v1.5.43

type RenameAlbumRequest struct {
	CurrentId        AlbumId
	NewName          string
	RenameFolder     bool   // RenameFolder set to TRUE will create a new album with a FolderName generated from the NewName
	ForcedFolderName string // ForcedFolderName will create a new album with a specific FolderName (RenameFolder is ignored)
}

func (RenameAlbumRequest) IsValid added in v1.5.43

func (r RenameAlbumRequest) IsValid() error

func (RenameAlbumRequest) String added in v1.5.43

func (r RenameAlbumRequest) String() string

type RepositoryAdapter

type RepositoryAdapter interface {
	FindAlbumsByOwner(ctx context.Context, owner ownermodel.Owner) ([]*Album, error)

	// FindAlbumByIds only returns found albums
	FindAlbumByIds(ctx context.Context, ids ...AlbumId) ([]*Album, error)

	CountMedia(ctx context.Context, album ...AlbumId) (map[AlbumId]int, error)
}

RepositoryAdapter brings persistence layer to catalog package

type StatefulAlbumReferencer added in v1.5.58

type StatefulAlbumReferencer struct {
	Owner             ownermodel.Owner
	TimelineAggregate *TimelineAggregate
	LookupStrategies  []AlbumLookupStrategy // LookupStrategies will return the first matching album reference (not returning NoAlbumLookedUpError)
}

func (*StatefulAlbumReferencer) FindReference added in v1.5.58

func (a *StatefulAlbumReferencer) FindReference(ctx context.Context, mediaTime time.Time) (AlbumReference, error)

type ThreadSafeAlbumReferencer added in v1.6.13

type ThreadSafeAlbumReferencer struct {
	Delegate *StatefulAlbumReferencer
	// contains filtered or unexported fields
}

func NewAlbumAutoPopulateReferencer added in v1.5.54

func NewAlbumAutoPopulateReferencer(
	owner ownermodel.Owner,
	findAlbumsByOwner FindAlbumsByOwnerPort,
	insertAlbumPort InsertAlbumPort,
	transferMediasPort TransferMediasRepositoryPort,
	timelineMutationObservers ...TimelineMutationObserver,
) (*ThreadSafeAlbumReferencer, error)

func NewAlbumDryRunReferencer added in v1.5.57

func NewAlbumDryRunReferencer(
	owner ownermodel.Owner,
	findAlbumsByOwner FindAlbumsByOwnerPort,
) (*ThreadSafeAlbumReferencer, error)

func (*ThreadSafeAlbumReferencer) FindReference added in v1.6.13

func (t *ThreadSafeAlbumReferencer) FindReference(ctx context.Context, mediaTime time.Time) (AlbumReference, error)

type TimeRange

type TimeRange struct {
	Start time.Time
	End   time.Time
}

TimeRange is of days, start is inclusive (at the second), end is exclusive (at the second)

func (TimeRange) Equals

func (t TimeRange) Equals(other TimeRange) bool

func (TimeRange) Minus

func (t TimeRange) Minus(other TimeRange) (ranges []TimeRange)

func (TimeRange) Plus

func (t TimeRange) Plus(other TimeRange) (ranges []TimeRange)

func (TimeRange) String

func (t TimeRange) String() string

type Timeline

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

Timeline can be used to find to which album a media will belongs.

func NewTimeline

func NewTimeline(originalAlbums []*Album) (*Timeline, error)

NewTimeline creates a Timeline object used to compute overlaps between Album. List of albums must be sorted by Start date ASC (End sorting does not matter).

func (*Timeline) AppendAlbum

func (t *Timeline) AppendAlbum(album *Album) (*Timeline, error)

AppendAlbum generates a new timeline from memory

func (*Timeline) Debug added in v1.5.53

func (t *Timeline) Debug() string

func (*Timeline) FindAllAt

func (t *Timeline) FindAllAt(date time.Time) []*Album

func (*Timeline) FindAt

func (t *Timeline) FindAt(date time.Time) (*Album, bool)

FindAt returns nil if not found

func (*Timeline) FindBetween

func (t *Timeline) FindBetween(start, end time.Time) (segments []PrioritySegment, missed []PrioritySegment)

FindBetween is deprecated, use FindSegmentsBetween instead

func (*Timeline) FindForAlbum

func (t *Timeline) FindForAlbum(albumId AlbumId) (segments []PrioritySegment)

func (*Timeline) FindSegmentsBetween added in v1.5.41

func (t *Timeline) FindSegmentsBetween(start, end time.Time) (segments []PrioritySegment)

FindSegmentsBetween returns a list of segments between start and end date. Segments will cover the whole period, but might not have any album.

func (*Timeline) FindSegmentsBetweenAndFilter added in v1.5.45

func (t *Timeline) FindSegmentsBetweenAndFilter(start, end time.Time, albumId AlbumId) (segments []PrioritySegment)

FindSegmentsBetweenAndFilter returns a list of segments between start and end date, only segments lead by the given albumId will be returned.

type TimelineAggregate added in v1.5.53

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

func NewInitialisedTimelineAggregate added in v1.5.54

func NewInitialisedTimelineAggregate(albums []*Album) (*TimelineAggregate, error)

func NewLazyTimelineAggregate added in v1.5.54

func NewLazyTimelineAggregate(albums []*Album) *TimelineAggregate

NewLazyTimelineAggregate creates a new TimelineAggregate without timeline pre-computation. The timeline will be computed at the first AddNew call.

func (*TimelineAggregate) AddNew added in v1.5.53

func (t *TimelineAggregate) AddNew(addedAlbum Album) (MediaTransferRecords, error)

func (*TimelineAggregate) AmendDates added in v1.5.57

func (t *TimelineAggregate) AmendDates(amendedAlbum DatesUpdate) (MediaTransferRecords, []MediaSelector, error)

func (*TimelineAggregate) CreateNewAlbum added in v1.5.54

func (t *TimelineAggregate) CreateNewAlbum(ctx context.Context, request CreateAlbumRequest, observers ...CreateAlbumObserver) (Album, error)

func (*TimelineAggregate) FindAt added in v1.5.54

func (t *TimelineAggregate) FindAt(date time.Time) (*Album, bool, error)

func (*TimelineAggregate) RemoveAlbum added in v1.5.57

func (t *TimelineAggregate) RemoveAlbum(deletedAlbumId AlbumId) (MediaTransferRecords, []MediaSelector, error)

func (*TimelineAggregate) ValidateAmendDates added in v1.5.58

func (t *TimelineAggregate) ValidateAmendDates(albumId AlbumId, start, end time.Time) (*DatesUpdate, error)

type TimelineLookupStrategy added in v1.5.58

type TimelineLookupStrategy struct{}

func (TimelineLookupStrategy) LookupAlbum added in v1.5.58

func (t TimelineLookupStrategy) LookupAlbum(ctx context.Context, owner ownermodel.Owner, timeline *TimelineAggregate, mediaTime time.Time) (AlbumReference, error)

type TimelineMutationObserver added in v1.5.33

type TimelineMutationObserver interface {
	OnTransferredMedias(ctx context.Context, transfers TransferredMedias) error
}

TimelineMutationObserver will notify each observer that medias has been transferred to a different album.

type TimelineMutationObserverFunc added in v1.5.42

type TimelineMutationObserverFunc func(ctx context.Context, transfers TransferredMedias) error

func (TimelineMutationObserverFunc) OnTransferredMedias added in v1.6.4

func (f TimelineMutationObserverFunc) OnTransferredMedias(ctx context.Context, transfers TransferredMedias) error

type TransferMediasFunc added in v1.5.41

type TransferMediasFunc func(ctx context.Context, records MediaTransferRecords) (TransferredMedias, error)

func (TransferMediasFunc) TransferMediasFromRecords added in v1.5.41

func (f TransferMediasFunc) TransferMediasFromRecords(ctx context.Context, records MediaTransferRecords) (TransferredMedias, error)

type TransferMediasRepositoryPort added in v1.5.45

type TransferMediasRepositoryPort interface {
	TransferMediasFromRecords(ctx context.Context, records MediaTransferRecords) (TransferredMedias, error)
}

type TransferredMedias added in v1.5.33

type TransferredMedias struct {
	Transfers  map[AlbumId][]MediaId
	FromAlbums []AlbumId // FromAlbums is a list of potential origins of medias
}

TransferredMedias is a list of all medias that has be transferred to a different album in the state.

func NewTransferredMedias added in v1.6.4

func NewTransferredMedias() TransferredMedias

func (TransferredMedias) IsEmpty added in v1.5.41

func (t TransferredMedias) IsEmpty() bool

type UpdateAlbumNamePort added in v1.5.43

type UpdateAlbumNamePort interface {
	UpdateAlbumName(ctx context.Context, albumId AlbumId, newName string) error
}

Jump to

Keyboard shortcuts

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