forked from yomorun/yomo
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: version negotiation (yomorun#639)
# Description Adding version negotiation between `zipper` and `source/sfn`, if version negotiation failed, the `source/sfn` cannot connect to `zipper`. The version format must follow the `Major.Minor.Patch` formatting, and the Major, Minor, and Patch components must be numeric. The client‘s MAJOR and MINOR versions should equal to server's, otherwise, the zipper will be considered has break-change, the handshake will fail. ## Impact This is a break-change. It will not be possible to establish a connection with the `zipper` if the `source/sfn` does not send the version field.
- Loading branch information
Showing
10 changed files
with
233 additions
and
29 deletions.
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
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,4 @@ | ||
package core | ||
|
||
// Version is the current yomo version. | ||
const Version = "1.17.0" |
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,44 @@ | ||
// Package version provides functionality for parsing versions.. | ||
package version | ||
|
||
import ( | ||
"fmt" | ||
"strconv" | ||
"strings" | ||
) | ||
|
||
// Version is used by the source/sfn to communicate their version to the server. | ||
type Version struct { | ||
Major int | ||
Minor int | ||
Patch int | ||
} | ||
|
||
// Parse parses a string into a Version. The string format must follow the `Major.Minor.Patch` | ||
// formatting, and the Major, Minor, and Patch components must be numeric. If they are not, | ||
// a parse error will be returned. | ||
func Parse(str string) (*Version, error) { | ||
vs := strings.Split(str, ".") | ||
if len(vs) != 3 { | ||
return nil, fmt.Errorf("invalid semantic version, params=%s", str) | ||
} | ||
|
||
major, err := strconv.Atoi(vs[0]) | ||
if err != nil { | ||
return nil, fmt.Errorf("invalid version major, params=%s", str) | ||
} | ||
|
||
minor, err := strconv.Atoi(vs[1]) | ||
if err != nil { | ||
return nil, fmt.Errorf("invalid version minor, params=%s", str) | ||
} | ||
|
||
patch, err := strconv.Atoi(vs[2]) | ||
if err != nil { | ||
return nil, fmt.Errorf("invalid version patch, params=%s", str) | ||
} | ||
|
||
ver := &Version{Major: major, Minor: minor, Patch: patch} | ||
|
||
return ver, nil | ||
} |
Oops, something went wrong.