* Revert "Remove deprecated mqtrigger with kind fission (#2875)"
This reverts commit f44174debc.
* Upgrade sarama version to v1.43.2
Signed-off-by: Md Soharab Ansari <soharab.ansari@infracloud.io>
---------
Signed-off-by: Md Soharab Ansari <soharab.ansari@infracloud.io>
This commit is contained in:
@@ -16,7 +16,13 @@ limitations under the License.
|
||||
|
||||
package validator
|
||||
|
||||
import (
|
||||
"sync"
|
||||
)
|
||||
|
||||
var (
|
||||
topicValidators = make(map[string]TopicValidator)
|
||||
lock = sync.Mutex{}
|
||||
kedaMqTypeValidators = map[string]bool{
|
||||
"kafka": true,
|
||||
"aws-sqs-queue": true,
|
||||
@@ -29,13 +35,41 @@ var (
|
||||
}
|
||||
)
|
||||
|
||||
func IsValidTopic(mqtKind string) bool {
|
||||
return mqtKind == "keda"
|
||||
type (
|
||||
TopicValidator func(topic string) bool
|
||||
)
|
||||
|
||||
func Register(mqType string, validator TopicValidator) {
|
||||
lock.Lock()
|
||||
defer lock.Unlock()
|
||||
|
||||
if validator == nil {
|
||||
panic("Nil message queue topic validator")
|
||||
}
|
||||
|
||||
_, registered := topicValidators[mqType]
|
||||
if registered {
|
||||
panic("Message queue topic validator already register")
|
||||
}
|
||||
|
||||
topicValidators[mqType] = validator
|
||||
}
|
||||
|
||||
func IsValidTopic(mqType, topic, mqtKind string) bool {
|
||||
if mqtKind == "keda" {
|
||||
return true
|
||||
}
|
||||
validator, registered := topicValidators[mqType]
|
||||
if !registered {
|
||||
return false
|
||||
}
|
||||
return validator(topic)
|
||||
}
|
||||
|
||||
func IsValidMessageQueue(mqType, mqtKind string) bool {
|
||||
if mqtKind == "keda" {
|
||||
return kedaMqTypeValidators[mqType]
|
||||
}
|
||||
return false
|
||||
_, registered := topicValidators[mqType]
|
||||
return registered
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user