-
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
Modify Status command to return a ConnTypeLabel in addition to the ConnType byte #471
base: devel
Are you sure you want to change the base?
Conversation
pkg/netceptor/netceptor.go
Outdated
@@ -221,6 +222,8 @@ const ( | |||
ConnTypeStreamTLS = 2 | |||
) | |||
|
|||
var ConnTypeStrings = [...]string{"Datagram", "Stream", "StreamTLS"} |
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.
what if this was a map instead?
connTypeStrings := map[byte] string {ConnTypeDatagram: "DataGram" ... }
then in GetConnectionTypeAsString() we do
conntypestr, ok := connTypeString[conntype]
if !ok {
conntypestr = "unknown"
}
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 like the idea of the map because then the labels are not dependent on the order of the array.
38d6cd7
to
434ca25
Compare
// A byte can't be < 0 so we don't need to check the lower bounds | ||
connTypeString, ok := ConnTypeStrings[connectionType] | ||
if !ok { | ||
connTypeString = UnknownConnTypeStr |
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.
Curious, under which conditions would this happen?
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.
If someone added a new connection type constant but forgot to add an entry into the map. I was also thinking of some weird upgrade scenario where a newer version of receptor with a new connection type was introduced to an existing mesh.
434ca25
to
e99ca56
Compare
e99ca56
to
855c3fe
Compare
Service string | ||
Time time.Time | ||
ConnType byte | ||
ConnTypeLabel string |
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 probably shouldn't go here. This is the struct for the low-level advertisements that get sent around the network, so its size matters. If we want another field in the Status response, we should define another struct that inherits this one and adds the field, and populate it at the time the status is being asked for.
Addresses #423
Includes modification of receptorctl to show the label instead of the status.