Documentation
¶
Index ¶
- Constants
- Variables
- func BuildTarget(spec Spec, values FormValues) (string, bool)
- func Open(ctx context.Context, target string) (sharedsql.Opened, error)
- func Register(spec Spec)
- func RegisterShim(shim Shim) error
- func ValidateShim(shim Shim) error
- func ValidateShimReplacement(shim Shim) error
- type Capabilities
- type CustomWorkspaceView
- type FormField
- type FormFieldKind
- type FormOption
- type FormSpec
- type FormValidation
- type FormValues
- type QueryCommand
- type QueryLanguage
- type Shim
- type Spec
- type StandardWorkspaceTab
- type TargetBuilder
- type TargetPattern
- type WorkspaceCapability
- type WorkspaceViewKind
- type WorkspaceViewRequest
- type WorkspaceViewTarget
Constants ¶
const ( WorkspaceViewDatabase = sharedsql.WorkspaceViewDatabase WorkspaceViewSchema = sharedsql.WorkspaceViewSchema WorkspaceViewTable = sharedsql.WorkspaceViewTable )
Workspace view target kinds, aliased from the shared contract.
const ( StandardWorkspaceTabColumns = sharedsql.StandardWorkspaceTabColumns StandardWorkspaceTabIndexes = sharedsql.StandardWorkspaceTabIndexes StandardWorkspaceTabForeignKeys = sharedsql.StandardWorkspaceTabForeignKeys StandardWorkspaceTabDiagram = sharedsql.StandardWorkspaceTabDiagram )
Standard workspace tab keys, aliased from the shared contract.
Variables ¶
var SQLQueryLanguage = sharedsql.SQLQueryLanguage
SQLQueryLanguage is the legacy SQL default every driver without an explicit query language advertisement gets.
Functions ¶
func BuildTarget ¶
func BuildTarget(spec Spec, values FormValues) (string, bool)
BuildTarget serializes form values into the opener target body for spec's driver. ok=false when the driver has no form or no registered builder; the caller then falls back to the raw target field.
func Open ¶
Open connects to target and returns its schema for the initial workbench view. The driver group routes the target form to a registered driver; anything without a registered target form opens as SQLite after path resolution. The returned Opened carries the matched driver's query language (the SQLite fallback carries the legacy SQL default) and workspace tab capability.
func Register ¶
func Register(spec Spec)
Register adds a driver to the group. Driver names are unique: registering a duplicate name panics. Registration is init-time only — the group is fully populated before any Open call — but the lock keeps late in-process registration (tests, future shims) safe.
func RegisterShim ¶
RegisterShim installs a plugin-backed driver into the group, deriving the spec from the shim's declarative capabilities. Unlike Register, a misconfigured shim returns an error: a broken plugin must not take the app down. Formless drivers never register a target builder; the connection form then falls back to the raw target field, like a target-only driver. ValidateShim is the side-effect-free face of the same checks.
func ValidateShim ¶
ValidateShim checks the registration invariants RegisterShim enforces — a valid capability advertisement, a name unique against the registered drivers, and no cross-driver target-prefix overlap — without installing anything. It is the read-only face of shim registration for diagnostic tooling: validating the same shim any number of times, including duplicate identities and overlapping target prefixes across items, never mutates the driver group.
func ValidateShimReplacement ¶
ValidateShimReplacement validates a restart replacement whose driver is already registered under its own identity: the replacement must be self-consistent and must not conflict with any OTHER registered driver, while the entry's own registration is excluded — it is the registration being swapped in place, never duplicated. The caller is still responsible for requiring the replacement to keep the registered identity. Side-effect-free, like ValidateShim.
Types ¶
type Capabilities ¶
type Capabilities struct {
Name string `json:"name"`
Display string `json:"display"`
Targets []TargetPattern `json:"targets,omitempty"`
Form *FormSpec `json:"form,omitempty"`
// QueryLanguage advertises the query editor language for this
// driver, or nil when the plugin does not advertise one. The host
// normalizes nil and zero advertisements to the legacy SQL default
// at registration.
QueryLanguage *QueryLanguage `json:"query_language,omitempty"`
// WriteCapabilities advertises the optional row/document write
// interfaces a plugin's sessions implement. A zero value means no
// write support: the workbench never attempts row or document writes.
WriteCapabilities sharedsql.WriteCapabilities `json:"write_capabilities"`
// Workspace advertises the optional workspace tab metadata: the
// standard tabs beyond Query/Browse the driver supports and its
// ordered custom plain-data views. Absent (nil) keeps the legacy
// per-product tab policy exactly, so old plugins load unchanged.
Workspace *sharedsql.WorkspaceCapability `json:"workspace,omitempty"`
}
Capabilities is the serializable advertisement an external driver serves over its transport: identity, the target forms it addresses, the connection form description, and the query editor language — the DTO twin of Spec's data fields. Compiled-in drivers never travel as capabilities.
type CustomWorkspaceView ¶
type CustomWorkspaceView = sharedsql.CustomWorkspaceView
CustomWorkspaceView is one advertised custom plain-data tab.
type FormField ¶
type FormField struct {
Key string `json:"key"`
Title string `json:"title"`
Kind FormFieldKind `json:"kind"`
Placeholder string `json:"placeholder,omitempty"`
// Default is the well-known value shown when the field is blank
// (e.g. the default port).
Default string `json:"default,omitempty"`
Options []FormOption `json:"options,omitempty"`
// Validate is the rule applied to the field value; Error is the
// message shown when the rule fails. Kind and Validate are the Go
// iota constants — a transport must not reorder them.
Validate FormValidation `json:"validate"`
Error string `json:"error,omitempty"`
}
FormField describes one driver-specific connection-form field. Keys from the fixed set bind to the form's typed fields: host, port, username, password, database, target, tls. Any other key binds to the profile's generic extras.
type FormFieldKind ¶
type FormFieldKind int
FormFieldKind selects the widget for a connection-form field.
const ( // FormInput is a plain text input. FormInput FormFieldKind = iota // FormPassword is a masked text input. FormPassword // FormSelect is a select with fixed options. FormSelect )
type FormOption ¶
FormOption is one option of a select field.
type FormSpec ¶
type FormSpec struct {
Fields []FormField `json:"fields"`
// Prefix is prepended to the serialized target so Match can route it
// back to this driver ("" for SQLite).
Prefix string `json:"prefix,omitempty"`
}
FormSpec declaratively describes the connection form for one driver: which fields to show, in order, and the opener-target prefix. It carries no code, so it can cross the plugin DTO boundary unchanged.
type FormValidation ¶
type FormValidation int
FormValidation selects the validation rule for a form field.
const ( // FormNone disables validation. FormNone FormValidation = iota // FormRequired requires a non-blank value. FormRequired // FormPort accepts a blank value or a port number in 1-65535. FormPort )
type FormValues ¶
type FormValues struct {
Host string `json:"host,omitempty"`
Port string `json:"port,omitempty"`
User string `json:"user,omitempty"`
Pass string `json:"pass,omitempty"`
Database string `json:"database,omitempty"`
TLS string `json:"tls,omitempty"`
Extras map[string]string `json:"extras,omitempty"`
}
FormValues is the driver-facing view of the connection form: effective host/port, credentials, the database field, the selected TLS mode, and driver-specific extras (secret references resolved). It is the field-value DTO a transport sends to a plugin for target serialization.
type QueryCommand ¶
type QueryCommand = sharedsql.QueryCommand
QueryCommand is one static completion entry of a query language advertisement; the canonical type lives in the shared contract package and crosses the plugin DTO boundary unchanged.
type QueryLanguage ¶
type QueryLanguage = sharedsql.QueryLanguage
QueryLanguage is the query editor presentation of a driver's language; the canonical type and the legacy SQL default live in the shared contract package and cross the plugin DTO boundary unchanged.
type Shim ¶
type Shim interface {
Capabilities() Capabilities
BuildTarget(values FormValues) (string, bool)
Open(ctx context.Context, target string) (sharedsql.Service, error)
}
Shim is the in-process face of one plugin-backed driver: the declarative capabilities the plugin advertised, plus the dialect the transport owns — target serialization and service opening, both bridged over its wire protocol. A shim-registered driver is indistinguishable from a compiled-in one.
type Spec ¶
type Spec struct {
// Name identifies the driver. It is the profile driver name
// ("sqlite", "mysql", "postgres").
Name string
// Display is the human-readable driver label ("SQLite").
Display string
// Targets lists the target forms this driver addresses, in check
// order. Empty means the driver is reached only through the default
// fallback (SQLite).
Targets []TargetPattern
// Open opens a service for a matched target.
Open func(ctx context.Context, target string) (sharedsql.Service, error)
// Form describes the connection form for this driver, or nil when the
// driver has no form entry (MongoDB is opened by target URL only).
// Target serialization is a registered in-process builder (see
// BuildTarget), not part of the spec.
Form *FormSpec
// QueryLanguage describes how the query editor presents this
// driver's language. A zero value carries no advertisement (the UI
// falls back to its defaults); built-ins and registered shims always
// carry an explicit one.
QueryLanguage QueryLanguage
// Workspace advertises the driver's workspace tab capability: the
// standard tabs it supports beyond Query/Browse and its ordered
// custom plain-data views. Nil keeps the legacy per-product tab
// policy exactly; a present advertisement is authoritative for the
// tab row.
Workspace *sharedsql.WorkspaceCapability
}
Spec describes one driver in the group: which target forms address it, how to open a service for a matched target, and (optionally) how the connection form presents it. The group is the single place that maps target forms to backends; the workbench never switches on target prefixes itself. Everything but Open is plain data, so a spec crosses the plugin DTO boundary unchanged.
func FormDrivers ¶
func FormDrivers() []Spec
FormDrivers returns the registered drivers that offer a connection form, in registration order — the driver select's render order.
type StandardWorkspaceTab ¶
type StandardWorkspaceTab = sharedsql.StandardWorkspaceTab
StandardWorkspaceTab is one advertised standard tab key.
type TargetBuilder ¶
type TargetBuilder func(values FormValues) (string, bool)
TargetBuilder serializes connection-form values into the opener target body for one driver (no prefix). Built-in builders implement their dialect in the adapter packages; RegisterShim installs the builder of a plugin transport, receiving the same field-value DTO.
type TargetPattern ¶
type TargetPattern struct {
Prefix string `json:"prefix"`
// KeepTarget keeps the whole target for Open when true (URL scheme
// forms); when false the prefix is stripped.
KeepTarget bool `json:"keep_target,omitempty"`
}
TargetPattern declaratively addresses one target form of a driver. A pattern matches targets beginning with Prefix. Label prefixes end with ":" ("mysql:") and are stripped from the target passed to Open; scheme prefixes are full URL schemes ("postgres://") whose target is passed to Open unchanged. A scheme pattern must be declared before a label pattern that would otherwise shadow it ("redis://" before "redis:").
type WorkspaceCapability ¶
type WorkspaceCapability = sharedsql.WorkspaceCapability
WorkspaceCapability is a driver's workspace tab advertisement.
type WorkspaceViewKind ¶
type WorkspaceViewKind = sharedsql.WorkspaceViewKind
WorkspaceViewKind is a workspace view target kind.
type WorkspaceViewRequest ¶
type WorkspaceViewRequest = sharedsql.WorkspaceViewRequest
WorkspaceViewRequest is one custom view request.
type WorkspaceViewTarget ¶
type WorkspaceViewTarget = sharedsql.WorkspaceViewTarget
WorkspaceViewTarget is the active structured target of a view.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package plugin hosts external database driver plugins: child processes speaking the perk/v1 JSON-RPC stdio protocol.
|
Package plugin hosts external database driver plugins: child processes speaking the perk/v1 JSON-RPC stdio protocol. |
|
conformance
Package conformance runs the perk/v1 protocol conformance suite against one external plugin executable, outside Go's unit-test harness: fixture-driven protocol cases and generated transport cases, each in a fresh child spoken to as raw NDJSON-RPC on stdio.
|
Package conformance runs the perk/v1 protocol conformance suite against one external plugin executable, outside Go's unit-test harness: fixture-driven protocol cases and generated transport cases, each in a fresh child spoken to as raw NDJSON-RPC on stdio. |