event: golint updates for this or self warning (#16631)
* event/*: golint updates for this or self warning * event/*: golint updates for this or self warning, pr updated per feedback
This commit is contained in:
parent
fd3da7c69d
commit
60b433ab84
@ -45,37 +45,37 @@ func New() *Filters {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *Filters) Start() {
|
func (f *Filters) Start() {
|
||||||
go self.loop()
|
go f.loop()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *Filters) Stop() {
|
func (f *Filters) Stop() {
|
||||||
close(self.quit)
|
close(f.quit)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *Filters) Notify(filter Filter, data interface{}) {
|
func (f *Filters) Notify(filter Filter, data interface{}) {
|
||||||
self.ch <- FilterEvent{filter, data}
|
f.ch <- FilterEvent{filter, data}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *Filters) Install(watcher Filter) int {
|
func (f *Filters) Install(watcher Filter) int {
|
||||||
self.watchers[self.id] = watcher
|
f.watchers[f.id] = watcher
|
||||||
self.id++
|
f.id++
|
||||||
|
|
||||||
return self.id - 1
|
return f.id - 1
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *Filters) Uninstall(id int) {
|
func (f *Filters) Uninstall(id int) {
|
||||||
delete(self.watchers, id)
|
delete(f.watchers, id)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *Filters) loop() {
|
func (f *Filters) loop() {
|
||||||
out:
|
out:
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case <-self.quit:
|
case <-f.quit:
|
||||||
break out
|
break out
|
||||||
case event := <-self.ch:
|
case event := <-f.ch:
|
||||||
for _, watcher := range self.watchers {
|
for _, watcher := range f.watchers {
|
||||||
if reflect.TypeOf(watcher) == reflect.TypeOf(event.filter) {
|
if reflect.TypeOf(watcher) == reflect.TypeOf(event.filter) {
|
||||||
if watcher.Compare(event.filter) {
|
if watcher.Compare(event.filter) {
|
||||||
watcher.Trigger(event.data)
|
watcher.Trigger(event.data)
|
||||||
@ -86,10 +86,10 @@ out:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *Filters) Match(a, b Filter) bool {
|
func (f *Filters) Match(a, b Filter) bool {
|
||||||
return reflect.TypeOf(a) == reflect.TypeOf(b) && a.Compare(b)
|
return reflect.TypeOf(a) == reflect.TypeOf(b) && a.Compare(b)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *Filters) Get(i int) Filter {
|
func (f *Filters) Get(i int) Filter {
|
||||||
return self.watchers[i]
|
return f.watchers[i]
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user