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:
|
||||
}
|
||||
|
||||
|
||||
@@ -8,3 +8,9 @@ type Channel struct {
|
||||
EventName string `bson:"eventName,omitempty"`
|
||||
LocationName string `bson:"locationName,omitempty"`
|
||||
}
|
||||
|
||||
// IsChangeObject is an interface implementation to identify it as a valid
|
||||
// ChangeObject in GQL.
|
||||
func (*Channel) IsChangeObject() {
|
||||
panic("this method is a dummy, and so is its caller")
|
||||
}
|
||||
@@ -20,3 +20,9 @@ type Chapter struct {
|
||||
func (chapter *Chapter) CanComment() bool {
|
||||
return !chapter.CommentsLocked && chapter.CommentMode.IsEnabled()
|
||||
}
|
||||
|
||||
// IsChangeObject is an interface implementation to identify it as a valid
|
||||
// ChangeObject in GQL.
|
||||
func (*Chapter) IsChangeObject() {
|
||||
panic("this method is a dummy, and so is its caller")
|
||||
}
|
||||
@@ -29,3 +29,9 @@ func (character *Character) HasNick(nick string) bool {
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
// IsChangeObject is an interface implementation to identify it as a valid
|
||||
// ChangeObject in GQL.
|
||||
func (*Character) IsChangeObject() {
|
||||
panic("this method is a dummy, and so is its caller")
|
||||
}
|
||||
@@ -15,3 +15,9 @@ type Comment struct {
|
||||
EditedDate time.Time `bson:"editeddDate"`
|
||||
Source string `bson:"source"`
|
||||
}
|
||||
|
||||
// IsChangeObject is an interface implementation to identify it as a valid
|
||||
// ChangeObject in GQL.
|
||||
func (*Comment) IsChangeObject() {
|
||||
panic("this method is a dummy, and so is its caller")
|
||||
}
|
||||
@@ -14,3 +14,9 @@ type File struct {
|
||||
Author string `bson:"author" json:"author"`
|
||||
URL string `bson:"url,omitempty" json:"url,omitempty"`
|
||||
}
|
||||
|
||||
// IsChangeObject is an interface implementation to identify it as a valid
|
||||
// ChangeObject in GQL.
|
||||
func (*File) IsChangeObject() {
|
||||
panic("this method is a dummy, and so is its caller")
|
||||
}
|
||||
@@ -14,3 +14,9 @@ type Log struct {
|
||||
Open bool `bson:"open"`
|
||||
CharacterIDs []string `bson:"characterIds"`
|
||||
}
|
||||
|
||||
// IsChangeObject is an interface implementation to identify it as a valid
|
||||
// ChangeObject in GQL.
|
||||
func (*Log) IsChangeObject() {
|
||||
panic("this method is a dummy, and so is its caller")
|
||||
}
|
||||
@@ -12,3 +12,9 @@ type Post struct {
|
||||
Text string `bson:"text"`
|
||||
Position int `bson:"position"`
|
||||
}
|
||||
|
||||
// IsChangeObject is an interface implementation to identify it as a valid
|
||||
// ChangeObject in GQL.
|
||||
func (*Post) IsChangeObject() {
|
||||
panic("this method is a dummy, and so is its caller")
|
||||
}
|
||||
@@ -16,3 +16,9 @@ type Story struct {
|
||||
FictionalDate time.Time `bson:"fictionalDate,omitempty"`
|
||||
UpdatedDate time.Time `bson:"updatedDate"`
|
||||
}
|
||||
|
||||
// IsChangeObject is an interface implementation to identify it as a valid
|
||||
// ChangeObject in GQL.
|
||||
func (*Story) IsChangeObject() {
|
||||
panic("this method is a dummy, and so is its caller")
|
||||
}
|
||||
@@ -10,3 +10,9 @@ type Tag struct {
|
||||
func (tag *Tag) Equal(other Tag) bool {
|
||||
return tag.Kind == other.Kind && tag.Name == other.Name
|
||||
}
|
||||
|
||||
// IsChangeObject is an interface implementation to identify it as a valid
|
||||
// ChangeObject in GQL.
|
||||
func (*Tag) IsChangeObject() {
|
||||
panic("this method is a dummy, and so is its caller")
|
||||
}
|
||||
Reference in New Issue
Block a user