models

package
v1.1.4 Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	URL          LinkType = "URL"
	Email                 = "Email"
	InternalLink          = "InternalLink"
)

const - Enum to determine the type of link

Variables

This section is empty.

Functions

This section is empty.

Types

type FileProcessor added in v1.1.0

type FileProcessor interface {
	ProcessFile()
}

FileProcessor - process a single file, get links and check them

func GetNewFileProcessor added in v1.1.0

func GetNewFileProcessor(filePath string, resultChan chan *LinkResult) FileProcessor

GetNewFileProcessor - get instance of file processor

type FileResultData added in v1.1.0

type FileResultData struct {
	FilePath string
	Error    bool
	Links    []*LinkResult
}

FileResultData - contains all file links and their data

type FilesProcessor

type FilesProcessor interface {
	Process(files []string) error
}

FilesProcessor - process multiple files either parallel or one by one

func GetFilesProcessorInstance

func GetFilesProcessorInstance() FilesProcessor

GetFilesProcessorInstance - get instance of files processor (Singleton)

type LinkHandlerInterface added in v1.1.0

type LinkHandlerInterface interface {
	Handle(linkPath string) int
}

LinkHandlerInterface - interface to define different link handlers

func GetEmailHandlerInstance

func GetEmailHandlerInstance() LinkHandlerInterface

GetEmailHandlerInstance Get email handler instance

func GetInternalLinkHandler added in v1.1.0

func GetInternalLinkHandler(filePath string) LinkHandlerInterface

GetInternalLinkHandler - handles internal links

func GetURLHandlerInstance

func GetURLHandlerInstance() LinkHandlerInterface

GetURLHandlerInstance - get instance of URL handler, handle links with http in them (singleton)

type LinkProcessor added in v1.1.0

type LinkProcessor interface {
	CheckLink(filePath string, linkPath string, lineNumber int) *LinkResult
	ExtractLinks(fileData string) []*linkPath
}

LinkProcessor - process a single link, sends it to handler according to its type

func GetLinkProcessorInstance added in v1.1.0

func GetLinkProcessorInstance() LinkProcessor

GetLinkProcessorInstance - get instance of link processor

type LinkResult

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

LinkResult - a descriptor which contains data for a single link

type LinkType

type LinkType string

LinkType - 4 types of links we currently have url/email/file

type Result

type Result struct {
	FilesLinksMap map[string]*FileResultData

	Channel chan *LinkResult
	// contains filtered or unexported fields
}

Result - a result for an entire run use channel to get results

func (*Result) AddNewFile

func (res *Result) AddNewFile(fileLink *FileResultData)

AddNewFile - add new file to the FileLinksMap to be saved as part of the results

func (*Result) Close

func (res *Result) Close()

Close = close the channel when we are done with all results.

func (*Result) Print

func (res *Result) Print() error

Print - print and return the results and return the errors we received

Jump to

Keyboard shortcuts

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