examples: make the libmgmt example more fun
You can try it out yourself by running `go build` and then calling it. Use a bare integer argument to create that number of noop resources. There are clearly some performance optimizations that we could do for extremely large graphs.
This commit is contained in:
@@ -6,6 +6,7 @@ import (
|
|||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"os/signal"
|
"os/signal"
|
||||||
|
"strconv"
|
||||||
"sync"
|
"sync"
|
||||||
"syscall"
|
"syscall"
|
||||||
"time"
|
"time"
|
||||||
@@ -120,7 +121,7 @@ func (obj *MyGAPI) Close() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Run runs an embedded mgmt server.
|
// Run runs an embedded mgmt server.
|
||||||
func Run() error {
|
func Run(count uint) error {
|
||||||
|
|
||||||
obj := &mgmt.Main{}
|
obj := &mgmt.Main{}
|
||||||
obj.Program = "libmgmt" // TODO: set on compilation
|
obj.Program = "libmgmt" // TODO: set on compilation
|
||||||
@@ -132,7 +133,7 @@ func Run() error {
|
|||||||
|
|
||||||
obj.GAPI = &MyGAPI{ // graph API
|
obj.GAPI = &MyGAPI{ // graph API
|
||||||
Name: "libmgmt", // TODO: set on compilation
|
Name: "libmgmt", // TODO: set on compilation
|
||||||
Count: 60, // number of vertices to add
|
Count: count, // number of vertices to add
|
||||||
Interval: 15, // arbitrarily change graph every 15 seconds
|
Interval: 15, // arbitrarily change graph every 15 seconds
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -172,7 +173,13 @@ func Run() error {
|
|||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
log.Printf("Hello!")
|
log.Printf("Hello!")
|
||||||
if err := Run(); err != nil {
|
var count uint = 1 // default
|
||||||
|
if len(os.Args) == 2 {
|
||||||
|
if i, err := strconv.Atoi(os.Args[1]); err == nil && i > 0 {
|
||||||
|
count = uint(i)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if err := Run(count); err != nil {
|
||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
return
|
return
|
||||||
|
|||||||
Reference in New Issue
Block a user