-
Notifications
You must be signed in to change notification settings - Fork 40
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
feat: support classic-flavored ingest keys #237
Conversation
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 was slightly worried about performance, and took a minute to run a couple of benchmarks with variations on the regexp.
First, classic keys are hex only, so you can change the classic key regex to a-f instead of a-z. This makes that regex faster.
Second, if you check length manually and then remove the counts from the regexp, it runs literally 1000x faster (7 nS instead of 7 uS!)
var classicKeyRegex = regexp.MustCompile(`^[a-f0-9]*$`)
var classicIngestKeyRegex = regexp.MustCompile(`^hc[a-z]ic_[a-z0-9]*$`)
if len(key) == 0 {
return true
} else if len(key) == 32 {
return classicKeyRegex.MatchString(key)
} else if len(key) == 64 {
return classicIngestKeyRegex.MatchString(key)
}
return false
Whoa! Thank you for this: that's huge. Will refactor the shape of the function |
## Which problem is this PR solving? As a follow on to #237, we now realize it's more helpful to be able to determine if a key is a classic key just by the string and not just in the context of a `Config`. ## Short description of the changes - Adds a new public function `IsClassicKey()` and updates `Config.IsClassic()` to use this without making a breaking change.
Which problem is this PR solving?
We've now released Ingest Keys, but in order for them to work with Classic environments properly we need to update the key detection logic.
Short description of the changes
Config.isClassic
a public method (Config.IsClassic
) to allow other projects to use this method and reduce the duplication of logic (i.e. beeline-go)