gqlgen Squashed commit of the following: commit162ccf6bfbAuthor: Gisle Aune <dev@gisle.me> Date: Fri May 17 11:51:23 2019 +0200 The great module madness continus, now with pointers. commit7e3dc49635Author: Gisle Aune <dev@gisle.me> Date: Thu May 16 15:57:08 2019 +0200 Basic stuff, doesn't compile
This commit is contained in:
@@ -12,13 +12,13 @@ var subList []*subscription
|
||||
|
||||
type subscription struct {
|
||||
Keys map[string]bool
|
||||
Channel chan<- models.Change
|
||||
Channel chan<- *models.Change
|
||||
WildCard bool
|
||||
}
|
||||
|
||||
// Subscribe subscribes to all changes.
|
||||
func Subscribe(ctx context.Context, keys []models.ChangeKey, wildcard bool) <-chan models.Change {
|
||||
channel := make(chan models.Change, 64)
|
||||
func Subscribe(ctx context.Context, keys []models.ChangeKey, wildcard bool) <-chan *models.Change {
|
||||
channel := make(chan *models.Change, 64)
|
||||
sub := &subscription{
|
||||
Keys: make(map[string]bool, len(keys)),
|
||||
Channel: channel,
|
||||
@@ -58,16 +58,18 @@ func pushToSubscribers(change models.Change) {
|
||||
subMutex.Lock()
|
||||
SubLoop:
|
||||
for _, sub := range subList {
|
||||
changeCopy := change
|
||||
|
||||
if sub.WildCard && change.Listed {
|
||||
select {
|
||||
case sub.Channel <- change:
|
||||
case sub.Channel <- &changeCopy:
|
||||
default:
|
||||
}
|
||||
} else {
|
||||
for _, key := range keys {
|
||||
if sub.Keys[key] {
|
||||
select {
|
||||
case sub.Channel <- change:
|
||||
case sub.Channel <- &changeCopy:
|
||||
default:
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user