-
Notifications
You must be signed in to change notification settings - Fork 928
feat(codersdk/agentsdk): add StartupLogsSender
and StartupLogsWriter
#8129
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
feat(codersdk/agentsdk): add StartupLogsSender
and StartupLogsWriter
#8129
Conversation
StartupLogsSender
and StartupLogsWriter
StartupLogsSender
and StartupLogsWriter
6b97ede
to
8ce4e7d
Compare
This commit adds two new `agentsdk` functions, `StartupLogsSender` and `StartupLogsWriter` that can be used by any client looking to send startup logs to coderd. We also refactor the `agent` to use these new functions. As a bonus, agent startup logs are separated into "info" and "error" levels to separate stdout and stderr.
8ce4e7d
to
5e48ee1
Compare
}() | ||
|
||
var queue []StartupLog | ||
sendLog = func(callCtx context.Context, log ...StartupLog) error { |
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.
Review: Technically we don't need callCtx
here right now because we allow the queue/backlog to grow without bounds, but if we need to limit this in the future, accepting a context here makes it much nicer for the user of the SDK, letting them abort if it takes too long.
ec496f8
to
cdb64e2
Compare
"github.com/coder/retry" | ||
) | ||
|
||
type startupLogsWriter struct { |
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.
Review: I went a round of back-and-forth on making this concurrently safe. Ultimately I opted to revert the concurrency safety in favor of keeping the implementation as short/simple as possible (cdb64e2
(#8129)).
6435f12
to
9ac5d60
Compare
Co-authored-by: Marcin Tojek <mtojek@users.noreply.github.com>
Related: #7767 |
As proposed in #8084 (note that the implementation had to change slightly to accommodate the additional use-case):
This commit adds two new
agentsdk
functions,StartupLogsSender
andStartupLogsWriter
that can be used by any client looking to sendstartup logs to coderd.
We also refactor the
agent
to use these new functions.As a bonus, agent startup logs are separated into "info" and "error"
levels to separate stdout and stderr.