forked from superedge/superedge
-
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.
Merge pull request superedge#86 from chenkaiyue/endpoint-update
Edge autonomy enhancement: Endpoints can be updated when disconnect with apiserver
- Loading branch information
Showing
12 changed files
with
265 additions
and
60 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
48 changes: 48 additions & 0 deletions
48
cmd/application-grid-wrapper/app/options/service-autonomy-enhancement-options.go
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,48 @@ | ||
package options | ||
|
||
import ( | ||
"fmt" | ||
"strconv" | ||
"strings" | ||
) | ||
|
||
type ServiceAutonomyEnhancementOptions struct { | ||
Enabled bool | ||
NeighborStatusSvc string | ||
UpdateInterval int | ||
} | ||
|
||
func (p ServiceAutonomyEnhancementOptions) Name() string { | ||
return "ServiceAutonomyEnhancement" | ||
} | ||
|
||
func (p *ServiceAutonomyEnhancementOptions) Set(s string) error { | ||
var err error | ||
|
||
for _, para := range strings.Split(s, ",") { | ||
if len(para) == 0 { | ||
continue | ||
} | ||
arr := strings.Split(para, "=") | ||
trimkey := strings.TrimSpace(arr[0]) | ||
switch trimkey { | ||
case "address": | ||
(*p).NeighborStatusSvc = strings.TrimSpace(arr[1]) | ||
case "interval": | ||
interval, _ := strconv.Atoi(strings.TrimSpace(arr[1])) | ||
(*p).UpdateInterval = interval | ||
case "enabled": | ||
enabled, _ := strconv.ParseBool(strings.TrimSpace(arr[1])) | ||
(*p).Enabled = enabled | ||
} | ||
} | ||
return err | ||
} | ||
|
||
func (p *ServiceAutonomyEnhancementOptions) String() string { | ||
return fmt.Sprintf("%#v", *p) | ||
} | ||
|
||
func (i *ServiceAutonomyEnhancementOptions) Type() string { | ||
return "ServiceAutonomyEnhancement" | ||
} |
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
Oops, something went wrong.