Documentation
¶
Index ¶
- Constants
- Variables
- func BuildTarget(spec Spec, values FormValues) (string, bool)
- func Matches(target string) []targetMatch
- func Open(ctx context.Context, pluginID, target string) (sharedsql.Opened, error)
- func Register(spec Spec)
- func RegisterShim(shim Shim) error
- func ResolvePlugin(target string) (string, 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 through the callback carried by spec.
func Matches ¶ added in v0.11.0
func Matches(target string) []targetMatch
Matches returns every plugin instance whose target pattern addresses target. Results are sorted by plugin ID, never by load order.
func Open ¶
Open connects to target through the explicitly selected plugin ID and returns its schema for the initial workbench view.
func Register ¶
func Register(spec Spec)
Register adds a plugin instance to the registry. Plugin IDs are unique; database families and target prefixes may be shared.
func RegisterShim ¶
RegisterShim installs one plugin-backed driver into the registry.
func ResolvePlugin ¶ added in v0.11.0
ResolvePlugin deterministically chooses the plugin for a direct target. Unprefixed targets use the sqlite plugin; a prefixed target must have exactly one matching plugin instance.
func ValidateShim ¶
ValidateShim checks registration invariants without installing the shim.
func ValidateShimReplacement ¶
ValidateShimReplacement validates a restart replacement against all other registered plugin instances while excluding its own plugin ID.
Types ¶
type Capabilities ¶
type Capabilities struct {
Name string `json:"name"`
Display string `json:"display"`
// Driver is the non-unique database-family key. When omitted, it
// normalizes to Name for compatibility with existing v1 plugins.
Driver string `json:"driver,omitempty"`
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 {
PluginID string
Driver string
Display string
Targets []TargetPattern
Open func(ctx context.Context, target string) (sharedsql.Service, error)
BuildTarget TargetBuilder
Form *FormSpec
QueryLanguage QueryLanguage
Workspace *sharedsql.WorkspaceCapability
// Source identifies how the plugin is hosted ("builtin" or "external").
// Built-ins remain child processes; this is presentation metadata only.
Source string
}
Spec describes one registered plugin instance: the database family it serves, the target forms it addresses, and the callbacks that cross the plugin boundary. PluginID is unique; Driver is deliberately non-unique.
func FormPlugins ¶ added in v0.11.0
func FormPlugins() []Spec
FormPlugins returns registered plugin instances that advertise a form, in registry order so built-ins retain their stable selector order.
func PluginsByDriver ¶ added in v0.11.0
PluginsByDriver returns all registered plugin instances serving one family, in deterministic plugin-ID 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 plugin (without its form prefix).
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. |