Skip to content

Fix unsubscribe#29

Open
nothize wants to merge 2 commits into
gofinance:masterfrom
nothize:fix_unsubscribe
Open

Fix unsubscribe#29
nothize wants to merge 2 commits into
gofinance:masterfrom
nothize:fix_unsubscribe

Conversation

@nothize

@nothize nothize commented Jul 15, 2017

Copy link
Copy Markdown
Contributor

Fix unsubscribe all and unmatched bug that removed other observers

Use a more efficient way to construct the new subscribe list while
fixing the bug.

A test case is included as an earlier commit so that the bug can be reproduced by running the test case:

$ GATEWAY_URL=localhost:4003 go test -run TestUnsubscribe
=== RUN   TestUnsubscribeAllAndUnmatched
--- FAIL: TestUnsubscribeAllAndUnmatched (0.10s)
	engine_test.go:72: created engine for reuse
	engine_test.go:158: rc should be unsubscribed from allObservers
	engine_test.go:167: rc should be unsubscribed from unObservers
FAIL
exit status 1
FAIL	github.com/gofinance/ib	0.113s

nothize added 2 commits July 15, 2017 20:26
This reveals a bug that when there is more than 1 subscribers, the
end result will always contain the observer to be removed.

In general, where n is the length of the subscriber list
	when n = 1, works as expected
	when n > 1, subscriber list = [observer to be removed] x (n-1)
Use a more efficient way to construct the new subscribe list while
fixing the bug.
@nothize

nothize commented Jan 26, 2019

Copy link
Copy Markdown
Contributor Author

@creack @indrekj @joelreymont @uwe

Please review, thanks!

@creack

creack commented Jan 28, 2019

Copy link
Copy Markdown
Member

I'll give it a shot over the weekend.

@creack creack self-requested a review January 31, 2019 20:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants