Skip to content
Snippets Groups Projects
Commit 56d6f635 authored by dylan.peiry's avatar dylan.peiry
Browse files

setting up formatting for debug purposes

parent 596ac9a0
No related branches found
No related tags found
No related merge requests found
package client package main
...@@ -2,6 +2,11 @@ package helper ...@@ -2,6 +2,11 @@ package helper
import "fmt" import "fmt"
type NodeWrapper struct {
Resource Resource `yaml:"resource"`
Stora0lwe
}
type Node struct { type Node struct {
Resource Resource `json:"resource"` Resource Resource `json:"resource"`
Storage Storage `json:"storage"` Storage Storage `json:"storage"`
...@@ -30,10 +35,14 @@ func (se StorageElement) String() string { ...@@ -30,10 +35,14 @@ func (se StorageElement) String() string {
} }
func (s Storage) String() string { func (s Storage) String() string {
output := "Storage{\n" output := "Storage{"
for _, se := range s.Data { for _, se := range s.Data {
output += fmt.Sprintf("%s\n", se.String()) output += fmt.Sprintf("\n\t\t%s", se.String())
} }
output += "}" output += "\n\t}\n"
return output return output
} }
func (n Node) String() string {
return fmt.Sprintf("Node{\n\t%s,\n\t%s}\n", n.Resource, n.Storage)
}
resource:
name: "a"
address: "127.0.0.10"
storage:
data:
- id: 50
resource:
name: "a"
address: "127.0.0.10"
- id: 10
resource:
name: "b"
address: "127.0.0.11"
\ No newline at end of file
name: "b"
address: "127.0.0.11"
storage:
- id: 10
resource:
name: "b"
address: "127.0.0.11"
- id: 15
resource:
name: "c"
address: "127.0.0.12"
\ No newline at end of file
name: "c"
address: "127.0.0.12"
storage:
- id: 15
resource:
name: "c"
address: "127.0.0.12"
- id: 50
resource:
name: "a"
address: "127.0.0.10"
\ No newline at end of file
id: x
address: "127.0.0.x"
neighbours:
- id: x
address: "127.0.0.x"
edge_weight: 0
- id: x
address: "127.0.0.x"
edge_weight: 0
\ No newline at end of file
File added
package server package main
import ( import (
"fmt" "fmt"
...@@ -6,6 +6,26 @@ import ( ...@@ -6,6 +6,26 @@ import (
) )
func main() { func main() {
//read arguments passed to the program
//./server <port> <config_number> <mode>
// port is the port the server will listen on
// config_number represents de number of the neighbour-x.yaml file to load
// mode is INIT or WAIT (INIT for the server that will run the search, WAIT for the servers that will listen)
//initialize socket connection
//if INIT
//run the search algorithm and send message to the servers
//if WAIT
//wait and listen for new connections
debugTypesPrint()
}
func parseNodeConfig() {
}
func debugTypesPrint() {
resource := helper.Resource{ resource := helper.Resource{
Name: "a", Name: "a",
Address: "127.0.0.10", Address: "127.0.0.10",
...@@ -14,13 +34,22 @@ func main() { ...@@ -14,13 +34,22 @@ func main() {
Id: 15, Id: 15,
Resource: resource, Resource: resource,
} }
storageElement2 := helper.StorageElement{
Id: 13,
Resource: resource,
}
elements := make([]helper.StorageElement, 1) elements := make([]helper.StorageElement, 0)
elements = append(elements, storageElement) elements = append(elements, storageElement)
elements = append(elements, storageElement2)
storage := helper.Storage{
Data: elements,
}
node := helper.Node{ node := helper.Node{
Resource: resource, Resource: resource,
Storage: helper.Storage{Data: elements}, Storage: storage,
} }
fmt.Printf(node) fmt.Printf(node.String())
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment