Documentation
¶
Overview ¶
Package diragent implements the client part of the directory agent protocol. It handles connecting to the server via websocket, authentication, and relaying messages from the server to a child process (implemented by RunWorker) and back.
Index ¶
Constants ¶
const ( // DefaultMaxConcurrentRequests is the default number of worker/connection lanes. DefaultMaxConcurrentRequests = 3 // MaximumConcurrentRequests is the maximum supported number of worker/connection lanes. MaximumConcurrentRequests = 16 )
🤖
Variables ¶
This section is empty.
Functions ¶
func NewLogger ¶ added in v0.1.30
NewLogger builds a logger that writes every record to w in the given format, regardless of level. Use it for a process whose stdout is reserved for something other than log output (such as a directory agent worker, whose stdout carries the JSON request/response protocol), so all of its own messages -- errors included -- have to share the one stream it can safely write to.
func RunWorker ¶
RunWorker implements the worker process for a directory agent. It handles accepting and processing requests from the server. It returns when ctx is canceled or when the parent closes stdin.
logger is used only for conditions that have nowhere else to go, such as a provider panic: the worker's stdout already carries the JSON request/response protocol, so its own messages (errors included) share its stderr. A nil logger defaults to plain text on os.Stderr. 🤖
Types ¶
type LogFormat ¶ added in v0.1.30
type LogFormat string
LogFormat selects how a directory agent process renders its own log messages.
func ParseLogFormat ¶ added in v0.1.30
ParseLogFormat validates a --log-format flag value. An empty string is accepted and normalized to LogFormatText.
type Service ¶
type Service struct {
Server string
AuthToken string
DirID string
// MaxConcurrentRequests sets the number of worker/connection lanes.
// Zero means one lane.
MaxConcurrentRequests int // 🤖
// Command starts the worker through the platform shell: cmd.exe /c on Windows
// or /bin/sh -c elsewhere. Use it for operator-supplied commands that may contain
// shell syntax. It is ignored when Argv is non-empty.
Command string
// Argv starts the worker directly without a shell. Argv[0] is the executable
// and the remaining elements are passed as individual arguments. Use it for
// programmatically constructed invocations so argument boundaries are preserved.
// Argv takes precedence over Command.
Argv []string
Env map[string]string
Stdout io.Writer // 🤖 defaults to os.Stdout; carries the agent's own info/debug messages
Stderr io.Writer
HTTPClient *http.Client
Verbose bool
// ListenStatus, if non-empty, is the address (e.g. "0.0.0.0:8000") for an HTTP
// server exposing a Kubernetes-style "/ready" liveness/readiness endpoint. It is
// disabled when empty. 🤖
ListenStatus string
// LogFormat selects how the agent renders its own log messages: text
// (the default) or json. 🤖
LogFormat LogFormat
// contains filtered or unexported fields
}
Service runs the parent process for the directory agent. It connects to the server and relays messages between the server (via websocket) and the child process (via stdin/stdout).