Skip to content

Commit

Permalink
improve doc comments for logBuffer & logClient
Browse files Browse the repository at this point in the history
  • Loading branch information
barrettj12 committed Jul 4, 2023
1 parent 1b7995b commit 1f4fe21
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions internals/overlord/logstate/gatherer.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,14 +134,23 @@ func (g *logGatherer) stop() {
close(g.cancel)
}

// logBuffer is an interface which ...
// logBuffer is an interface encapsulating format-specific buffering of log
// messages. E.g. a logBuffer for Loki would encode the log messages in the
// JSON format expected by Loki.
// A logBuffer's methods may not be concurrency-safe. Callers should protect
// the logBuffer using a sync.Mutex.
type logBuffer interface {
Write(servicelog.Entry)
IsEmpty() bool
IsFull() bool

// Write encodes the provided log message and adds it to the buffer.
Write(servicelog.Entry) // TODO: return error?

// Request returns an io.Reader which can be used as the body of a request
// to the remote log target.
Request() (io.Reader, error)

// Reset empties the buffer.
Reset()
}

Expand All @@ -150,6 +159,8 @@ func newLogBuffer(target *plan.LogTarget) logBuffer {
return nil
}

// logClient is implemented by a client to a specific type of log target.
// It sends requests using the protocol preferred by that log target.
type logClient interface {
Send(io.Reader) error
}
Expand Down

0 comments on commit 1f4fe21

Please sign in to comment.