Documentation
¶
Index ¶
- Variables
- func DumpErrors()
- func GetFirstAttribute(attributed Attributed, key string) (string, error)
- func NewGeneratedAssetError(err *codederror.CodedError) string
- func SourceAssetSource(sourceAsset *SourceAsset) string
- type AmazonS3Client
- func (client *AmazonS3Client) Delete(bucket, file string) error
- func (client *AmazonS3Client) Get(bucket, file string) (S3Object, error)
- func (client *AmazonS3Client) NewObject(name, bucket, contentType string) (S3Object, error)
- func (client *AmazonS3Client) Put(s3object S3Object, content []byte) error
- type AmazonS3ClientConfig
- type AmazonS3Object
- type Attribute
- type Attributed
- type CassandraManager
- type Downloader
- type GeneratedAsset
- type GeneratedAssetStorageManager
- type Placeholder
- type PlaceholderManager
- type S3Client
- type S3Object
- type SourceAsset
- type SourceAssetStorageManager
- type Template
- type TemplateManager
- type TemporaryFile
- type TemporaryFileManager
- type Uploader
Constants ¶
This section is empty.
Variables ¶
var ( // GeneratedAssetStatusWaiting is the initial, unprocessed state of a generated asset. GeneratedAssetStatusWaiting = "waiting" // GeneratedAssetStatusScheduled is the state of a generated asset that indicates that it has been scheduled for processing but processing has not yet begun. GeneratedAssetStatusScheduled = "scheduled" // GeneratedAssetStatusProcessing is the state of a generated asset that indicates that processing has begun. GeneratedAssetStatusProcessing = "processing" // GeneratedAssetStatusComplete is the state of a generated asset that indicates that processing has completed. GeneratedAssetStatusComplete = "complete" // GeneratedAssetStatusFailed is the state of a generated asset that indicates that processing has completed, but failed. This value is just a prefix and is accompanied by a coded error. GeneratedAssetStatusFailed = "failed" // DefaultGeneratedAssetStatus is the default state of a generated asset when it is created. DefaultGeneratedAssetStatus = GeneratedAssetStatusWaiting // SourceAssetAttributeSource is a constant for the source attribute that can be set for source assets. SourceAssetAttributeSource = "source" // SourceAssetAttributeType is a constant for the type attribute that can be set for source assets. SourceAssetAttributeType = "type" // SourceAssetAttributeSize is a constant for the size attribute that can be set for source assets. SourceAssetAttributeSize = "size" // SourceAssetAttributePages is a constant for the pages attribute that can be set for source assets. SourceAssetAttributePages = "pages" // GeneratedAssetAttributePage is a constant for the page attribute that can be set for generated assets. GeneratedAssetAttributePage = "page" // SourceAssetTypeOrigin is a constant that represents origin types for source assets. SourceAssetTypeOrigin = "origin" // SourceAssetTypePdf is a constant that represents a generated PDF type for source assets. SourceAssetTypePdf = "pdf" )
var ( ErrorNotImplemented = codederror.NewCodedError([]string{"PRV", "COM"}, 1) ErrorSourceAssetExpired = codederror.NewCodedError([]string{"PRV", "COM"}, 2) ErrorNoRenderersSupportFileType = codederror.NewCodedError([]string{"PRV", "COM"}, 3) ErrorFileTooLarge = codederror.NewCodedError([]string{"PRV", "COM"}, 4) ErrorNoDownloadUrlsWork = codederror.NewCodedError([]string{"PRV", "COM"}, 6) ErrorTooLittleWorkRequested = codederror.NewCodedError([]string{"PRV", "COM"}, 7) ErrorUnknownError = codederror.NewCodedError([]string{"PRV", "COM"}, 8) ErrorUnableToFindGeneratedAssetsById = codederror.NewCodedError([]string{"PRV", "COM"}, 9) ErrorNoGeneratedAssetsFoundForId = codederror.NewCodedError([]string{"PRV", "COM"}, 10) ErrorUnableToFindSourceAssetsById = codederror.NewCodedError([]string{"PRV", "COM"}, 11) ErrorNoSourceAssetsFoundForId = codederror.NewCodedError([]string{"PRV", "COM"}, 12) ErrorUnableToFindTemplatesById = codederror.NewCodedError([]string{"PRV", "COM"}, 13) ErrorNoTemplatesFoundForId = codederror.NewCodedError([]string{"PRV", "COM"}, 14) ErrorCouldNotDetermineRenderSize = codederror.NewCodedError([]string{"PRV", "COM"}, 15) ErrorCouldNotResizeImage = codederror.NewCodedError([]string{"PRV", "COM"}, 16) ErrorCouldNotUploadAsset = codederror.NewCodedError([]string{"PRV", "COM"}, 17) ErrorS3FileNotFound = codederror.NewCodedError([]string{"PRV", "COM"}, 18) ErrorCouldNotDetermineFileSize = codederror.NewCodedError([]string{"PRV", "COM"}, 19) ErrorNoTemplateForId = codederror.NewCodedError([]string{"PRV", "COM"}, 20) ErrorTemplateHeightAttributeMissing = codederror.NewCodedError([]string{"PRV", "COM"}, 21) ErrorGeneratedAssetCouldNotBeUpdated = codederror.NewCodedError([]string{"PRV", "COM"}, 22) ErrorUploaderDoesNotSupportUrl = codederror.NewCodedError([]string{"PRV", "COM"}, 23) ErrorInvalidFileId = codederror.NewCodedError([]string{"PRV", "COM"}, 24) ErrorMissingFieldType = codederror.NewCodedError([]string{"PRV", "COM"}, 25) ErrorMissingFieldUrl = codederror.NewCodedError([]string{"PRV", "COM"}, 26) ErrorMissingFieldSize = codederror.NewCodedError([]string{"PRV", "COM"}, 27) ErrorCouldNotDetermineFileType = codederror.NewCodedError([]string{"PRV", "COM"}, 28) AllErrors = []*codederror.CodedError{ ErrorNotImplemented, ErrorSourceAssetExpired, ErrorNoRenderersSupportFileType, ErrorFileTooLarge, ErrorNoDownloadUrlsWork, ErrorTooLittleWorkRequested, ErrorUnknownError, ErrorUnableToFindGeneratedAssetsById, ErrorNoGeneratedAssetsFoundForId, ErrorUnableToFindSourceAssetsById, ErrorNoSourceAssetsFoundForId, ErrorUnableToFindTemplatesById, ErrorNoTemplatesFoundForId, ErrorCouldNotDetermineRenderSize, ErrorCouldNotResizeImage, ErrorCouldNotUploadAsset, ErrorS3FileNotFound, ErrorCouldNotDetermineFileSize, ErrorNoTemplateForId, ErrorTemplateHeightAttributeMissing, ErrorGeneratedAssetCouldNotBeUpdated, ErrorUploaderDoesNotSupportUrl, ErrorInvalidFileId, ErrorMissingFieldType, ErrorMissingFieldUrl, ErrorMissingFieldSize, } )
var ( PlaceholderSizeJumbo = "jumbo" PlaceholderSizeLarge = "large" PlaceholderSizeMedium = "medium" PlaceholderSizeSmall = "small" DefaultPlaceholderSizes = []string{PlaceholderSizeJumbo, PlaceholderSizeLarge, PlaceholderSizeMedium, PlaceholderSizeSmall} DefaultPlaceholderType = "unknown" )
var ( RenderAgentImageMagick = "renderAgentImageMagick" RenderAgentDocument = "renderAgentDocument" RenderAgents = []string{RenderAgentImageMagick, RenderAgentDocument} )
var ( LegacyDefaultTemplates = []string{ "04a2c710-8872-4c88-9c75-a67175d3a8e7", "2eee7c27-75e2-4682-9920-9a4e14caa433", "a89a6a0d-51d9-4d99-b278-0c5dfc538984", "eaa7be0e-354f-482c-ac75-75cbdafecb6e", } DefaultTemplateJumbo = &Template{ "04a2c710-8872-4c88-9c75-a67175d3a8e7", RenderAgentImageMagick, "4C96", []Attribute{ Attribute{TemplateAttributeWidth, []string{"1040"}}, Attribute{TemplateAttributeHeight, []string{"780"}}, Attribute{TemplateAttributeOutput, []string{"jpg"}}, Attribute{TemplateAttributePlaceholderSize, []string{PlaceholderSizeJumbo}}, }, } DefaultTemplateLarge = &Template{ "2eee7c27-75e2-4682-9920-9a4e14caa433", RenderAgentImageMagick, "4C96", []Attribute{ Attribute{TemplateAttributeWidth, []string{"520"}}, Attribute{TemplateAttributeHeight, []string{"390"}}, Attribute{TemplateAttributeOutput, []string{"jpg"}}, Attribute{TemplateAttributePlaceholderSize, []string{PlaceholderSizeLarge}}, }, } DefaultTemplateMedium = &Template{ "a89a6a0d-51d9-4d99-b278-0c5dfc538984", RenderAgentImageMagick, "4C96", []Attribute{ Attribute{TemplateAttributeWidth, []string{"500"}}, Attribute{TemplateAttributeHeight, []string{"376"}}, Attribute{TemplateAttributeOutput, []string{"jpg"}}, Attribute{TemplateAttributePlaceholderSize, []string{PlaceholderSizeMedium}}, }, } DefaultTemplateSmall = &Template{ "eaa7be0e-354f-482c-ac75-75cbdafecb6e", RenderAgentImageMagick, "4C96", []Attribute{ Attribute{TemplateAttributeWidth, []string{"250"}}, Attribute{TemplateAttributeHeight, []string{"188"}}, Attribute{TemplateAttributeOutput, []string{"jpg"}}, Attribute{TemplateAttributePlaceholderSize, []string{PlaceholderSizeSmall}}, }, } DocumentConversionTemplate = &Template{ "9B17C6CE-7B09-4FD5-92AD-D85DD218D6D7", RenderAgentDocument, "A907", []Attribute{ Attribute{TemplateAttributeOutput, []string{"pdf"}}, }, } DocumentConversionTemplateId = "9B17C6CE-7B09-4FD5-92AD-D85DD218D6D7" // TemplateAttributeHeight is a constant for the height attribute that can be set for templates. TemplateAttributeHeight = "height" // TemplateAttributeWidth is a constant for the width attribute that can be set for templates. TemplateAttributeWidth = "width" // TemplateAttributeOutput is a constant for the output attribute that can be set for templates. TemplateAttributeOutput = "output" // TemplateAttributePlaceholderSize is a constant for the placeholderSize attribute that can be set for templates. TemplateAttributePlaceholderSize = "placeholderSize" )
Functions ¶
func GetFirstAttribute ¶
func GetFirstAttribute(attributed Attributed, key string) (string, error)
func NewGeneratedAssetError ¶
func NewGeneratedAssetError(err *codederror.CodedError) string
NewGeneratedAssetError returns a correctly formatted error string for generated asset storage manager storage.
func SourceAssetSource ¶
func SourceAssetSource(sourceAsset *SourceAsset) string
Types ¶
type AmazonS3Client ¶
type AmazonS3Client struct {
// contains filtered or unexported fields
}
func (*AmazonS3Client) Delete ¶
func (client *AmazonS3Client) Delete(bucket, file string) error
func (*AmazonS3Client) Get ¶
func (client *AmazonS3Client) Get(bucket, file string) (S3Object, error)
type AmazonS3ClientConfig ¶
type AmazonS3ClientConfig struct {
// contains filtered or unexported fields
}
func NewBasicS3Config ¶
func NewBasicS3Config(key, secret, host string) *AmazonS3ClientConfig
type AmazonS3Object ¶
type AmazonS3Object struct {
// contains filtered or unexported fields
}
func (*AmazonS3Object) Bucket ¶
func (s3obj *AmazonS3Object) Bucket() string
func (*AmazonS3Object) ContentType ¶
func (s3obj *AmazonS3Object) ContentType() string
func (*AmazonS3Object) FileName ¶
func (s3obj *AmazonS3Object) FileName() string
func (*AmazonS3Object) Payload ¶
func (s3obj *AmazonS3Object) Payload() []byte
func (*AmazonS3Object) Url ¶
func (s3obj *AmazonS3Object) Url() string
type Attribute ¶
Attribute is simply a key/value pair container used by source assets, generated assets and templates.
type Attributed ¶
type Attributed interface { // AddAttribute adds key and array of values to the structure. AddAttribute(name string, value []string) Attribute // HasAttribute returns true if the structure has a given attribute, false if otherwise. HasAttribute(name string) bool // GetAttribute retuirns the values for the given attribute. GetAttribute(key string) []string }
Attributed structures have internal attributes that can be manipulated.
type CassandraManager ¶
type CassandraManager struct {
// contains filtered or unexported fields
}
func NewCassandraManager ¶
func NewCassandraManager(hosts []string, keyspace string) (*CassandraManager, error)
func (*CassandraManager) Session ¶
func (cm *CassandraManager) Session() *gocql.Session
func (*CassandraManager) Stop ¶
func (cm *CassandraManager) Stop()
type Downloader ¶
type Downloader interface { // Download attempts to retreive a file with a given url and store it to a temporary file that is managed by a TemporaryFileManager. Download(url, source string) (TemporaryFile, error) }
Downloader structures retreive remote files and make them available locally.
func NewDownloader ¶
func NewDownloader(basePath, localStoragePath string, tfm TemporaryFileManager, tramEnabled bool, tramHosts []string) Downloader
NewDownloader creates, configures and returns a new defaultDownloader.
type GeneratedAsset ¶
type GeneratedAsset struct { Id string SourceAssetId string SourceAssetType string TemplateId string Location string Status string CreatedAt int64 CreatedBy string UpdatedAt int64 UpdatedBy string Attributes []Attribute }
GeneratedAsset describes an asset that is generated by the system from a source asset.
func NewGeneratedAssetFromSourceAsset ¶
func NewGeneratedAssetFromSourceAsset(sourceAsset *SourceAsset, template *Template, location string) (*GeneratedAsset, error)
NewGeneratedAssetFromSourceAsset creates a new generated asset from a given source asset and template, filling in everything but location.
func (*GeneratedAsset) AddAttribute ¶
func (ga *GeneratedAsset) AddAttribute(name string, value []string) Attribute
func (*GeneratedAsset) GetAttribute ¶
func (ga *GeneratedAsset) GetAttribute(key string) []string
func (*GeneratedAsset) HasAttribute ¶
func (ga *GeneratedAsset) HasAttribute(name string) bool
func (*GeneratedAsset) Serialize ¶
func (ga *GeneratedAsset) Serialize() ([]byte, error)
func (*GeneratedAsset) String ¶
func (ga *GeneratedAsset) String() string
type GeneratedAssetStorageManager ¶
type GeneratedAssetStorageManager interface { Store(generatedAsset *GeneratedAsset) error Update(generatedAsset *GeneratedAsset) error FindById(id string) (*GeneratedAsset, error) FindByIds(ids []string) ([]*GeneratedAsset, error) FindBySourceAssetId(id string) ([]*GeneratedAsset, error) FindWorkForService(serviceName string, workCount int) ([]*GeneratedAsset, error) }
func NewCassandraGeneratedAssetStorageManager ¶
func NewCassandraGeneratedAssetStorageManager(cm *CassandraManager, templateManager TemplateManager, nodeId, keyspace string) (GeneratedAssetStorageManager, error)
func NewGeneratedAssetStorageManager ¶
func NewGeneratedAssetStorageManager(templateManager TemplateManager) GeneratedAssetStorageManager
type Placeholder ¶
type PlaceholderManager ¶
type PlaceholderManager interface { Url(fileType, placeholderSize string) *Placeholder AllFileTypes() []string }
func NewPlaceholderManager ¶
func NewPlaceholderManager(appConfig config.AppConfig) PlaceholderManager
type S3Client ¶
type S3Client interface { Put(s3object S3Object, content []byte) error Get(bucket, file string) (S3Object, error) Delete(bucket, file string) error NewObject(name, bucket, contentType string) (S3Object, error) }
func NewAmazonS3Client ¶
func NewAmazonS3Client(config *AmazonS3ClientConfig) S3Client
type S3Object ¶
type S3Object interface { FileName() string Bucket() string Url() string ContentType() string Payload() []byte }
func NewAmazonS3Object ¶
type SourceAsset ¶
type SourceAsset struct { Id string IdType string CreatedAt int64 CreatedBy string UpdatedAt int64 UpdatedBy string Attributes []Attribute }
SourceAsset describes an asset that is used as a source of data for generated assets.
func NewSourceAsset ¶
func NewSourceAsset(id, idType string) (*SourceAsset, error)
NewSourceAsset creates a new source asset, filling in default values for everything but the id, type and location.
func (*SourceAsset) AddAttribute ¶
func (sa *SourceAsset) AddAttribute(name string, value []string) Attribute
func (*SourceAsset) GetAttribute ¶
func (sa *SourceAsset) GetAttribute(key string) []string
func (*SourceAsset) HasAttribute ¶
func (sa *SourceAsset) HasAttribute(name string) bool
func (*SourceAsset) Serialize ¶
func (sa *SourceAsset) Serialize() ([]byte, error)
type SourceAssetStorageManager ¶
type SourceAssetStorageManager interface { Store(sourceAsset *SourceAsset) error FindBySourceAssetId(id string) ([]*SourceAsset, error) }
func NewCassandraSourceAssetStorageManager ¶
func NewCassandraSourceAssetStorageManager(cm *CassandraManager, nodeId, keyspace string) (SourceAssetStorageManager, error)
func NewSourceAssetStorageManager ¶
func NewSourceAssetStorageManager() SourceAssetStorageManager
type Template ¶
func (*Template) AddAttribute ¶
func (*Template) GetAttribute ¶
func (*Template) HasAttribute ¶
type TemplateManager ¶
type TemplateManager interface { Store(template *Template) error FindByIds(id []string) ([]*Template, error) FindByRenderService(renderService string) ([]*Template, error) }
func NewTemplateManager ¶
func NewTemplateManager() TemplateManager
type TemporaryFile ¶
type TemporaryFile interface { Path() string Release() }
type TemporaryFileManager ¶
type TemporaryFileManager interface { Notify(path string) Create(path string) TemporaryFile List() map[string]int }
func NewTemporaryFileManager ¶
func NewTemporaryFileManager() TemporaryFileManager