Documentation
¶
Index ¶
- Constants
- func ListDatabases(ctx context.Context, db *sql.DB, driver string) ([]string, error)
- func NewMemoryCache() *inspection.Memo[Catalog]
- type Cache
- type Catalog
- type Column
- type ForeignKey
- type Index
- type Limits
- type Options
- type Relation
- type Routine
- type RoutineParameter
- type Schema
- type Trigger
Constants ¶
const ( DefaultMaxRelations = native.DefaultMaxRelations DefaultMaxColumns = native.DefaultMaxColumns DefaultMaxMetadata = native.DefaultMaxMetadata DefaultMaxRoutines = native.DefaultMaxRoutines DefaultMaxDefinitionBytes = native.DefaultMaxDefinitionBytes )
Variables ¶
This section is empty.
Functions ¶
func ListDatabases ¶
func NewMemoryCache ¶ added in v0.1.35
func NewMemoryCache() *inspection.Memo[Catalog]
NewMemoryCache creates an isolated cache with the SQL freshness and capacity policy. Reuse it across inspections; nil Options.Cache uses the shared default. Like all Memos, it registers with inspection.Stats and inspection.Flush.
Types ¶
type Cache ¶ added in v0.1.35
type Cache interface {
Get(context.Context, inspection.GetOptions[Catalog]) (inspection.Result[Catalog], error)
}
Cache owns catalogue storage and fill coordination. Implementations must honor GetOptions.Refresh and inspection.WithRefresh, coalesce concurrent fills, and return cache metadata, including stale values alongside refresh errors. Load runs locally; a remote implementation stores the Catalog, not the callback. *inspection.Memo[Catalog] implements this interface.
type Catalog ¶
type Catalog struct {
Driver string `json:"driver"`
Database string `json:"database,omitempty"`
Capabilities connection.BackendCapabilities `json:"capabilities"`
Databases []string `json:"databases,omitempty"`
DefaultSchema string `json:"defaultSchema,omitempty"`
Schemas []Schema `json:"schemas"`
Truncated bool `json:"truncated,omitempty"`
TruncateReason string `json:"truncateReason,omitempty"`
Cache *inspection.CacheMetadata `json:"cache,omitempty"`
}
func Inspect ¶
Inspect returns a cached catalogue of the current database, with freshness metadata. Pass either a caller-owned db or Options.Open and identify its connection, authorization context, revision, and selected database in CacheKey. Keep a caller-owned db open while background refreshes may use it. Returned slices and nested pointers are shared cache values and must be treated as read-only. A failed explicit refresh returns the last known catalogue alongside its error.
type ForeignKey ¶ added in v0.1.32
type ForeignKey = native.ForeignKey
type Options ¶ added in v0.1.35
type Options struct {
// CacheKey must isolate the connection, authorization/context scope, selected
// database, and connection revision. Change it when credentials or connection
// settings change. Use an opaque identity, never credentials or a raw DSN.
// Driver and effective limits are appended by Inspect.
CacheKey string
// Cache replaces the default process-lifetime memory cache; it is not layered
// with it. A shared backend needs CacheKey values stable across processes.
Cache Cache
Refresh bool
// Limits bounds the catalogue; zero fields use the defaults.
Limits Limits
// Open is used instead of db for short-lived connections. It is called only
// on a fill, with the fill context, and Inspect closes the returned pool.
Open func(context.Context) (*sql.DB, error)
}
Options identifies the source independently of transient SQL pool handles.
type RoutineParameter ¶ added in v0.1.32
type RoutineParameter = native.RoutineParameter
Directories
¶
| Path | Synopsis |
|---|---|
|
Package inspector preserves the commons-db API; implementations live in sqlglot-go.
|
Package inspector preserves the commons-db API; implementations live in sqlglot-go. |
|
Package snapshot preserves the commons-db API; implementations live in sqlglot-go.
|
Package snapshot preserves the commons-db API; implementations live in sqlglot-go. |