Documentation ¶
Index ¶
- Constants
- Variables
- func EscapeLimitJSONBytes(b []byte, capacity int) []byte
- func Start()
- func StartLogtail(config *Config)
- func StopLogtail()
- func WildcardMatch(pattern string, data []byte) bool
- type Channel
- type Config
- type ConsoleTransfer
- type ContainsMatcher
- type DingTransfer
- type FileConfig
- type FileTransfer
- type Filter
- type Format
- type Matcher
- type MatcherConfig
- type Router
- type RouterConfig
- type Server
- type ServerConfig
- type Transfer
- type TransferConfig
- type WebhookTransfer
- type WebsocketTransfer
Constants ¶
View Source
const ( // URIIndexPrefix uri index prefix. URIIndexPrefix = "/index" // URITailPrefix uri tail prefix. URITailPrefix = "/tail" )
View Source
const ( // DefaultServerID default server id. DefaultServerID = "default" // CommandFailRetryInterval command fail retry interval. CommandFailRetryInterval = 10 * time.Second )
View Source
const DefaultChannelBufferSize = 16
View Source
const DefaultServerPort = 54321
View Source
const DoubleSize = 2
View Source
const DurationReadNextTimeout = time.Millisecond * 60
View Source
const MessageTypeMatcherConfig = '1'
View Source
const TransferFileSize = 1024 * 1024 * 8
8MB for each transfer file.
View Source
const TransferTypeConsole = "console"
View Source
const TransferTypeDing = "ding"
View Source
const TransferTypeFile = "file"
View Source
const TransferTypeWebhook = "webhook"
View Source
const WebsocketHeartbeatReadTimeout = 15 * time.Second
Variables ¶
View Source
var ( ErrNoServerConfig = errors.New("no server config") ErrServerIDNil = errors.New("server id is nil") ErrNoTailingConfig = errors.New("no tailing command/file config") ErrTransURLNil = errors.New("transfer url is nil") ErrTransTypeNil = errors.New("transfer type is nil") ErrTransTypeInvalid = errors.New("invalid transfer type") ErrTransDirNil = errors.New("transfer dir is nil") )
View Source
var ErrHTTPStatusNonOK = errors.New("http status non ok")
View Source
var ErrWorkerCommandStopped = errors.New("worker command stopped")
Functions ¶
func EscapeLimitJSONBytes ¶
func WildcardMatch ¶
WildcardMatch - finds whether the bytes matches/satisfies the pattern wildcard. supports: - '?' as one byte char - '~' as one alphabet char - '!' as one number char NOT support '*' for none or many char.
Types ¶
type Config ¶
type Config struct { Port int `json:"port"` LogLevel string `json:"log_level"` DefaultFormat *Format `json:"default_format"` Servers []*ServerConfig `json:"servers"` DefaultRouters []*RouterConfig `json:"default_routers"` GlobalRouters []*RouterConfig `json:"global_routers"` }
type ConsoleTransfer ¶
type ConsoleTransfer struct{}
type ContainsMatcher ¶
type ContainsMatcher struct {
// contains filtered or unexported fields
}
func NewContainsMatcher ¶
func NewContainsMatcher(pattern string, contains bool) *ContainsMatcher
func (*ContainsMatcher) Match ¶
func (cm *ContainsMatcher) Match(bytes []byte) bool
type DingTransfer ¶
type DingTransfer struct {
// contains filtered or unexported fields
}
type FileConfig ¶ added in v1.1.0
type FileConfig struct { // Path the file or directory to tail. Path string `json:"path"` // Method watch method, // - os: using os file system api to monitor file changes, // - timer: interval check file stat to check file changes, // For some network mount devices, can't get file change events for os api, // you'd better to check file stat to know the changes. Method fwatch.WatchMethod `json:"method"` // only tailing files with the prefix. Prefix string `json:"prefix"` // only tailing files with the suffix. Suffix string `json:"suffix"` // Whether include all files in sub directories recursively. Recursive bool `json:"recursive"` }
FileConfig tailing file config.
type FileTransfer ¶
type FileTransfer struct {
// contains filtered or unexported fields
}
type Format ¶
type Format struct {
Prefix string `json:"prefix"` // the wildcard of the line prefix of a log record
}
Format the log format.
func (*Format) PrefixMatch ¶
PrefixMatch whether the given data has a prefix of a new record.
type MatcherConfig ¶
type Router ¶
type Router struct {
// contains filtered or unexported fields
}
func (*Router) SetMatchers ¶
type RouterConfig ¶
type RouterConfig struct { Matchers []*MatcherConfig `json:"matchers"` Transfers []*TransferConfig `json:"transfers"` }
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
func NewServer ¶
func NewServer(config *Config, serverConfig *ServerConfig) *Server
NewServer start a new server.
type ServerConfig ¶
type ServerConfig struct { ID string `json:"id"` Format *Format `json:"format"` Routers []*RouterConfig `json:"routers"` // single command. Command string `json:"command"` // multiple commands split by new line. Commands string `json:"commands"` // command to generate multiple commands split by new line. CommandGen string `json:"command_gen"` // command to generate multiple commands split by new line. File *FileConfig `json:"file"` }
type Transfer ¶
type Transfer interface { Trans(serverID string, data ...[]byte) error // contains filtered or unexported methods }
func NewDingTransfer ¶
func NewFileTransfer ¶
func NewWebhookTransfer ¶
type TransferConfig ¶
type WebhookTransfer ¶
type WebhookTransfer struct {
// contains filtered or unexported fields
}
type WebsocketTransfer ¶
type WebsocketTransfer struct {
// contains filtered or unexported fields
}
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
cmd
|
|
Command makeStatic reads a set of files and writes a Go source file to "static.go" that declares a map of string constants containing contents of the input files.
|
Command makeStatic reads a set of files and writes a Go source file to "static.go" that declares a map of string constants containing contents of the input files. |
Click to show internal directories.
Click to hide internal directories.