queue

package
v0.0.0-...-aefcfe0 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2022 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// StatusPending represents
	StatusPending = "Pending"
	// StatusFailed is a failed status
	StatusFailed = "Failed"
	// StatusCompleted is a completed status
	StatusCompleted = "Completed"
	// VerificationUnitName represents a task that should not be signed but verified
	VerificationUnitName = "VerificationUnitName"
)

Functions

This section is empty.

Types

type Job

type Job struct {
	// ID represents id of the job
	ID string `json:"id"`
	// TasksMap represents tasks added to the job
	TasksMap map[string]Task `json:"task_map"`
	// totalProcessedTasks represents total processed tasks of the job, incremented atomically
	TotalProcesedTasks uint32 `json:"total_procesed_tasks"`
	// JobSignConfig represents additional sign data added by request to override signer initial sign data
	SignConfig JobSignConfig `json:"sign_data"`
}

Job represents a job for sign queue, stores tasks and sign data to override units initial sign data

func (*Job) GetTasks

func (j *Job) GetTasks(status string) ([]Task, error)

GetTasks returns all the completed tasks if status is empty string, and only tasks with specific status if status is provided

type JobSignConfig

type JobSignConfig struct {
	// sign data
	Signer      string `json:"signer"`
	Name        string `json:"name"`
	Location    string `json:"location"`
	Reason      string `json:"reason"`
	ContactInfo string `json:"contact_info"`
	CertType    uint   `json:"cert_type"`
	DocMDPPerms uint   `json:"doc_mdp_perms"`
	// ValidateSignature allows to verify the job after it's being singed
	ValidateSignature bool `json:"verify_after_sign"`
}

type Queue

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

Queue represents sign queue

func NewQueue

func NewQueue() *Queue

NewQueue creates new sign queue

func (*Queue) AddBatchPersistentTasks

func (q *Queue) AddBatchPersistentTasks(unitName, jobID string, fileNames map[string]string, priority priority_queue.Priority) error

func (*Queue) AddSignJob

func (q *Queue) AddSignJob(signConfig JobSignConfig) string

AddSignJob adds sign job to the jobs map

func (*Queue) AddSignUnit

func (q *Queue) AddSignUnit(unitName string, signData signer.SignData)

AddSignUnit adds signer unit to units map

func (*Queue) AddTask

func (q *Queue) AddTask(unitName, jobID, originalFileName, inputFilePath, outputFilePath string, priority priority_queue.Priority) (string, error)

AddTask adds task to the specific job by job id

func (*Queue) AddVerifyJob

func (q *Queue) AddVerifyJob() string

AddVerifyJob adds sign job to the jobs map

func (*Queue) AddVerifyUnit

func (q *Queue) AddVerifyUnit()

AddVerifyUnit adds verify unit to units map

func (*Queue) DeleteFromDB

func (q *Queue) DeleteFromDB(jobID string) error

func (*Queue) DeleteJob

func (q *Queue) DeleteJob(jobID string) error

DeleteJob deletes job from the jobs and database

func (*Queue) GetCompletedTask

func (q *Queue) GetCompletedTask(jobID, taskID string) (Task, error)

GetCompletedTask returns the file path if the task is completed

func (*Queue) GetJobByID

func (q *Queue) GetJobByID(jobID string) (Job, error)

func (*Queue) GetQueueSizeByUnitName

func (q *Queue) GetQueueSizeByUnitName(signerName string) (priority_queue.LenAll, error)

GetQueueSizeByUnitName returns lengths of the channels of all the priorities for the specific signer.

func (*Queue) LoadFromDB

func (q *Queue) LoadFromDB() error

func (*Queue) SaveToDB

func (q *Queue) SaveToDB(jobID string) error

func (*Queue) StartProcessor

func (q *Queue) StartProcessor()

StartProcessor starts separate go routine for each signer which signs associated job tasks when they appear

type Task

type Task struct {
	// ID represents id of the task
	ID string `json:"id"`
	// JobID represents id of the job task is assigned to
	JobID string `json:"job_id"`
	// OriginalFileName represents pdf file name
	OriginalFileName string `json:"original_file_name"`
	// InputFilePath represents path to the unprocessed file
	InputFilePath string `json:"input_file_path"`
	// OutputFilePath represents path to the processed file
	OutputFilePath string `json:"output_file_path"`
	// Status represents the status of the task. Pending, Failed, Completed.
	Status string `json:"status"`
	// VerificationData represents data of the verification
	VerificationData *verify.Response `json:"verification_data,omitempty"`
	// Error represents error if the task failed
	Error string `json:"error,omitempty"`
}

Task represents a single unit of work(file)

Jump to

Keyboard shortcuts

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