Documentation ¶
Index ¶
- Variables
- type ByCreatedAt
- type DB
- type DatastoreClient
- type DatastoreDatabase
- func (d *DatastoreDatabase) DeleteJob(id string) error
- func (d *DatastoreDatabase) GetJob(id string) (*Job, error)
- func (d *DatastoreDatabase) GetJobByProviderID(providerID string) (*Job, error)
- func (d *DatastoreDatabase) GetJobs(parentID string) ([]Job, error)
- func (d *DatastoreDatabase) StoreJob(job *Job) (string, error)
- func (d *DatastoreDatabase) UpdateJob(id string, job *Job) error
- type Job
- type JobOutput
- type JobSummary
- type MemoryDatabase
- func (db *MemoryDatabase) DeleteJob(id string) error
- func (db *MemoryDatabase) GetJob(id string) (*Job, error)
- func (db *MemoryDatabase) GetJobByProviderID(providerID string) (*Job, error)
- func (db *MemoryDatabase) GetJobs(parentID string) ([]Job, error)
- func (db *MemoryDatabase) StoreJob(job *Job) (string, error)
- func (db *MemoryDatabase) UpdateJob(id string, job *Job) error
- type ProviderJob
- type ProviderParams
- type UploadedFile
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNoJobs indicates that no jobs can be found for a given parent ID. ErrNoJobs = errors.New("no jobs found with this parent ID") // ErrJobNotFound indicates that no job can be found for a given job ID. ErrJobNotFound = errors.New("job not found") )
Functions ¶
This section is empty.
Types ¶
type ByCreatedAt ¶
type ByCreatedAt []Job
ByCreatedAt implements sort.Interface for []Job by CreatedAt field.
func (ByCreatedAt) Len ¶
func (b ByCreatedAt) Len() int
func (ByCreatedAt) Less ¶
func (b ByCreatedAt) Less(i, j int) bool
func (ByCreatedAt) Swap ¶
func (b ByCreatedAt) Swap(i, j int)
type DB ¶
type DB interface { StoreJob(*Job) (string, error) UpdateJob(string, *Job) error GetJob(string) (*Job, error) DeleteJob(string) error GetJobs(string) ([]Job, error) GetJobByProviderID(string) (*Job, error) }
DB interface for database interactions
type DatastoreClient ¶
type DatastoreClient interface { Put(context.Context, *datastore.Key, interface{}) (*datastore.Key, error) Get(context.Context, *datastore.Key, interface{}) error Delete(context.Context, *datastore.Key) error GetAll(context.Context, *datastore.Query, interface{}) ([]*datastore.Key, error) }
DatastoreClient is a datastore interface with operations used by the captions API
type DatastoreDatabase ¶
type DatastoreDatabase struct {
// contains filtered or unexported fields
}
DatastoreDatabase is a datastore client that implements DB interface
func NewDatastoreDatabase ¶
func NewDatastoreDatabase(projectID string) (*DatastoreDatabase, error)
NewDatastoreDatabase returns a DatastoreDatabase
func (*DatastoreDatabase) DeleteJob ¶
func (d *DatastoreDatabase) DeleteJob(id string) error
DeleteJob deletes a job from database
func (*DatastoreDatabase) GetJob ¶
func (d *DatastoreDatabase) GetJob(id string) (*Job, error)
GetJob retrieves a job from database
func (*DatastoreDatabase) GetJobByProviderID ¶
func (d *DatastoreDatabase) GetJobByProviderID(providerID string) (*Job, error)
GetJobByProviderID returns a job associated with a given provider ID
func (*DatastoreDatabase) GetJobs ¶
func (d *DatastoreDatabase) GetJobs(parentID string) ([]Job, error)
GetJobs retrieves all jobs in database
type Job ¶
type Job struct { ID string `json:"id"` ParentID string `json:"parent_id"` MediaURL string `json:"media_url"` Status string `json:"status"` Provider string `json:"provider"` ProviderParams ProviderParams `json:"provider_params"` CreatedAt time.Time `json:"created_at"` Outputs []JobOutput `json:"outputs"` Done bool `json:"done"` Language string `json:"language"` Details string `json:"details,omitempty"` CaptionFile UploadedFile `json:"caption_file,omitempty"` JobType string `json:"job_type"` }
Job representation of a captions job
func (*Job) GetProviderID ¶
func (*Job) UpdateStatus ¶
UpdateStatus update Job status and mark as done if needed
type JobOutput ¶
type JobOutput struct { URL string `json:"url"` Type string `json:"type"` Filename string `json:"filename"` }
JobOutput output associated with a Job
type JobSummary ¶
JobSummary minimal information about a Job
type MemoryDatabase ¶
type MemoryDatabase struct {
// contains filtered or unexported fields
}
MemoryDatabase memory based database implementation for the DB interface
func NewMemoryDatabase ¶
func NewMemoryDatabase() *MemoryDatabase
NewMemoryDatabase creates a MemoryDatabase
func (*MemoryDatabase) DeleteJob ¶
func (db *MemoryDatabase) DeleteJob(id string) error
DeleteJob deletes a Job given its ID
func (*MemoryDatabase) GetJob ¶
func (db *MemoryDatabase) GetJob(id string) (*Job, error)
GetJob returns a Job given its ID
func (*MemoryDatabase) GetJobByProviderID ¶
func (db *MemoryDatabase) GetJobByProviderID(providerID string) (*Job, error)
GetJobByProviderID Returns returns a job matching the ProviderID
func (*MemoryDatabase) GetJobs ¶
func (db *MemoryDatabase) GetJobs(parentID string) ([]Job, error)
GetJobs Returns all Jobs stored for the same ParentID
type ProviderJob ¶
type ProviderJob struct { ID string Status string Details string Params map[string]string Cancellable bool }
ProviderJob holds data coming from a Provider
type ProviderParams ¶
ProviderParams is a set of parameters for providers
type UploadedFile ¶
type UploadedFile struct { File []byte `json:"file" datastore:",noindex"` Name string `json:"name"` }
UploadedFile contains the uploaded file and its name