Skip to content

Commit 1447c26

Browse files
author
yash.bansal
committed
Address comments
1 parent aeaedb3 commit 1447c26

File tree

2 files changed

+4
-12
lines changed

2 files changed

+4
-12
lines changed

pubsub/gochannel/pubsub.go

+2-4
Original file line numberDiff line numberDiff line change
@@ -356,12 +356,10 @@ func (s *subscriber) sendMessageToSubscriber(msg *message.Message, logFields wat
356356
s.sending.Lock()
357357
defer s.sending.Unlock()
358358

359-
var ctx context.Context
359+
ctx := msg.Context()
360360

361361
//This is getting the context from the message, not the subscriber
362-
if s.preserveContext {
363-
ctx = msg.Context()
364-
} else {
362+
if !s.preserveContext {
365363
var cancelCtx context.CancelFunc
366364
ctx, cancelCtx = context.WithCancel(s.ctx)
367365
defer cancelCtx()

pubsub/tests/test_asserts.go

+2-8
Original file line numberDiff line numberDiff line change
@@ -95,17 +95,11 @@ func AssertMessagesMetadata(t *testing.T, key string, expectedValues map[string]
9595
}
9696

9797
// AssertAllMessagesHaveSameContext checks if context of all received messages is the same as in expectedValues, if PreserveContext is enabled.
98-
func AssertAllMessagesHaveSameContext(t *testing.T, contextKeyString string, expectedValues map[string]context.Context, received []*message.Message) bool {
98+
func AssertAllMessagesHaveSameContext(t *testing.T, contextKeyString string, expectedValues map[string]context.Context, received []*message.Message) {
9999
assert.Len(t, received, len(expectedValues))
100-
101-
ok := true
102100
for _, msg := range received {
103101
expectedValue := expectedValues[msg.UUID].Value(contextKey(contextKeyString)).(string)
104102
actualValue := msg.Context().Value(contextKeyString)
105-
if !assert.Equal(t, expectedValue, actualValue) {
106-
ok = false
107-
}
103+
assert.Equal(t, expectedValue, actualValue)
108104
}
109-
110-
return ok
111105
}

0 commit comments

Comments
 (0)