Skip to content
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

Change to file tailing in pkg/resultstore #82

Open
applejag opened this issue Apr 7, 2022 · 0 comments
Open

Change to file tailing in pkg/resultstore #82

applejag opened this issue Apr 7, 2022 · 0 comments
Labels
chore Routine task, refactoring, or other changes not affecting end-users directly. prio/1 Low priority. "Nice to have"

Comments

@applejag
Copy link
Contributor

applejag commented Apr 7, 2022

The freezing logic in pkg/resultstore is messy. If it works, that's great. But a rewrite is in order.

My idea is that we should be able to reuse the readers for the entire reading process, and let all messages get piped through the file. In other words:

  • new log line comes in from pod
  • write log line to file
  • (wake up any sleeping readers)
  • reader continues to read and publishes all log lines via pubsub, reads until reaches EOF, and then goes to sleep
  • on freeze, wake up all readers and tell them to stop on EOF instead of go to sleep.

For wake up/sleep we could use channels. Ex:

func stuff() {
	sleepCh := make(chan struct{})

	// reader:
	go func() {
		for {
			// 1. read until EOF, and send all logs through pubsub
			// 2. check if should die or sleep
			<-sleepCh
		}
	}()

	// writer:
	go func() {
		for {
			// 1. wait for log line from pod
			// 2. write log line to file
			wakeUp(sleepCh)
		}
	}()
}

func wakeUp(ch chan struct{}) {
	select {
	case ch<-struct{}{}:
	default:
	}
}

Originally posted by @jilleJr in #77 (comment)

@applejag applejag added c/worker Component: wharf-cmd-worker prio/1 Low priority. "Nice to have" chore Routine task, refactoring, or other changes not affecting end-users directly. and removed c/worker Component: wharf-cmd-worker labels Apr 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
chore Routine task, refactoring, or other changes not affecting end-users directly. prio/1 Low priority. "Nice to have"
Projects
None yet
Development

No branches or pull requests

1 participant