Skip to content

Commit

Permalink
fix: listener deletion (#73)
Browse files Browse the repository at this point in the history
  • Loading branch information
xzchaoo authored Sep 15, 2023
1 parent 1a791cd commit d4c3127
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
6 changes: 6 additions & 0 deletions pkg/collectconfig/executor/logstream/logstream_g.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,10 +147,16 @@ func (f *GLogStream) RemoveListener(listener Listener, cursor int64) {

listeners := make([]Listener, 0, len(f.Listeners))
for _, l := range f.Listeners {
// The implementations of Listener must not be empty structs.
// They will result in same object address when their instances are converted to Listener interface,
// which leads to the following 'l!=listener' always returns false
if l != listener {
listeners = append(listeners, l)
}
}
if x := len(f.Listeners) - len(listeners); x > 1 {
logger.Errorz("remove multi listeners", zap.String("key", f.Key), zap.Int("old", len(f.Listeners)), zap.Int("new", len(listeners)))
}
f.Listeners = listeners

for i := cursor; i < f.Cursor; i++ {
Expand Down
5 changes: 3 additions & 2 deletions pkg/collectconfig/executor/pipeline.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ const (
)

type (
listenerImpl struct{}
listenerImpl struct {
_ int
}

// LogPipeline is responsible for detecting log inputs(see inputsManager) , scheduling pulling logs task, and put logs to consumer.
LogPipeline struct {
Expand Down Expand Up @@ -162,7 +164,6 @@ func (iw *inputWrapper) read() (*logstream.ReadResponse, int64, error) {

func (l *listenerImpl) Changed(ls logstream.LogStream, lcursor int64) {
}

func (p *LogPipeline) Key() string {
return p.st.CT.Key
}
Expand Down

0 comments on commit d4c3127

Please sign in to comment.