brucecore

package module
v0.0.0-...-b1ebb56 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2019 License: Apache-2.0 Imports: 24 Imported by: 0

README

brucecore

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildNoGZipTableData

func BuildNoGZipTableData(files []GZipFile) [][]string

BuildNoGZipTableData - build [][]string

func DistanceColor

func DistanceColor(c1 color.Color, c2 color.Color) float64

DistanceColor - count distance c1 and c2

func DistanceImg

func DistanceImg(fn1 string, fn2 string, mfn string) (image.Image, float64, error)

DistanceImg - distance image img1 and img2

func FormatByteSize

func FormatByteSize(bytesize int) string

FormatByteSize - 1025 => 1k1b

func FormatTime

func FormatTime(time int) string

FormatTime - 12345 => 1.235s

func GetHostname

func GetHostname(str string) (string, error)

GetHostname - https://www.a.com/b/c.png => www.a.com

func GetImageRectName

func GetImageRectName(w int, h int) string

GetImageRectName - (100, 50) => 100x50, (50, 100) => 100x50

func GetLightness

func GetLightness(fn string) (image.Image, float64, error)

GetLightness - get lightness and variance

func GetResType

func GetResType(res *jarviscrawlercore.AnalyzeReqInfo) (string, error)

GetResType - https://www.a.com/b/c.png => https

func GetResWithScheme

func GetResWithScheme(reqs []*jarviscrawlercore.AnalyzeReqInfo, scheme string) (
	[]string, error)

GetResWithScheme - get resource with scheme

func GetSaturation

func GetSaturation(fn string) (image.Image, float64, error)

GetSaturation - get saturation and variance

func GetScheme

func GetScheme(str string) (string, error)

GetScheme - https://www.a.com/b/c.png => https

func GetURLName

func GetURLName(url string) string

GetURLName - get URL name

func InitLogger

func InitLogger(cfg *Config)

InitLogger - init logger

func ToWebp

func ToWebp(fn string, Lossless bool, quality float32) ([]byte, error)

ToWebp - to webp

Types

type Config

type Config struct {

	// AdaCoreServAddr - Ada core service address
	AdaCoreServAddr string
	// AdaCoreToken - This is a valid adacoreserv token
	AdaCoreToken string

	// JarvisCrawlerServAddr - Jarvis Crawler service address
	JarvisCrawlerServAddr string
	// JarvisCrawlerToken - This is a valid jarviscrawler token
	JarvisCrawlerToken string

	// ClientTokens - There are the valid clienttokens for this node
	ClientTokens []string

	Log struct {
		// LogPath - log path
		LogPath string
		// LogLevel - log level, it can be debug, info, warn, error
		LogLevel string
		// LogConsole - it can be output to console
		LogConsole bool
	}
}

Config - config

func LoadConfig

func LoadConfig(filename string) (*Config, error)

LoadConfig - load config

func (*Config) HasToken

func (cfg *Config) HasToken(token string) bool

HasToken - has token

type GZipFile

type GZipFile struct {
	URL      string
	Size     int
	GZipSize int
}

GZipFile - gzip file infomation

func GetNoGZip

func GetNoGZip(reqs []*jarviscrawlercore.AnalyzeReqInfo) (
	[]GZipFile, error)

GetNoGZip - get no gzip resource

type HostnameInfo

type HostnameInfo struct {
	Hostname string
	IPs      []*IPGeoInfo
}

HostnameInfo - hostname infomation

func (*HostnameInfo) Insert

func (hi *HostnameInfo) Insert(ipaddr string, ipg *ipgeopb.IPGeo)

Insert - insert a SourceInfo

type HostnameList

type HostnameList struct {
	List []*HostnameInfo
}

HostnameList - hostname infomation list

func AnalyzeHostNameInfo

func AnalyzeHostNameInfo(ctx context.Context, ipgeodb *ipgeo.DB,
	reqs []*jarviscrawlercore.AnalyzeReqInfo) (*HostnameList, error)

AnalyzeHostNameInfo - analyze hostname

func (*HostnameList) Find

func (sl *HostnameList) Find(hostname string) *HostnameInfo

Find - find a SourceInfo

func (*HostnameList) Insert

func (sl *HostnameList) Insert(ctx context.Context, ipgeodb *ipgeo.DB, hostname string, ipaddr []string)

Insert - insert a SourceInfo

func (*HostnameList) ToData

func (sl *HostnameList) ToData() [][]string

ToData - to data

type IPGeoInfo

type IPGeoInfo struct {
	IPAddr string
	IPGeo  *ipgeopb.IPGeo
}

IPGeoInfo - ipgeo infomation

type Image

type Image struct {
	URL          string
	ImgType      string
	Width        int
	Height       int
	Size         int
	PixelQuality float32
}

