Skip to content

Commit 50e0d0f

Browse files
committed
- Updated: cleanup
1 parent afc1af9 commit 50e0d0f

File tree

4 files changed

+30
-30
lines changed

4 files changed

+30
-30
lines changed

bus/bus.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ func New() Bus {
3434
}
3535
}
3636

37-
// Dispatch sends an msg to registered handler that were declared
38-
// to accept values of a msg
37+
//Dispatch sends an msg to registered handler that were declared
38+
//to accept values of a msg
3939
func (b *InProcBus) Dispatch(msg Msg) error {
4040
nameOfMsg := reflect.TypeOf(msg)
4141

@@ -55,8 +55,8 @@ func (b *InProcBus) Dispatch(msg Msg) error {
5555
return nil
5656
}
5757

58-
// Dispatch sends an msg to all registered listeners that were declared
59-
// to accept values of a msg
58+
//Publish sends an msg to all registered listeners that were declared
59+
//to accept values of a msg
6060
func (b *InProcBus) Publish(msg Msg) error {
6161
nameOfMsg := reflect.TypeOf(msg)
6262
listeners := b.listeners[nameOfMsg.String()]
@@ -74,8 +74,8 @@ func (b *InProcBus) Publish(msg Msg) error {
7474
return nil
7575
}
7676

77-
// AddHandler registers a handler function that will be called when a matching
78-
// msg is dispatched.
77+
//AddHandler registers a handler function that will be called when a matching
78+
//msg is dispatched.
7979
func (b *InProcBus) AddHandler(handler HandlerFunc) error {
8080
b.Mutex.Lock()
8181
defer b.Mutex.Unlock()
@@ -92,8 +92,8 @@ func (b *InProcBus) AddHandler(handler HandlerFunc) error {
9292
return nil
9393
}
9494

95-
// AddListener registers a listener function that will be called when a matching
96-
// msg is dispatched.
95+
//AddListener registers a listener function that will be called when a matching
96+
//msg is dispatched.
9797
func (b *InProcBus) AddEventListener(handler HandlerFunc) {
9898
b.Mutex.Lock()
9999
defer b.Mutex.Unlock()
@@ -109,7 +109,7 @@ func (b *InProcBus) AddEventListener(handler HandlerFunc) {
109109
b.listeners[typOfMsg.String()] = append(b.listeners[typOfMsg.String()], reflect.ValueOf(handler))
110110
}
111111

112-
// panic if conditions not met (this is a programming error)
112+
//panic if conditions not met (this is a programming error)
113113
func validateHandlerFunc(handlerType reflect.Type) {
114114
switch {
115115
case handlerType.Kind() != reflect.Func:
@@ -121,8 +121,8 @@ func validateHandlerFunc(handlerType reflect.Type) {
121121
}
122122
}
123123

124-
// BadFuncError is raised via panic() when AddEventListener is called with an
125-
// invalid listener function.
124+
//BadFuncError is raised via panic() when AddEventListener or AddHandler is called with an
125+
//invalid listener function.
126126
type BadFuncError string
127127

128128
func (bhf BadFuncError) Error() string {

bus/bus_test.go

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -21,27 +21,27 @@ func TestHandlerReturnsError(t *testing.T) {
2121

2222
err := b.Dispatch(new(msg))
2323
if err == nil {
24-
t.Fatal("Send query failed " + err.Error())
24+
t.Fatalf("dispatch msg failed (%s)", err.Error())
2525
}
2626
}
2727

2828
func TestHandlerReturn(t *testing.T) {
2929
b := bus.New()
3030

31-
b.AddHandler(func(q *msg) error {
32-
q.body = "Hello, world!"
31+
b.AddHandler(func(m *msg) error {
32+
m.body = "Hello, world!"
3333
return nil
3434
})
3535

3636
msg := new(msg)
3737
err := b.Dispatch(msg)
3838

3939
if err != nil {
40-
t.Fatal("Send msg failed " + err.Error())
40+
t.Fatalf("dispatch msg failed (%s)", err.Error())
4141
}
4242

4343
if msg.body != "Hello, world!" {
44-
t.Fatal("Failed to get response from handler")
44+
t.Fatal("failed to get response from handler")
4545
}
4646
}
4747

@@ -61,11 +61,11 @@ func TestEventListeners(t *testing.T) {
6161

6262
err := b.Publish(new(msg))
6363
if err != nil {
64-
t.Fatal("Publish msg failed " + err.Error())
64+
t.Fatalf("publish msg failed (%s)", err.Error())
6565
}
6666

6767
if count != 11 {
68-
t.Fatal(fmt.Sprintf("Publish msg failed, listeners called: %v, expected: %v", count, 11))
68+
t.Fatal(fmt.Sprintf("publish msg failed, listeners called: %v, expected: %v", count, 11))
6969
}
7070
}
7171

@@ -80,7 +80,7 @@ func TestAddHandlerBadFunc(t *testing.T) {
8080
}()
8181

8282
b := bus.New()
83-
b.AddHandler(func(q *msg, s string) error {
83+
b.AddHandler(func(m *msg, s string) error {
8484
return nil
8585
})
8686
}
@@ -96,7 +96,7 @@ func TestAddListenerBadFunc(t *testing.T) {
9696
}()
9797

9898
b := bus.New()
99-
b.AddEventListener(func(q *msg, s string) error {
99+
b.AddEventListener(func(m *msg, s string) error {
100100
return nil
101101
})
102102
}
@@ -125,23 +125,23 @@ func BenchmarkRun(b *testing.B) {
125125
return nil
126126
})
127127

128-
b.AddHandler(func(q *msg) error {
128+
b.AddHandler(func(m *msg) error {
129129
return nil
130130
})
131131

132-
b.AddHandler(func(q *msg) error {
132+
b.AddHandler(func(m *msg) error {
133133
return nil
134134
})
135135

136-
b.AddHandler(func(q *msg) error {
136+
b.AddHandler(func(m *msg) error {
137137
return nil
138138
})
139139

140-
b.AddHandler(func(q *msg) error {
140+
b.AddHandler(func(m *msg) error {
141141
return nil
142142
})
143143

144-
b.AddHandler(func(q *msg) error {
144+
b.AddHandler(func(m *msg) error {
145145
return nil
146146
})
147147

concurrent/runner_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ func TestRun(t *testing.T) {
2828

2929
expectedValue := int32(6)
3030
if counter != expectedValue {
31-
t.Errorf(`unexpected value (Actual: %d, expected: %d)`, counter, expectedValue)
31+
t.Errorf(`unexpected value (actual: %d, expected: %d)`, counter, expectedValue)
3232
}
3333
}
3434

@@ -50,12 +50,12 @@ func TestRunFail(t *testing.T) {
5050

5151
expectedCountOfErrors := 2
5252
if len(errs) != expectedCountOfErrors {
53-
t.Fatalf(`unexpected count of errors (Actual: %d, expected: %d)`, len(errs), expectedCountOfErrors)
53+
t.Fatalf(`unexpected count of errors (actual: %d, expected: %d)`, len(errs), expectedCountOfErrors)
5454
}
5555

5656
expectedValue := int32(3)
5757
if counter != expectedValue {
58-
t.Errorf(`unexpected value (Actual: %d, expected: %d)`, counter, expectedValue)
58+
t.Errorf(`unexpected value (actual: %d, expected: %d)`, counter, expectedValue)
5959
}
6060
}
6161

schedule/schedule_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ func TestFIFOSchedule(t *testing.T) {
3636
s.WaitFinish(100)
3737
expectedJobCount := 100
3838
if s.Scheduled() != expectedJobCount {
39-
t.Fatalf("scheduled (Actual: %d, Expected: %d)", s.Scheduled(), expectedJobCount)
39+
t.Fatalf("scheduled (actual: %d, expected: %d)", s.Scheduled(), expectedJobCount)
4040
}
4141
}
4242

@@ -64,7 +64,7 @@ func BenchmarkFIFOSchedule(b *testing.B) {
6464

6565
expectedJobCount := 100
6666
if s.Scheduled() != expectedJobCount {
67-
b.Fatalf("scheduled (Actual: %d, Expected: %d)", s.Scheduled(), expectedJobCount)
67+
b.Fatalf("scheduled (actual: %d, expected: %d)", s.Scheduled(), expectedJobCount)
6868
s.Stop()
6969
}
7070
s.Stop()

0 commit comments

Comments
 (0)