-
Notifications
You must be signed in to change notification settings - Fork 158
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
Prevent possible duplicate ECS services. #884
Merged
Changes from 4 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
8b0b997
Prevent possible duplicate ECS services.
ejholmes 6ab8681
Generate name postfix based on hash of properties.
ejholmes 0c39ff8
Update CHANGELOG.
ejholmes add02c9
Use a smaller base62 encoded sum of the hash.
ejholmes 289c665
Use Hash method instead of hashstructure.Hash.
ejholmes 8d19173
Cleanup error messages.
ejholmes 59af36b
Postfix based on a hash of the request id.
ejholmes e753dbc
Revert requiresReplacement change.
ejholmes a5e8b17
Cleanup base62 docs.
ejholmes 946a876
Don't set visibility timeout.
ejholmes ac3f2bb
Cleanup debugging change.
ejholmes File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// Package base62 implements conversion to and from base62. Useful for url shorteners. | ||
package base62 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was stripped from an internal project. |
||
|
||
// characters used for conversion | ||
const alphabet = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" | ||
|
||
// converts number to base62 | ||
func Encode(number uint64) string { | ||
if number == 0 { | ||
return string(alphabet[0]) | ||
} | ||
|
||
chars := make([]byte, 0) | ||
|
||
length := uint64(len(alphabet)) | ||
|
||
for number > 0 { | ||
result := number / length | ||
remainder := number % length | ||
chars = append(chars, alphabet[remainder]) | ||
number = result | ||
} | ||
|
||
for i, j := 0, len(chars)-1; i < j; i, j = i+1, j-1 { | ||
chars[i], chars[j] = chars[j], chars[i] | ||
} | ||
|
||
return string(chars) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package base62 | ||
|
||
import "testing" | ||
|
||
func Test_Encode(t *testing.T) { | ||
tests := []struct { | ||
Input uint64 | ||
Expected string | ||
}{ | ||
{1024, "gw"}, | ||
{512347, "29hF"}, | ||
{5369806, "mwVM"}, | ||
{2147483647, "2lkCB1"}, | ||
{0xFFFFFFFFFFFFFFFF, "lYGhA16ahyf"}, // Max uint64 | ||
} | ||
|
||
for i, test := range tests { | ||
e := Encode(test.Input) | ||
|
||
if e != test.Expected { | ||
t.Errorf("%v: Got %v, want %v", i, e, test.Expected) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) 2016 Mitchell Hashimoto | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
# hashstructure [![GoDoc](https://godoc.org/github.com/mitchellh/hashstructure?status.svg)](https://godoc.org/github.com/mitchellh/hashstructure) | ||
|
||
hashstructure is a Go library for creating a unique hash value | ||
for arbitrary values in Go. | ||
|
||
This can be used to key values in a hash (for use in a map, set, etc.) | ||
that are complex. The most common use case is comparing two values without | ||
sending data across the network, caching values locally (de-dup), and so on. | ||
|
||
## Features | ||
|
||
* Hash any arbitrary Go value, including complex types. | ||
|
||
* Tag a struct field to ignore it and not affect the hash value. | ||
|
||
* Tag a slice type struct field to treat it as a set where ordering | ||
doesn't affect the hash code but the field itself is still taken into | ||
account to create the hash value. | ||
|
||
* Optionally specify a custom hash function to optimize for speed, collision | ||
avoidance for your data set, etc. | ||
|
||
## Installation | ||
|
||
Standard `go get`: | ||
|
||
``` | ||
$ go get github.com/mitchellh/hashstructure | ||
``` | ||
|
||
## Usage & Example | ||
|
||
For usage and examples see the [Godoc](http://godoc.org/github.com/mitchellh/hashstructure). | ||
|
||
A quick code example is shown below: | ||
|
||
```go | ||
type ComplexStruct struct { | ||
Name string | ||
Age uint | ||
Metadata map[string]interface{} | ||
} | ||
|
||
v := ComplexStruct{ | ||
Name: "mitchellh", | ||
Age: 64, | ||
Metadata: map[string]interface{}{ | ||
"car": true, | ||
"location": "California", | ||
"siblings": []string{"Bob", "John"}, | ||
}, | ||
} | ||
|
||
hash, err := hashstructure.Hash(v, nil) | ||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
fmt.Printf("%d", hash) | ||
// Output: | ||
// 2307517237273902113 | ||
``` |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 seems really long - you handle de-duping requests here as well, right? Otherwise we could see things being re-submitted 30 minutes later after a crash or something. In the case where de-duping is handled, what's the idea behind making this so long? Would 5 minutes be sufficient?
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.
Yeah good point. Probably the best thing to do would be to leave the default, and then use the ChangeMessageVisibility api call to increase it when needed.
I'll revert the current change for now, since the de-duping is sufficient to fix the current issue.