Image - image

type ImageMgr

type ImageMgr struct {
	Imgs     []*Image
	TreeMap  []adacore.ChartTreeMapSeriesNodeFloat
	HostList []string
}

ImageMgr - image manager

func AnalyzeImageMgr

func AnalyzeImageMgr(reqs []*jarviscrawlercore.AnalyzeReqInfo) (*ImageMgr, error)

AnalyzeImageMgr - analyze image manager

func (*ImageMgr) Find

func (mgr *ImageMgr) Find(url string) *Image

Find - find a SourceInfo

func (*ImageMgr) Insert

func (mgr *ImageMgr) Insert(url string, imgtype string, bytes int, w int, h int)

Insert - insert a SourceInfo

type ImgTypeInfo

type ImgTypeInfo struct {
	ImgWidth   int
	ImgHeight  int
	TotalBytes int
	TotalTime  int
	TotalNums  int
}

ImgTypeInfo - image type infomation

type ResSourceData

type ResSourceData struct {
	ResSource     []string  `yaml:"source"`
	Bytes         []int     `yaml:"bytes"`
	MBytes        []float32 `yaml:"mbytes"`
	Time          []int     `yaml:"time"`
	Nums          []int     `yaml:"nums"`
	DownloadSpeed []float32 `yaml:"downloadspeed"`
}

ResSourceData - resource source data

type ResTreeMapData

type ResTreeMapData struct {
	TreeMap  []adacore.ChartTreeMapSeriesNode
	HostList []string
	// contains filtered or unexported fields
}

ResTreeMapData - resource treemap data

func AnalyzeResTreeMap

func AnalyzeResTreeMap(reqs []*jarviscrawlercore.AnalyzeReqInfo) (*ResTreeMapData, error)

AnalyzeResTreeMap - analyze request

type ResTypeData

type ResTypeData struct {
	ResType       []string  `yaml:"restype"`
	Bytes         []int     `yaml:"bytes"`
	MBytes        []float32 `yaml:"mbytes"`
	Time          []int     `yaml:"time"`
	Nums          []int     `yaml:"nums"`
	DownloadSpeed []float32 `yaml:"downloadspeed"`
	ImgType       []string  `yaml:"imgtype"`
	ImgBytes      []int     `yaml:"imgbytes"`
	ImgTime       []int     `yaml:"imgtime"`
	ImgNums       []int     `yaml:"imgnums"`
}

ResTypeData - resource type data

type ResTypeInfo

type ResTypeInfo struct {
	ResType    string
	TotalBytes int
	TotalTime  int
	TotalNums  int
}

ResTypeInfo - resource type infomation

type ResTypeMgr

type ResTypeMgr struct {
	List    []*ResTypeInfo
	ImgList []*ImgTypeInfo
}

ResTypeMgr - resource type infomation list

func AnalyzeResType

func AnalyzeResType(reqs []*jarviscrawlercore.AnalyzeReqInfo) (*ResTypeMgr, error)

AnalyzeResType - analyze request

func (*ResTypeMgr) Find

func (mgr *ResTypeMgr) Find(restype string) *ResTypeInfo

Find - find a SourceInfo

func (*ResTypeMgr) FindImage

func (mgr *ResTypeMgr) FindImage(w int, h int) *ImgTypeInfo

FindImage - find a image

func (*ResTypeMgr) Insert

func (mgr *ResTypeMgr) Insert(restype string, bytes int, time int)

Insert - insert a SourceInfo

func (*ResTypeMgr) InsertImage

func (mgr *ResTypeMgr) InsertImage(w int, h int, bytes int, time int)

InsertImage - insert a image

func (*ResTypeMgr) ToData

func (mgr *ResTypeMgr) ToData() *ResTypeData

ToData - SourceList => ResSourceData

type SourceInfo

type SourceInfo struct {
	Source     string
	TotalBytes int
	TotalTime  int
	TotalNums  int
}

SourceInfo - source infomation

type SourceList

type SourceList struct {
	List []*SourceInfo
}

SourceList - source infomation list

func AnalyzeResSource

func AnalyzeResSource(reqs []*jarviscrawlercore.AnalyzeReqInfo) (*SourceList, error)

AnalyzeResSource - analyze request

func (*SourceList) Find

func (sl *SourceList) Find(host string) *SourceInfo

Find - find a SourceInfo

func (*SourceList) Insert

func (sl *SourceList) Insert(host string, bytes int, time int)

Insert - insert a SourceInfo

func (*SourceList) ToData

func (sl *SourceList) ToData() *ResSourceData

ToData - SourceList => ResSourceData

Directories

Path Synopsis
samples

Jump to

Keyboard shortcuts

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