diff --git a/x/vm/machine.go b/x/vm/machine.go index f93a149c..884c5034 100644 --- a/x/vm/machine.go +++ b/x/vm/machine.go @@ -8,8 +8,8 @@ import ( // Machine is a top-level struture that will coordinate the execution of a graph type Machine struct { - nodes []*node - pubsubs *pubsub + nodes []*node + pubsub *pubsub } // NewMachine creates an exeuction machine from an exprgraph @@ -37,7 +37,7 @@ func NewMachine(g *gorgonia.ExprGraph) *Machine { m := &Machine{ nodes: nodes, } - m.pubsubs = createNetwork(nodes, g) + m.pubsub = createNetwork(nodes, g) return m } @@ -92,7 +92,7 @@ func createNetwork(ns []*node, g *gorgonia.ExprGraph) *pubsub { // Run the computation func (m *Machine) Run(ctx context.Context) error { - cancel := m.pubsubs.run(ctx) + cancel := m.pubsub.run(ctx) err := m.runAllNodes(ctx) cancel() return err @@ -101,8 +101,8 @@ func (m *Machine) Run(ctx context.Context) error { // Close all the plumbing to avoid leaking func (m *Machine) Close() { chans := make(map[chan gorgonia.Value]struct{}) - for i := range m.pubsubs.publishers { - pub := m.pubsubs.publishers[i] + for i := range m.pubsub.publishers { + pub := m.pubsub.publishers[i] for j := range pub.subscribers { chans[pub.subscribers[j]] = struct{}{} } diff --git a/x/vm/machine_test.go b/x/vm/machine_test.go index e88979b9..6db3ef48 100644 --- a/x/vm/machine_test.go +++ b/x/vm/machine_test.go @@ -60,8 +60,8 @@ func TestMachine_runAllNodes(t *testing.T) { two := gorgonia.F32(2.0) t.Run(tt.name, func(t *testing.T) { m := &Machine{ - nodes: tt.fields.nodes, - pubsubs: tt.fields.pubsubs, + nodes: tt.fields.nodes, + pubsub: tt.fields.pubsubs, } go func() { inputC1 <- struct { @@ -271,8 +271,8 @@ func TestMachine_Close(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { m := &Machine{ - nodes: tt.fields.nodes, - pubsubs: tt.fields.pubsubs, + nodes: tt.fields.nodes, + pubsub: tt.fields.pubsubs, } m.Close() }) @@ -464,8 +464,8 @@ func TestMachine_Run(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { m := &Machine{ - nodes: tt.fields.nodes, - pubsubs: tt.fields.pubsubs, + nodes: tt.fields.nodes, + pubsub: tt.fields.pubsubs, } err := m.Run(tt.args.ctx) if (err != nil) != tt.wantErr { @@ -524,8 +524,8 @@ func TestMachine_GetResult(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { m := &Machine{ - nodes: tt.fields.nodes, - pubsubs: tt.fields.pubsubs, + nodes: tt.fields.nodes, + pubsub: tt.fields.pubsubs, } if got := m.GetResult(tt.args.id); !reflect.DeepEqual(got, tt.want) { t.Errorf("Machine.GetResult() = %v, want %v", got, tt.want)