-
Notifications
You must be signed in to change notification settings - Fork 82
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
[Feature] Identity carry over part 6 / Configure Identity
from constuctor
#194
Changes from 4 commits
8337973
0876074
1660c01
97741e9
03527bc
58a104c
4838ed2
f9c9eb7
bf23425
20a4910
5e842da
23fca53
65e41f9
735ca7f
a1de8bf
39d2245
19ad1a0
92cde55
6eca742
ae69665
e99f2d7
ef8a2e4
3c4c437
b5b7a47
3901340
68566d8
b204d2b
28c26a5
7d33825
b3a5a9e
dcc597a
b2afa96
33b85a2
8362478
f2b8ff5
0295cb9
d5b1490
391bf3a
43fd997
4310b0d
7cf7735
5dec2b3
2ef6d5f
1af053a
68f0b86
6ad89c0
3f059b6
b3ed09f
730abc4
265c6c2
a047ef8
399aa96
6c030dc
938be77
273d946
e4926c9
49b5026
fd9fd37
2f62bba
80205d6
8373307
c52f066
38aa51e
30e3c60
bfb5e86
e4d8dd1
3d0d532
31e630b
101e4f8
2921874
1259782
2269706
fb81d89
60515d0
7c85ff4
74de8fe
3cf4b5c
fac34e4
ecf4f8a
a4d8488
a0468ac
d721c7e
0b6f6e8
3e015c5
c7ef3e7
388a5f8
21611c5
5c97e4a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,8 +28,10 @@ import ( | |
log "github.com/uber-common/bark" | ||
"github.com/uber/ringpop-go/hashring" | ||
"github.com/uber/ringpop-go/logging" | ||
"github.com/uber/ringpop-go/membership" | ||
"github.com/uber/ringpop-go/shared" | ||
"github.com/uber/ringpop-go/swim" | ||
"github.com/uber/ringpop-go/util" | ||
) | ||
|
||
type configuration struct { | ||
|
@@ -52,6 +54,9 @@ type configuration struct { | |
// number of labels and the size of key and value can be configured. | ||
LabelLimits swim.LabelOptions | ||
|
||
// InitialLabels configures the initial labels. | ||
InitialLabels swim.LabelMap | ||
|
||
// SelfEvict holds the settings with regards to self eviction | ||
SelfEvict swim.SelfEvictOptions | ||
} | ||
|
@@ -173,6 +178,19 @@ func Statter(s log.StatsReporter) Option { | |
} | ||
} | ||
|
||
// Identity is used to specify an identity as this Ringpop instance's identity. | ||
// Since a ringpop instance is by default identified by its hostport, it's not allowed to manually specify a | ||
// hostport as its identity. | ||
func Identity(identity string) Option { | ||
return func(r *Ringpop) error { | ||
if util.HostportPattern.MatchString(identity) { | ||
return errors.New("a hostport is not valid as an identity") | ||
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. maybe define an error at the top that is exported and returned here. 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. Was thinking the same but all other errors in this file are created inline. I chose to follow the code style (of this file). |
||
} | ||
r.config.InitialLabels[membership.IdentityLabelKey] = identity | ||
return nil | ||
} | ||
} | ||
|
||
// Address is used to specify a static hostport string as this Ringpop | ||
// instance's address. | ||
// | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -48,6 +48,8 @@ var ( | |
faultyPeriod = flag.Int("faulty-period", 24*60*60*1000, "The lifetime of a faulty member in ms. After that the member becomes a tombstone.") | ||
tombstonePeriod = flag.Int("tombstone-period", 5000, "The lifetime of a tombstone member in ms. After that the member is removed from the membership.") | ||
|
||
identity = flag.String("identity", "", "specify an identity") | ||
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. I think we should at least say: |
||
|
||
hostportPattern = regexp.MustCompile(`^(\d+.\d+.\d+.\d+):\d+$`) | ||
) | ||
|
||
|
@@ -78,6 +80,10 @@ func main() { | |
ringpop.TombstonePeriod(time.Duration(*tombstonePeriod) * time.Millisecond), | ||
} | ||
|
||
if *identity != "" { | ||
options = append(options, ringpop.Identity(*identity)) | ||
} | ||
|
||
if *statsUDP != "" && *statsFile != "" { | ||
log.Fatalf("-stats-udp and stats-file are mutually exclusive.") | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
|
||
declare project_root="${0%/*}/.." | ||
declare ringpop_common_dir="${0%/*}/ringpop-common" | ||
declare ringpop_common_branch="menno/allow-multi-checksum" | ||
declare ringpop_common_branch="feature/identity" | ||
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. Lets make sure to change this to 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. done! |
||
|
||
# | ||
# Clones or updates the ringpop-common repository. | ||
|
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.
Help text could be better here.
E.g.: