-
Notifications
You must be signed in to change notification settings - Fork 309
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
Follow with filter #152
base: main
Are you sure you want to change the base?
Follow with filter #152
Conversation
this allows users to pull data from journal entries that aren't MESSAGE
…return all fields
Sorry for not being responsive, (was not cc'd, so I lost this PR in notification). |
// holds journal events to process. tightly bounded for now unless there's a | ||
// reason to unblock the journal watch routine more quickly | ||
events := make(chan int, 1) | ||
pollDone := make(chan bool, 1) |
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.
Maybe change the size to 0, and close the channel instead of sending a bool?
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.
Or better, can we reuse these channels ?
Ref rkt/rkt#2041 as this is an API break change. cc @derekparker |
yikes sorry about being so non-responsive and thanks for the ping. it turns out we did not end up needing this functionality. I am more than happy to finish work on this or close it, depending on if you think this patch would be helpful or not. |
errChan := make(chan error, 1) | ||
go func() { | ||
for { | ||
kvMap := make(map[string]interface{}) |
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.
Why value type is interface{}
? Aren't strings enough?
@faiq I think it would be nice to have some portions of this. Point (1) looks good and point (3) makes the Regarding point (2) I think the library shouldn't be concerned about this. And once the other two points are in place, it should be easy for consumers to just provide their own filtering wrapper. |
Sorry I'm so slow at responding to this 😞 lots of work makes it hard to contribute to open source. regarding why we're sending i can probably take out the enumerating logic for a call to how does this all sound? |
I'm not completely sure I'm understanding your proposal. Current API will return you either a
Just to be clear, who will be performing the filtering? Do you need go-systemd to filter fields, or will the receiver take care of that? I was suggesting the latter, but I may understand in some performance-related scenarios the former may be interesting too... |
Okay so this is a combination of my last 2 pull requests: #149 and #151 and I think this provides really what an end user would want.
So let me describe the changes here:
This allows more flexibility in use cases as described here:
If I use a context, its more clear that I want to cancel processing of the logs rather than sending a time. Alternatively if someone wants to finish processing at a certain time, they can still do so. All they would have to do is send a ctx.Done() whenever the time hts
It's very reasonable for someone to want the entire journal entry, rather than just the message field. In fact, we use the Send() method from the journal library https://github.com/coreos/go-systemd/blob/master/journal/journal.go#L75 to write custom log fields for our programs into journald. It's only suitable that we should be able to pull them out for later processing
msgs chan<- map[string]interface{}
This allows us to read all fields from the jorunal without worrying about the type and send them asynchronously without having to marshal and unmarshal the entries
Willing to close #151 in favor of this.
Thanks for all the help