33 lines
846 B
Go
33 lines
846 B
Go
|
package writers
|
||
|
|
||
|
import "StoreBackEnd/pkg/protocol"
|
||
|
|
||
|
// SendErrorRulePrefix Rule command prefix
|
||
|
const SendErrorRulePrefix = "SEND_ERROR"
|
||
|
|
||
|
// SendErrorRule Storage structure for the SendErrorRule
|
||
|
type SendErrorRule struct {
|
||
|
// cmd Rule name
|
||
|
cmd string
|
||
|
// matcher Allow to make a regex match
|
||
|
matcher *protocol.RegexMatcher
|
||
|
}
|
||
|
|
||
|
// CreateSendErrorRule Creating an instance of SendErrorRule
|
||
|
func CreateSendErrorRule(pattern string) protocol.IProtocolWriter {
|
||
|
return &SendErrorRule{
|
||
|
cmd: SendErrorRulePrefix,
|
||
|
matcher: protocol.CreateRegexMatcher(pattern),
|
||
|
}
|
||
|
}
|
||
|
|
||
|
// GetCmd retrieve the command name.
|
||
|
func (rule SendErrorRule) GetCmd() string {
|
||
|
return rule.cmd
|
||
|
}
|
||
|
|
||
|
// Execute the Rule with a string command.
|
||
|
func (rule SendErrorRule) Execute(argsData ...string) (string, bool) {
|
||
|
return rule.matcher.Build(SendErrorRulePrefix, argsData...)
|
||
|
}
|