Skip to content

Commit

Permalink
chore: s/pubsubs/pubsub/
Browse files Browse the repository at this point in the history
  • Loading branch information
owulveryck committed Jul 22, 2020
1 parent 247b032 commit 1157b85
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
12 changes: 6 additions & 6 deletions x/vm/machine.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}

Expand Down Expand Up @@ -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
Expand All @@ -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{}{}
}
Expand Down
16 changes: 8 additions & 8 deletions x/vm/machine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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()
})
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 1157b85

Please sign in to comment.