update caching and server creation
This commit is contained in:
26
local/utl/regex_handler/regex_handler.go
Normal file
26
local/utl/regex_handler/regex_handler.go
Normal file
@@ -0,0 +1,26 @@
|
||||
package regex_handler
|
||||
|
||||
import (
|
||||
"acc-server-manager/local/model"
|
||||
"regexp"
|
||||
)
|
||||
|
||||
type AccServerInstance struct {
|
||||
Model *model.Server
|
||||
State *model.ServerState
|
||||
}
|
||||
|
||||
type RegexHandler struct {
|
||||
regex *regexp.Regexp
|
||||
}
|
||||
|
||||
func (rh *RegexHandler) Contains(line string, callback func(...string)) {
|
||||
match := rh.regex.FindStringSubmatch(line)
|
||||
callback(match...)
|
||||
}
|
||||
|
||||
func New(str string) *RegexHandler {
|
||||
return &RegexHandler{
|
||||
regex: regexp.MustCompile(str),
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user