Skip to content
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

Open
wants to merge 5 commits into
base: devel
Choose a base branch
from

Conversation

john-westcott-iv
Copy link
Member

Addresses #423

Includes modification of receptorctl to show the label instead of the status.

@@ -221,6 +222,8 @@ const (
ConnTypeStreamTLS = 2
)

var ConnTypeStrings = [...]string{"Datagram", "Stream", "StreamTLS"}
Copy link
Member

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"
}

Copy link
Member Author

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.

// A byte can't be < 0 so we don't need to check the lower bounds
connTypeString, ok := ConnTypeStrings[connectionType]
if !ok {
connTypeString = UnknownConnTypeStr
Copy link
Member

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?

Copy link
Member Author

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.

Service string
Time time.Time
ConnType byte
ConnTypeLabel string
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants