From a222740d381f7dc96c32277a46cfa50b27b8b348 Mon Sep 17 00:00:00 2001 From: Manuel Kieweg <mail@manuelkieweg.de> Date: Mon, 28 Sep 2020 11:54:57 +0100 Subject: [PATCH] refactored client slice to array --- nucleus/controller.go | 5 +++-- nucleus/nucleus-core.go | 8 +++++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/nucleus/controller.go b/nucleus/controller.go index b016f662b..79d686aac 100644 --- a/nucleus/controller.go +++ b/nucleus/controller.go @@ -19,7 +19,8 @@ type controllerConfig struct { } type Core struct { - clients []interfaces.Client + //Assert type with clients[key].(*MCPClient) + clients map[string]interfaces.Client database database.Database config controllerConfig } @@ -47,7 +48,7 @@ func (c *Core) Init(socket, configfile string) { c.AttachDatabase() //TODO: Create client config/CLI adapter - c.clients = append(c.clients, ciena.NewMCPClient( "141.100.70.170", "", "", &c.database)) + c.clients["ciena-mcp"] = ciena.NewMCPClient( "141.100.70.170", "", "", &c.database) } func (c *Core) AttachDatabase() { diff --git a/nucleus/nucleus-core.go b/nucleus/nucleus-core.go index 86909fc17..6479643b5 100644 --- a/nucleus/nucleus-core.go +++ b/nucleus/nucleus-core.go @@ -2,6 +2,8 @@ package nucleus import ( pb "code.fbi.h-da.de/cocsn/gosdn/cliInterface" + "code.fbi.h-da.de/cocsn/gosdn/database" + "code.fbi.h-da.de/cocsn/gosdn/nucleus/interfaces" "context" _ "github.com/mattn/go-sqlite3" "google.golang.org/grpc" @@ -55,7 +57,11 @@ func StartUp(socket, filename string) { log.Println("This is the network superintendent...") log.Println("Starting my ducks") // Init the Core - core := Core{} + core := Core{ + clients: make(map[string]interfaces.Client, 0), + database: database.Database{}, + config: nil, + } core.Init(socket, filename) // Start the GRCP CLI go getCLIGoing(&core) -- GitLab