process

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2024 License: AGPL-3.0 Imports: 35 Imported by: 0

Documentation

Overview

* Virtualpaper is a service to manage users paper documents in virtual format. * Copyright (C) 2022 Tero Vierimaa * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <https://www.gnu.org/licenses/>.

Index

Constants

This section is empty.

Variables

View Source
var SupportedLanguages = map[string]string{
	"af": "Afrikaans",
	"sq": "Albanian",
	"ar": "Arabic",
	"hy": "Armenian",
	"az": "Azerbaijani",
	"eu": "Basque",
	"be": "Belarusian",
	"bn": "Bengali",
	"nb": "Bokmal",
	"bs": "Bosnian",
	"bg": "Bulgarian",
	"ca": "Catalan",
	"zh": "Chinese",
	"hr": "Croatian",
	"cs": "Czech",
	"da": "Danish",
	"nl": "Dutch",
	"en": "English",
	"eo": "Esperanto",
	"et": "Estonian",
	"fi": "Finnish",
	"fr": "French",
	"lg": "Ganda",
	"ka": "Georgian",
	"de": "German",
	"el": "Greek",
	"gu": "Gujarati",
	"he": "Hebrew",
	"hi": "Hindi",
	"hu": "Hungarian",
	"is": "Icelandic",
	"id": "Indonesian",
	"ga": "Irish",
	"it": "Italian",
	"ja": "Japanese",
	"kk": "Kazakh",
	"ko": "Korean",
	"la": "Latin",
	"lv": "Latvian",
	"lt": "Lithuanian",
	"mk": "Macedonian",
	"ms": "Malay",
	"mi": "Maori",
	"mr": "Marathi",
	"mn": "Mongolian",
	"nn": "Nynorsk",
	"fa": "Persian",
	"pl": "Polish",
	"pt": "Portuguese",
	"pa": "Punjabi",
	"rm": "Romanian",
	"ru": "Russian",
	"sr": "Serbian",
	"sn": "Shona",
	"sk": "Slovak",
	"sl": "Slovene",
	"so": "Somali",
	"st": "Sotho",
	"es": "Spanish",
	"sw": "Swahili",
	"sv": "Swedish",
	"tl": "Tagalog",
	"ta": "Tamil",
	"te": "Telugu",
	"th": "Thai",
	"ts": "Tsonga",
	"tn": "Tswana",
	"tr": "Turkish",
	"uk": "Ukrainian",
	"ur": "Urdu",
	"vi": "Vietnamese",
	"cy": "Welsh",
	"xh": "Xhosa",
	"yo": "Yoruba",
	"zu": "Zulu",
}

Functions

func DeleteDocument

func DeleteDocument(docId string) error

DeleteDocument deletes original document and its preview file.

func GetFileHash

func GetFileHash(file *os.File) (string, error)

GetFileHash returns unique hash for file. It uses md5 for hashing.

func GetHash

func GetHash(fileName string) (string, error)

GetHash returns hash for file by its name.

func GetImagickVersion

func GetImagickVersion() string

func GetPandocInstalled

func GetPandocInstalled() bool

func GetPdfToTextIsInstalled

func GetPdfToTextIsInstalled() bool

func GetTesseractVersion

func GetTesseractVersion() string

func MimeTypeFromName

func MimeTypeFromName(fileName string) string

func MimeTypeIsSupported

func MimeTypeIsSupported(mimetype, filename string) bool

MimeTypeIsSupported returns true if mime type or file ending is supported. Either one, or both, can be filled. If both are "", return false. If both are filled, return true if expected file ending matches argument. If either one is filled, return true if that is supported.

func RequiredProcessingSteps

func RequiredProcessingSteps(startingStep models.ProcessStep) []models.ProcessStep

RequiredProcessingSteps returns list of steps that are required to be execute after a given step.

func SupportedFileTypes

func SupportedFileTypes() (mimetypes []string, filetypes []string)

SupportedFileTypes returns a list of supported file endings.

Types

type DocumentRule

type DocumentRule struct {
	Rule     *models.Rule
	Document *models.Document
	// contains filtered or unexported fields
}

func NewDocumentRule

func NewDocumentRule(document *models.Document, rule *models.Rule) DocumentRule

func (*DocumentRule) Match

func (d *DocumentRule) Match() (bool, error)

func (*DocumentRule) MatchTest

func (d *DocumentRule) MatchTest() *RuleTestResult

run rule in test mode, logging all results

func (*DocumentRule) RunActions

func (d *DocumentRule) RunActions() error

type Manager

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

Manager manages multiple goroutines processing files.

func NewManager

func NewManager(database *storage.Database, search *search.Engine) (*Manager, error)

func (*Manager) AddDocumentForProcessing

func (m *Manager) AddDocumentForProcessing(docId string) error

AddDocumentForProcessing marks document as available for processing.

func (*Manager) ProcessingStatus

func (m *Manager) ProcessingStatus() []QueueStatus

func (*Manager) PullDocumentsToProcess

func (m *Manager) PullDocumentsToProcess()

func (*Manager) QueueFull

func (m *Manager) QueueFull() bool

func (*Manager) Start

func (m *Manager) Start() error

func (*Manager) Stop

func (m *Manager) Stop() error

type QueueStatus

type QueueStatus struct {
	TaskId               int    `json:"task_id"`
	QueueCapacity        int    `json:"queue_capacity"`
	Queued               int    `json:"queued"`
	ProcessingOngoing    bool   `json:"processing_ongoing"`
	ProcessingDocumentId string `json:"processing_document_id"`
	Running              bool   `json:"task_running"`
	DurationMs           int    `json:"duration_ms"`
}

type RuleTestAction

type RuleTestAction struct {
	ActionId   int    `json:"action_id"`
	ActionType string `json:"action_type"`
	Skipped    bool   `json:"skipped"`
}

type RuleTestConditionResult

type RuleTestConditionResult struct {
	ConditionId   int    `json:"condition_id"`
	ConditionType string `json:"condition_type"`
	Matched       bool   `json:"matched"`
	Skipped       bool   `json:"skipped"`
}

type RuleTestResult

type RuleTestResult struct {
	Conditions      []RuleTestConditionResult `json:"conditions"`
	Actions         []RuleTestAction          `json:"actions"`
	RuleId          int                       `json:"rule_id"`
	Match           bool                      `json:"matched"`
	TookMs          int                       `json:"took_ms"`
	Log             string                    `json:"log"`
	Error           string                    `json:"error"`
	StartedAt       int                       `json:"started_at"`
	StoppedAt       int                       `json:"stopped_at"`
	ConditionOutput [][]string                `json:"condition_output"`
	ActionOutput    [][]string                `json:"action_output"`
}

type Task

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

Task is a background worker. Define runFunc and run it with Start(). Task calls runFunc in a loop until Stop() is called. Task can communicate via report channel, which is up to user to set correctly.

func (*Task) Start

func (t *Task) Start() error

func (*Task) Stop

func (t *Task) Stop() error

type TaskReport

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

Jump to

Keyboard shortcuts

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