search

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2024 License: MIT Imports: 33 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultChunkSize is the default value for the ChunkSize option
	DefaultChunkSize = 1024

	// DefaultMaxBufferSize is the default value for the MaxBufferSize option
	DefaultMaxBufferSize = 1 << 20 // 1 MB
)
View Source
const (
	InnerKeyContainer = "_container"
	InnerKeyFile      = "_file"
	InnerKeyNamespace = "_namespace"
	InnerKeyPod       = "_pod"
)
View Source
const (
	KB = 1024
	MB = 1024 * KB
	GB = 1024 * MB

	PARTITION_MAX_SIZE = 4 * MB
	PARTITION_MAX_NUM  = 10
)
View Source
const (
	SkipPath = "clickvisual"
)

Variables

View Source
var (
	// ErrLongLine indicates that the line is longer than the internal buffer size
	ErrLongLine = errors.New("line too long")
)
View Source
var SkipKeys = map[string]interface{}{
	InnerKeyContainer: struct{}{},
	InnerKeyFile:      struct{}{},
	InnerKeyNamespace: struct{}{},
	InnerKeyPod:       struct{}{},
}

Functions

func ChartsIntervalConvert

func ChartsIntervalConvert(interval int64) (standard int64)

func Run

func Run(req Request) (data view.RespAgentSearch, err error)

func RunCharts

func RunCharts(req Request) (resp view.RespAgentChartsSearch, err error)

func TrimKeyWord

func TrimKeyWord(keyWord string) string

Types

type Bash

type Bash struct {
	White   func(a ...interface{}) string
	Yellow  func(a ...interface{}) string
	Blue    func(a ...interface{}) string
	Green   func(a ...interface{}) string
	HiWrite func(a ...interface{}) string
	HiRed   func(a ...interface{}) string
}

func NewBash

func NewBash() *Bash

func (*Bash) ColorAll

func (b *Bash) ColorAll(line string) string

func (*Bash) ColorWord

func (b *Bash) ColorWord(word, line string) string

type CmdRequest

type CmdRequest struct {
	StartTime    string
	EndTime      string
	Date         string // last 30min,6h,1d,7d
	Path         string // 文件路径
	Dir          string // 文件夹路径
	KeyWord      string // 搜索的关键词
	Limit        int64  // 最少多少条数据
	IsK8S        bool
	K8SContainer []string
}

func (CmdRequest) ToRequest

func (c CmdRequest) ToRequest() Request

type Component

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

Component 每个执行指令地方

func NewComponent

func NewComponent(targetInfo dto.AgentSearchTargetInfo, req Request) (*Component, error)

func (*Component) IsChartRequest

func (c *Component) IsChartRequest() bool

func (*Component) SearchFile

func (c *Component) SearchFile() error

* searchFile 搜索文件内容 * searchFile 2023-09-28 10:10:00 2023-09-28 10:20:00 /xxx/your_service.log`

type Container

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

type File

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

File contains file related information

func OpenFile

func OpenFile(filename string) (*File, error)

type KeySearch

type KeySearch struct {
	Key   string
	Value interface{}
	Type  string
}

func Keyword2Array

func Keyword2Array(keyword string, isSkip bool) []KeySearch

type LogRes

type LogRes struct {
	// Code means response business code
	Code int `json:"code"`
	// Msg means response extra message
	Msg string `json:"msg"`
	// Data means response data payload
	Data view.RespAgentSearch `json:"data"`
}

LogRes defines HTTP JSON response

type OffsetSection

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

This structure is mainly used to record the maximum pos belonging to the same offset when searching, and the number of rows that have been searched for a match

type Options

type Options struct {
	// ChunkSize specifies the size of the chunk that is read at once from the input.
	ChunkSize int64

	// MaxBufferSize limits the maximum size of the buffer used internally.
	// This also limits the max line size.
	MaxBufferSize int64
}

Options contains parameters that influence the internal working of the Scanner.

type Request

type Request struct {
	StartTime      int64
	EndTime        int64
	Date           string // last 30min,6h,1d,7d
	Path           string // 文件路径
	Dir            string // 文件夹路径
	TruePath       []dto.AgentSearchTargetInfo
	KeyWord        string // 搜索的关键词
	Limit          int64  // 最少多少条数据
	IsCommand      bool   // 是否是命令行 默认不是
	IsUploadExcel  bool   //
	Namespace      string // 指定namespace
	IsK8S          bool
	K8SContainer   []string
	K8sClientType  string // 是 containerd,还是docker
	IsChartRequest bool   // 是否为请求 Charts
	IsAllCurl      bool
	Interval       int64 // 请求 charts 时,划分的标准时间间隔
}

type Scanner

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

Scanner is the back-scanner implementation.

func NewBackScan

func NewBackScan(r io.ReaderAt, pos int64) *Scanner

New returns a new Scanner.

func NewOptions

func NewOptions(r io.ReaderAt, pos int64, o *Options) *Scanner

NewOptions returns a new Scanner with the given Options. Invalid option values are replaced with their default values.

func (*Scanner) Line

func (s *Scanner) Line() (line string, pos int64, err error)

Line returns the next line from the input and its absolute byte-position. Line ending is cut from the line. Empty lines are also returned. After returning the last line (which is the first in the input), subsequent calls report io.EOF.

func (*Scanner) LineBytes

func (s *Scanner) LineBytes() (line []byte, pos int64, err error)

LineBytes returns the bytes of the next line from the input and its absolute byte-position. Line ending is cut from the line. Empty lines are also returned. After returning the last line (which is the first in the input), subsequent calls report io.EOF.

This method is for efficiency if you need to inspect or search in the line. The returned line slice shares data with the internal buffer of the Scanner, and its content may be overwritten in subsequent calls to LineBytes() or Line(). If you need to retain the line data, make a copy of it or use the Line() method.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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