-
Notifications
You must be signed in to change notification settings - Fork 487
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
Make loki.LogsReceiver an interface #4303
Conversation
// LogsReceiver is an interface providing `chan Entry` which is used for component | ||
// communication. | ||
type LogsReceiver chan Entry | ||
type LogsReceiver interface { | ||
Chan() chan Entry | ||
} | ||
|
||
type logsReceiver struct { | ||
entries chan Entry | ||
} | ||
|
||
func (l *logsReceiver) Chan() chan Entry { | ||
return l.entries | ||
} | ||
|
||
func NewLogsReceiver() LogsReceiver { | ||
return NewLogsReceiverWithChannel(make(chan Entry)) | ||
} | ||
|
||
func NewLogsReceiverWithChannel(c chan Entry) LogsReceiver { | ||
return &logsReceiver{ | ||
entries: c, | ||
} | ||
} |
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.
This is the main change - the rest is just making it work using it.
Might be best for a separate PR, but I am wondering if its possible to hide the underlying implementation and the interface be more generic while we are looking at it.
|
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.
LGTM
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.
LGTM
There's also some places where |
PR Description
In order to implement config converter we need to override how a components' export is tokenized.
prometheus.remote_write
- when we create a block for remote_write, we return anremotewrite.Exports
."prometheus.remote_write.default.receiver"
which is what we want.loki.LogsReceiver
is not an interface, so I ran into an issue when trying to implementpromtail
config conversion support. The problem can be seen in code in this draft PR.Proposed solution: make
loki.LogsReceiver
an interface.PR Checklist