Documentation
¶
Overview ¶
Package client is how every presentation (CLI now, TUI in 1c, and the shared rules the web console relies on) reaches the local OVDB server.
Local is the single place that decides, for each capability, whether to ask the running server or to read state files, and it applies one rule set on the way: a running server started for a different OVDB home — or on a port other than an explicitly requested one — is a server_config_mismatch; a version difference is a one-line notice; a command that needs the server starts it unless told not to. Every method returns the schema-1 document bytes a presentation renders or prints as --json.
See decision 0006 and spec/features/local-server-and-web-console (REQ:client-values-and-mismatch, REQ:auto-start, REQ:version-mismatch-notice).
Index ¶
- Constants
- func NotRunning() *envelope.Error
- func VersionNotice(serverVersion, clientVersion string) string
- type Client
- type Local
- func (l *Local) Config(ctx context.Context) ([]byte, error)
- func (l *Local) Connect(ctx context.Context, noStart bool) (*Client, error)
- func (l *Local) LoginLink(ctx context.Context, noStart bool) ([]byte, error)
- func (l *Local) Restart(ctx context.Context) (StartOutcome, error)
- func (l *Local) Server(ctx context.Context) ([]byte, error)
- func (l *Local) SetConfig(ctx context.Context, change setup.ConfigChange) ([]byte, error)
- func (l *Local) Start(ctx context.Context) (StartOutcome, error)
- func (l *Local) Status(ctx context.Context) ([]byte, error)
- func (l *Local) Stop(ctx context.Context) (StopOutcome, error)
- type Response
- type StartOutcome
- type StopOutcome
Constants ¶
const ( ServerPath = "/api/local/v1/server" StatusPath = "/api/local/v1/status" LoginLinksPath = "/api/local/v1/login-links" ConfigPath = "/api/local/v1/config" )
Local API paths.
Variables ¶
This section is empty.
Functions ¶
func NotRunning ¶
NotRunning is server_not_running for --no-start.
func VersionNotice ¶
VersionNotice is the one line printed when client and server versions differ (REQ:version-mismatch-notice).
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client talks to one running local server with its instance secret.
type Local ¶
type Local struct {
Dirs paths.Dirs
Version string // this client's version
Port int // resolved with setup.ResolvePort
ExplicitPort bool // --port or OVDB_PORT
// Command builds the detached server process for a port.
Command func(port int) *exec.Cmd
// Notices receives one-line notices: auto-start, version mismatch,
// directory warnings, unreadable runtime files. Never stdout with --json.
Notices io.Writer
}
Local is one presentation's view of this home's local server.
func (*Local) Connect ¶
Connect returns a client for the running server, starting it when needed unless noStart (REQ:auto-start).
func (*Local) LoginLink ¶
LoginLink creates a console login link, starting the server unless noStart.
func (*Local) Restart ¶
func (l *Local) Restart(ctx context.Context) (StartOutcome, error)
Restart stops the server, treating an unconfirmable stale process as not running, and starts it again on the resolved port.
func (*Local) Server ¶
Server is the server document: from the server when it runs, otherwise built from files (a pure read that never starts anything).
func (*Local) SetConfig ¶
SetConfig changes a setting through the running server. With no server it writes as the home's single writer under the locks instead of starting one, because the fix offered for a busy port (`ovdb config set server.port N`) must work while that port keeps the server from starting.
func (*Local) Start ¶
func (l *Local) Start(ctx context.Context) (StartOutcome, error)
Start starts the server, or reports the one already running.
type Response ¶
Response is a local API response; Body is kept byte for byte so --json prints exactly what the API returned.
type StartOutcome ¶
StartOutcome is a start's server document.
type StopOutcome ¶
StopOutcome is a stop's server document.