-
Notifications
You must be signed in to change notification settings - Fork 822
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
stream: force subscription store check as stop gap for wrapper side implementation #1717
base: master
Are you sure you want to change the base?
Changes from 1 commit
3e7fe77
457cba1
dc72434
5ce010d
6ec3204
fadf919
759e225
fcf1d23
7147815
7401285
102bfc1
1e3eeda
9d7f116
ba022ec
06380e0
aca87c3
6c6fb30
fed2ed6
db9bb58
d630bf2
196263c
5f855fe
68461c5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -206,3 +206,21 @@ func (s *Store) Len() int { | |
defer s.mu.RUnlock() | ||
return len(s.m) | ||
} | ||
|
||
// PartitionByPresence returns two lists; one with the subscriptions that are present in the store and one with the | ||
// subscriptions that are not | ||
func (s *Store) PartitionByPresence(compare List) (matched, unmatched List) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thought about this for a while, and I think it's cute, but wrong to have a function where you're always using one or the other return. I'd vote for 2 funcs:
Alternative note: I'm feeling a tingle about how similar this is to Diff, and yet not. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah good suggestion. I will introduce contained and missing as it has a better approach and single responsibility is more efficient even though it increases code base. If you wanted a set theory naming convention could have There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
if s == nil || s.m == nil { | ||
return nil, compare // All are unmatched | ||
} | ||
s.mu.RLock() | ||
defer s.mu.RUnlock() | ||
for _, sub := range compare { | ||
if found := s.get(sub); found != nil { | ||
matched = append(matched, found) | ||
} else { | ||
unmatched = append(unmatched, sub) | ||
} | ||
} | ||
return | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.