-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for the CLI to push a lambda to monitor SQS queues. #8649
Add support for the CLI to push a lambda to monitor SQS queues. #8649
Conversation
c469a8c
to
ad4db30
Compare
return "fnb" + s.config.Name + suffix | ||
} | ||
|
||
re := regexp.MustCompile("[:/-]") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is kind of a constant. Let's move the init out of this function and introduce a global:
var reNormalizeNames = regexp.MustCompile("[:/-]")
It is not nice to have var as global constant, but this patterns catches errors/panics whenever the beat is started, not only when the regex is compiled by taking said code path.
A little trick (lisp-style) if ouy want to hide the regex (still creates a function pointer, though):
var normalizeSQSName = func() func(string) string {
re := regex.MustCompile()
return func(c string) string {
return re.ReplaceAllString(c, "")
}
}()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As we remove these bytes, solution without regex:
func removeChars(s string, chars string) string {
buf := &strings.Builder{}
for len(s) > 0 {
idx := strings.IndexAny(s, chars)
if idx < 0 {
if buf.Len() > 0 {
buf.WriteString(s)
}
break
}
buf.WriteString(s[:idx])
s = s[idx+1:]
}
if buf.Len() == 0 {
return s
}
return buf.String()
}
Why is this missing from stdlib :/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have added the above method in common/string.go and tests for it.
Updated with the reviews, added support for enabled: false in the 'yml' |
0956459
to
500de83
Compare
@urso rebased, it will probably conflict with another PR I have open so lets try to get it merged soonish. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. CI failure is unrelated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. CI failure is unrelated.
This all support to configure triggers in the configuration file to allow a lambda function to monitor one or more queue. Note: we assume that body of an SQS message is a string, it we receive a json encoded string we can use the `decode_json_fields`.
you are trying to use them in the CLI.
64ea8f4
to
2828f93
Compare
I've rebased this PR on top of the feature branch as soon as everything is green I will merge it. |
* Add support for the CLI to push a lambda to monitor SQS queues. This all support to configure triggers in the configuration file to allow a lambda function to monitor one or more queue. Note: we assume that the body of an SQS message is a string, if we receive a JSON encoded string we can use the `decode_json_fields`.
* Add support for the CLI to push a lambda to monitor SQS queues. This all support to configure triggers in the configuration file to allow a lambda function to monitor one or more queue. Note: we assume that the body of an SQS message is a string, if we receive a JSON encoded string we can use the `decode_json_fields`.
…tic#8649) * Add support for the CLI to push a lambda to monitor SQS queues. This all support to configure triggers in the configuration file to allow a lambda function to monitor one or more queue. Note: we assume that the body of an SQS message is a string, if we receive a JSON encoded string we can use the `decode_json_fields`.
This all support to configure triggers in the configuration file to
allow a lambda function to monitor one or more queue.
Note: we assume that body of an SQS message is a string, it we receive
a json encoded string we can use the
decode_json_fields
.