Skip to content

Commit

Permalink
Using metadata structs for sync and buffer options in JSON form…
Browse files Browse the repository at this point in the history
…at, #107.
  • Loading branch information
trustmaster committed Oct 25, 2013
1 parent 2d96215 commit f996dfc
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ type graphDescription struct {
}
Processes map[string]struct {
Component string
Sync bool `json:",omitempty"`
Metadata struct {
Sync bool `json:",omitempty"`
} `json:",omitempty"`
}
Connections []struct {
Data interface{} `json:",omitempty"`
Expand All @@ -26,7 +28,9 @@ type graphDescription struct {
Process string
Port string
}
Buffer int `json:",omitempty"`
Metadata struct {
Buffer int `json:",omitempty"`
} `json:",omitempty"`
}
Exports []struct {
Private string
Expand Down Expand Up @@ -54,7 +58,7 @@ func ParseJSON(js []byte) *Graph {
for procName, procValue := range descr.Processes {
net.AddNew(procValue.Component, procName)
// Support for Sync/Async process switch
if procValue.Sync {
if procValue.Metadata.Sync {
proc := net.Get(procName).(*Component)
proc.Mode = ComponentModeSync
}
Expand All @@ -65,7 +69,7 @@ func ParseJSON(js []byte) *Graph {
// Check if it is an IIP or actual connection
if conn.Data == nil {
// Add a connection
net.ConnectBuf(conn.Src.Process, conn.Src.Port, conn.Tgt.Process, conn.Tgt.Port, conn.Buffer)
net.ConnectBuf(conn.Src.Process, conn.Src.Port, conn.Tgt.Process, conn.Tgt.Port, conn.Metadata.Buffer)
} else {
// Add an IIP
net.AddIIP(conn.Data, conn.Tgt.Process, conn.Tgt.Port)
Expand Down

0 comments on commit f996dfc

Please sign in to comment.