Documentation
¶
Index ¶
- Constants
- Variables
- func IsOriginal(name string) bool
- func SourceFilename(name, ext string) string
- type Action
- func (a *Action) Copy() *Action
- func (a *Action) Equal(act *Action) bool
- func (a *Action) Value(name string, def any) any
- func (a *Action) ValueBool(name string, def bool) bool
- func (a *Action) ValueFloat64(name string, def float64) float64
- func (a *Action) ValueInt32(name string, def int32) int32
- func (a *Action) ValueInt64(name string, def int64) int64
- func (a *Action) ValueString(name string, def string) string
- func (a *Action) ValueStringSlice(name string) []string
- type Event
- type EventType
- type ItemMeta
- func (m *ItemMeta) ExtJSON() string
- func (m *ItemMeta) FromExtJSON(data []byte) error
- func (m *ItemMeta) Fullname() string
- func (m *ItemMeta) GetExt(name string) any
- func (m *ItemMeta) IsEmpty() bool
- func (m *ItemMeta) IsTaskProcessed(id string) bool
- func (m *ItemMeta) MarkAsComplete(id string)
- func (m *ItemMeta) MarkAsIncomplete(id string)
- func (m *ItemMeta) ObjectTypeExt() string
- func (m *ItemMeta) SetExt(name string, value any)
- func (m *ItemMeta) UpdateName(name string)
- type Manifest
- func (m *Manifest) GetStages() []*ManifestTaskStage
- func (m *Manifest) GetVersion() string
- func (m *Manifest) HasTask(id string) bool
- func (m *Manifest) HasTaskByTarget(name string) bool
- func (m *Manifest) IsEmpty() bool
- func (m *Manifest) IsValidContentType(contentType string) bool
- func (m *Manifest) PrepareInfo() *Manifest
- func (m *Manifest) TargetCount() int
- func (m *Manifest) TaskByID(id string) *ManifestTask
- func (m *Manifest) TaskByTarget(name string) *ManifestTask
- func (m *Manifest) TaskCount() int
- func (m *Manifest) UnmarshalJSON(data []byte) error
- type ManifestTask
- type ManifestTaskStage
- type Meta
- func (m *Meta) CleanSubItems()
- func (m *Meta) Complete(itemMeta *ItemMeta, task *ManifestTask, err error)
- func (m *Meta) ErrorTaskCount() (errorCount int)
- func (m *Meta) ExcessItems(manifest *Manifest) []*ItemMeta
- func (m *Meta) IsComplete(manifest *Manifest, stages ...string) bool
- func (m *Meta) IsCompleteTask(task *ManifestTask) bool
- func (m *Meta) IsConsistent(manifest *Manifest) bool
- func (m *Meta) IsEmpty() bool
- func (m *Meta) IsProcessingComplete(manifest *Manifest, stages ...string) bool
- func (m *Meta) IsProcessingCompleteTask(task *ManifestTask, maxRetries ...int) bool
- func (m *Meta) ItemByName(name string) *ItemMeta
- func (m *Meta) RemoveExcessTasks(manifest *Manifest)
- func (m *Meta) RemoveItemByName(name string) (bool, error)
- func (m *Meta) RemoveTaskByID(id string) bool
- func (m *Meta) ResetCompletion()
- func (m *Meta) SetItem(item *ItemMeta)
- type MetaTaskInfo
- type Object
- type ObjectStatus
- type ObjectType
Constants ¶
const (
MaxRetries = 10
)
Consts ...
const (
OriginalFilename = "prim"
)
Consts ...
Variables ¶
var ErrInvalidMetaMainItem = errors.New(`invalid meta main item`)
ErrInvalidMetaMainItem error
Functions ¶
func SourceFilename ¶
SourceFilename prepare ” -> @ = oroginal filename
Types ¶
type Action ¶
type Action struct { Name string `json:"name,omitempty"` MustExecute bool `json:"mustexecute,omitempty"` Values map[string]any `json:"values,omitempty"` }
Action which must be applied to source
func (*Action) ValueFloat64 ¶
ValueFloat64 parameter as float type
func (*Action) ValueInt32 ¶
ValueInt32 parameter as int type
func (*Action) ValueInt64 ¶
ValueInt64 parameter as int type
func (*Action) ValueString ¶
ValueString parameter as string type
func (*Action) ValueStringSlice ¶
ValueStringSlice parameter as string slice type
type Event ¶
type Event struct { Type EventType `json:"type"` Error string `json:"error,omitempty"` Object *Object `json:"object,omitempty"` }
Event produced by storage
type EventType ¶
type EventType string
EventType value
type ItemMeta ¶
type ItemMeta struct { TaskID []string `json:"task_id,omitempty"` Name string `json:"name"` NameExt string `json:"name_ext,omitempty"` Type ObjectType `json:"type,omitempty"` ContentType string `json:"content_type,omitempty"` HashID string `json:"hashid,omitempty"` Width int `json:"width,omitempty"` Height int `json:"height,omitempty"` Size int64 `json:"size,omitempty"` Duration int `json:"duration,omitempty"` Bitrate string `json:"bitrate,omitempty"` Codec string `json:"codec,omitempty"` Ext map[string]any `json:"ext,omitempty"` UpdatedAt time.Time `json:"updated_at,omitempty"` }
ItemMeta information about one object element
func (*ItemMeta) IsTaskProcessed ¶
IsTaskProcessed checks if the task was applied to the Item
func (*ItemMeta) MarkAsIncomplete ¶
MarkAsIncomplete task
func (*ItemMeta) ObjectTypeExt ¶
ObjectTypeExt returns file extension
type Manifest ¶
type Manifest struct { Version string `json:"version,omitempty"` ContentTypes []string `json:"content_types,omitempty"` Stages []*ManifestTaskStage `json:"stages,omitempty"` }
Manifest model object
func (*Manifest) GetStages ¶
func (m *Manifest) GetStages() []*ManifestTaskStage
GetStages returns the list of stagest safely
func (*Manifest) GetVersion ¶
GetVersion returns the version of manifest safely
func (*Manifest) HasTaskByTarget ¶
HasTaskByTarget name returns status
func (*Manifest) IsValidContentType ¶
IsValidContentType checks the content type
func (*Manifest) PrepareInfo ¶
PrepareInfo of the manifest
func (*Manifest) TargetCount ¶
TargetCount returns total count of targets
func (*Manifest) TaskByID ¶
func (m *Manifest) TaskByID(id string) *ManifestTask
TaskByID returns the task with such ID
func (*Manifest) TaskByTarget ¶
func (m *Manifest) TaskByTarget(name string) *ManifestTask
TaskByTarget name of result
func (*Manifest) UnmarshalJSON ¶
UnmarshalJSON is custom method of json.Unmarshaler implementation
type ManifestTask ¶
type ManifestTask struct { ID string `json:"id,omitempty"` // Unique ID Source string `json:"source,omitempty"` // ” -> @ = original file Target string `json:"target,omitempty"` // Name of file Type ObjectType `json:"type,omitempty"` // Target type Actions []*Action `json:"actions,omitempty"` // Applied to source before save to target When []string `json:"when,omitempty"` // Only if tasks are processed Required bool `json:"required,omitempty"` // If not required then task can`t be skipped and processin will ends with error }
ManifestTask file processing
func (*ManifestTask) IsLastAction ¶
func (task *ManifestTask) IsLastAction(action *Action, tester actionTester) bool
IsLastAction of some connverter
type ManifestTaskStage ¶
type ManifestTaskStage struct { Name string `json:"name,omitempty"` Tasks []*ManifestTask `json:"tasks,omitempty"` }
ManifestTaskStage file processing
func (*ManifestTaskStage) HasTask ¶
func (stage *ManifestTaskStage) HasTask(id string) bool
HasTask for target object in the manifest
func (*ManifestTaskStage) IsEmpty ¶
func (stage *ManifestTaskStage) IsEmpty() bool
IsEmpty manifest object
func (*ManifestTaskStage) PrepareInfo ¶
func (stage *ManifestTaskStage) PrepareInfo()
PrepareInfo of the manifest stage
func (*ManifestTaskStage) TaskByID ¶
func (stage *ManifestTaskStage) TaskByID(id string) *ManifestTask
TaskByID returns the task with ID
func (*ManifestTaskStage) TaskByTarget ¶
func (stage *ManifestTaskStage) TaskByTarget(name string) *ManifestTask
TaskByTarget name of result
type Meta ¶
type Meta struct { Main ItemMeta `json:"main"` Tasks []*MetaTaskInfo `json:"tasks,omitempty"` // List of complete actions Items []*ItemMeta `json:"items,omitempty"` Tags []string `json:"tags,omitempty"` Params map[string][]string `json:"params,omitempty"` ManifestVersion string `json:"manifest_version,omitempty"` CreatedAt time.Time `json:"created_at,omitempty"` UpdatedAt time.Time `json:"updated_at,omitempty"` }
Meta information of the file object
func (*Meta) CleanSubItems ¶
func (m *Meta) CleanSubItems()
CleanSubItems information from the object
func (*Meta) Complete ¶
func (m *Meta) Complete(itemMeta *ItemMeta, task *ManifestTask, err error)
Complete marks action as complete
func (*Meta) ErrorTaskCount ¶
ErrorTaskCount returns count of tasks which returns the error
func (*Meta) ExcessItems ¶
ExcessItems returns the list of items which is not present in the Manifest
func (*Meta) IsComplete ¶
IsComplete manifest processed
func (*Meta) IsCompleteTask ¶
func (m *Meta) IsCompleteTask(task *ManifestTask) bool
IsCompleteTask returns complition status of the task
func (*Meta) IsConsistent ¶
IsConsistent meta-information and manifest state
func (*Meta) IsProcessingComplete ¶
IsProcessingComplete with any status
func (*Meta) IsProcessingCompleteTask ¶
func (m *Meta) IsProcessingCompleteTask(task *ManifestTask, maxRetries ...int) bool
IsProcessingCompleteTask returns finished complition status of the task
func (*Meta) ItemByName ¶
ItemByName returns subfile information
func (*Meta) RemoveExcessTasks ¶
RemoveExcessTasks from the meta object
func (*Meta) RemoveItemByName ¶
RemoveItemByName meta information about item
func (*Meta) RemoveTaskByID ¶
RemoveTaskByID meta information about task
type MetaTaskInfo ¶
type MetaTaskInfo struct { ID string `json:"id"` Attempts int `json:"attempts,omitempty"` Status ObjectStatus `json:"status,omitempty"` StatusMessage string `json:"status_message,omitempty"` TargetItemName string `json:"target_item_name,omitempty"` UpdatedAt time.Time `json:"updated_at,omitempty"` }
MetaTaskInfo contains information of one action item
type Object ¶
type Object struct { ID string `json:"id" gorm:"primary_key"` // Unical ID in storage Bucket string `json:"bucket"` Path string `json:"path"` HashID string `json:"hashid" gorm:"index:hashid;column:hashid"` Status ObjectStatus `json:"status"` StatusMessage string `json:"status_message,omitempty"` ContentType string `json:"content_type"` Type ObjectType `json:"type"` Tags gosql.NullableJSONArray[string] `json:"tags,omitempty"` Meta gosql.NullableJSON[Meta] `json:"meta,omitempty"` Manifest gosql.NullableJSON[Manifest] `json:"manifest,omitempty"` Size uint64 `json:"size"` // Size in bytes CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at"` }
Object structure which describes the paticular file attached to advertisement Image advertisement: Title=Image title, Description=My description
ID, Bucket, path, HashID, size, type, content_type, meta File: 1, 'image', 'images/a/c', dhg321h3ndp43u2hfc, 64322, image, image/jpeg, {"width": 300, "height": 250} File: 2, 'image', 'images/a/c', xxg321h3xxx43u2hfc, 44322, video, video/x-mp4, {"width": 300, "height": 250, "duration": 11132ms}
func (*Object) IncompleteTasks ¶
func (o *Object) IncompleteTasks() (resp []*ManifestTask)
IncompleteTasks returns the list of incompleted tasks
func (*Object) PathByName ¶
PathByName returns the full path to the item
type ObjectStatus ¶
type ObjectStatus string
ObjectStatus of the object operation
const ( StatusUndefined ObjectStatus = "undefined" StatusProcessing ObjectStatus = "processing" StatusOK ObjectStatus = "ok" // If processing finished StatusError ObjectStatus = "error" StatusNotFound ObjectStatus = "not-found" )
Status list
func StatusFromString ¶
func StatusFromString(st string) ObjectStatus
StatusFromString converts string to status type
func (ObjectStatus) Improtant ¶
func (s ObjectStatus) Improtant(status2 ObjectStatus) ObjectStatus
Improtant returns more significant status one of two
func (ObjectStatus) IsProcessed ¶
func (s ObjectStatus) IsProcessed() bool
IsProcessed status complition
func (ObjectStatus) IsProcessing ¶
func (s ObjectStatus) IsProcessing() bool
IsProcessing status complition
func (ObjectStatus) String ¶
func (s ObjectStatus) String() string
type ObjectType ¶
type ObjectType string
ObjectType of object
const ( TypeUndefined ObjectType = "undefined" TypeVideo ObjectType = "video" TypeImage ObjectType = "image" TypeAudio ObjectType = "audio" TypeHTMLArchType ObjectType = "htmlarch" TypeOther ObjectType = "other" )
Object types...
func ObjectTypeByContentType ¶
func ObjectTypeByContentType(contentType string) ObjectType
ObjectTypeByContentType value
func ObjectTypesByContentType ¶
func ObjectTypesByContentType(contentTypes ...string) (list []ObjectType)
ObjectTypesByContentType value list
func (ObjectType) String ¶
func (t ObjectType) String() string