Documentation
¶
Overview ¶
Package userdata is the state dbc keeps for the user between sessions: the query history, the editor's per-database SQL consoles (and the single editor buffer they replaced), the assistant's conversations and the terminal UI's schema picks, all under ~/.config/dbc.
It started life inside the former tview UI (package ui, since removed), and kept that UI's on-disk format — same paths, same JSON-lines shape — so history and the scratchpad written by older dbc builds still load.
Index ¶
- Constants
- Variables
- func BufferFile() string
- func ChatTitle(msgs []ChatMsg) string
- func ChatsDir() string
- func ConsolePath(root string, d ConsoleDB, name string) string
- func ConsoleRev(text string, exists bool) string
- func ConsolesDir() string
- func DeleteConsole(root string, d ConsoleDB, name string) error
- func DescOf(src []byte) string
- func FlatConsoleFile(root, host, database string) string
- func HistoryFile() string
- func LayoutFile() string
- func ListConsoles(root string, d ConsoleDB, flat string) []string
- func LoadBuffer(path string) string
- func LoadConsole(path string) (text string, exists bool)
- func LoadPicks(path string) map[string]SchemaPick
- func MovePicks(path string, rename func(conn string) (to string, ok bool)) error
- func NewChatID(now time.Time) string
- func NextConsoleName(taken []string) string
- func PicksFile() string
- func PruneRuns(dir, kind, name string, keep int, live func(RunHead) bool) (int, error)
- func ReadJob(dir, name string) (text, rev string, err error)
- func ReadPipeline(dir, name string) (text, rev string, err error)
- func ReadPlugin(dir, name string) (text, rev string, err error)
- func ReadRun(dir, id string) ([]byte, time.Time, error)
- func ReadScript(dir, name string) (text, rev string, err error)
- func RemoveChat(dir, id string) error
- func RenameConsole(root string, d ConsoleDB, from, to string) error
- func RenameJob(dir, from, to string) error
- func RenamePipeline(dir, from, to string) error
- func RenamePlugin(dir, from, to string) error
- func RenameScript(dir, from, to string) error
- func RestoreJob(dir, id, to string) (string, error)
- func RestorePipeline(dir, id, to string) (string, error)
- func RestorePlugin(dir, id, to string) (string, error)
- func RestoreScript(dir, id, to string) (string, error)
- func RunsStamp(dir string) time.Time
- func SaveBuffer(path, text string) error
- func SaveChat(dir string, c Chat) error
- func SaveConsole(path, text string) error
- func SaveJob(dir, name, text, base string) (rev string, conflict bool, err error)
- func SaveLayout(path string, l Layout) error
- func SavePick(path, conn string, pick SchemaPick) error
- func SavePipeline(dir, name, text, base string) (rev string, conflict bool, err error)
- func SavePlugin(dir, name, text, base string) (rev string, conflict bool, err error)
- func SaveRun(dir, kind, name, id string, data []byte) error
- func SaveScript(dir, name, text, base string) (rev string, conflict bool, err error)
- func ScriptDesc(path string) string
- func TrashJob(dir, name string) (string, error)
- func TrashPipeline(dir, name string) (id string, err error)
- func TrashPlugin(dir, name string) (id string, err error)
- func TrashScript(dir, name string) (id string, err error)
- func ValidConsoleName(name string) bool
- func ValidJobName(name string) bool
- func ValidPipelineName(name string) bool
- func ValidPluginName(name string) bool
- func ValidRunID(id string) bool
- func ValidScriptName(name string) bool
- type Chat
- type ChatMeta
- type ChatMsg
- type ConsoleDB
- type Entry
- type History
- type JobInfo
- type Layout
- type LayoutTab
- type LayoutTabGroup
- type PipelineInfo
- type PipelineTrashInfo
- type PluginInfo
- type PluginTrashInfo
- type RunFilter
- type RunHead
- type SchemaPick
- type ScriptInfo
- type SpecTrashInfo
- type TrashInfo
Constants ¶
const ( // MaxChats caps how many conversations the directory keeps, trimmed // from the oldest. The feature is "the last few chats": an unbounded // archive would be a directory growing forever and a picker nobody can // scan. Thirty is a working week or two of questions. MaxChats = 30 // MaxChatTitle bounds a derived title, in runes. The picker row also // carries a date, a message count and sometimes a connection name, and // a title long enough to push those off the row costs more than it says. MaxChatTitle = 72 )
const DefaultConsole = "console"
DefaultConsole is the name of a database's first console.
const MaxJobBytes = 1 << 20
MaxJobBytes bounds what a save writes.
const MaxPipelineBytes = 1 << 20
MaxPipelineBytes bounds what a save writes.
const MaxScriptBytes = 1 << 20
MaxScriptBytes bounds what a save writes (and what dbc web checks). A script is a page of Go; a megabyte is a mistake (a pasted data file), not a script.
Variables ¶
var ( ErrJobExists = errors.New("a job by that name already exists") ErrBadJobName = errors.New("not a job name: letters, digits, . _ - ending in .json") )
ErrJobExists is a create, rename or restore onto a name the directory already has; ErrBadJobName a name ValidJobName refuses.
var ( ErrPipelineExists = errors.New("a pipeline by that name already exists") ErrBadPipelineName = errors.New("not a pipeline name: letters, digits, . _ - ending in .json") )
ErrPipelineExists is a create, rename or restore onto a name the directory already has; ErrBadPipelineName a name ValidPipelineName refuses.
var ErrBadScriptName = errors.New("not a script name: letters, digits, . _ - ending in .go")
ErrBadScriptName is a name ValidScriptName refuses.
var ErrConsoleExists = errors.New("a console by that name already exists")
ErrConsoleExists is a rename onto a name the database already has.
var ErrScriptExists = errors.New("a script by that name already exists")
ErrScriptExists is a create, rename or restore onto a name the scripts directory already has.
var RunKinds = []string{"job", "pipeline"}
RunKinds are the kinds of run a record may be.
Functions ¶
func BufferFile ¶
func BufferFile() string
BufferFile is where the editor buffer persists between sessions, under the user's config directory. It returns "" when no home directory is known, and the buffer simply does not persist.
func ChatTitle ¶
ChatTitle picks what a conversation is remembered by: the first line of the first thing the USER asked. Not the answer — the question is what the user scans a list for, and an answer's first line is usually a restatement or a preamble. Returns "" when there is no question; the caller decides how an untitled row reads.
func ChatsDir ¶
func ChatsDir() string
ChatsDir is where conversations persist, beside the history and the editor buffer. It returns "" when no home directory is known, and conversations then live only for the session.
func ConsolePath ¶ added in v0.6.0
ConsolePath is the file of console name of database d under root: "" when root is "" (persistence off) or any level is not a valid name.
func ConsoleRev ¶ added in v0.6.0
ConsoleRev is the revision of a console's text: a hash, so any writer — the TUI, another dbc web window, an editor outside dbc — changing the file changes it, with no counter to keep in step. A console with no file is revision "".
func ConsolesDir ¶ added in v0.6.0
func ConsolesDir() string
ConsolesDir is where the consoles live, beside the history and the legacy buffer. It returns "" when no home directory is known, and consoles then do not persist.
func DeleteConsole ¶ added in v0.6.0
DeleteConsole removes a console of database d. One with no file is already gone, which is success.
func DescOf ¶ added in v0.9.0
DescOf is a script's description, taken from the script itself so there is no sidecar file to keep in step: the first comment in the file, before the package clause, cut to its first sentence. Directives (//go:build) are not part of it — CommentGroup.Text drops them — so the comment may come before the build tag or after it.
// Copy myschema.mytable from ProdDr to dev. ─► "Copy myschema.mytable from ProdDr to dev." // More detail on the next line. //go:build ignore
It takes the source rather than a path so that a script not on disk (an embedded example) is described the same way.
func FlatConsoleFile ¶ added in v0.6.0
FlatConsoleFile is where the first consoles layout kept database on host's one console, directly under root — for ListConsoles to move in.
func HistoryFile ¶
func HistoryFile() string
HistoryFile is where the history persists, beside the editor buffer. It returns "" when no home directory is known, and history lives only for the session.
func LayoutFile ¶ added in v0.8.0
func LayoutFile() string
LayoutFile is where the TUI's layout persists, beside the schema picks. It returns "" when no home directory is known, and the layout lasts only for the run.
func ListConsoles ¶ added in v0.6.0
ListConsoles is the names of database d's consoles under root, in the order they are offered: DefaultConsole first, then "console-2", "console-3", … by number, then any other name alphabetically. A database with none lists none: a console only gets a file once it holds something (SaveConsole).
flat is the database's file in the first consoles layout (one file per database: FlatConsoleFile), "" when there is none to look for; such a file is moved in as DefaultConsole here.
func LoadBuffer ¶
LoadBuffer returns the persisted editor buffer, or "" when there is none.
func LoadConsole ¶ added in v0.6.0
LoadConsole returns a console's text and whether it has a file at all. The difference matters: a console emptied on purpose stays empty, where one never written may be seeded (from the legacy buffer.sql).
func LoadPicks ¶ added in v0.3.0
func LoadPicks(path string) map[string]SchemaPick
LoadPicks returns the saved picks, keyed by connection name ("<conn>" or a derived "<conn>/<database>"). A missing or unreadable file is no picks: losing them only means a connection opens on its default schema.
func MovePicks ¶ added in v0.8.0
MovePicks renames the picks rename maps to a new name (ok true), keeping the rest — a connection renamed in the TUI's form takes its pick, and those of its other databases ("<old>/analytics"), with it. Like SavePick it re-reads the file, so another TUI's picks since startup are kept.
func NewChatID ¶
NewChatID mints a conversation id from a wall-clock instant: sortable by construction, which lets a listing fall back on id order when a file's Updated stamp is missing, and legible to a user browsing the directory.
The tail is the full nanosecond field. ⟲ new saves the old conversation and the next save mints the new one's id moments later; a coarser tail could collide there, and a collision would overwrite the earlier file.
func NextConsoleName ¶ added in v0.6.0
NextConsoleName is the name a new console gets, given the names already taken: DefaultConsole if free, else the lowest free "console-n".
func PicksFile ¶ added in v0.3.0
func PicksFile() string
PicksFile is where the TUI's schema picks persist, beside the buffer. It returns "" when no home directory is known, and picks last only for the run.
func PruneRuns ¶ added in v0.13.0
PruneRuns keeps the newest keep records of one kind and name, removing the older ones — except a record live elsewhere (live reports it: a "running" record a process is still writing), which is never taken from under its writer. It returns how many it removed.
func ReadJob ¶ added in v0.13.0
ReadJob returns a job's text and revision; a missing one errors.Is fs.ErrNotExist.
func ReadPipeline ¶ added in v0.13.0
ReadPipeline returns a pipeline's text and revision. A missing one is an error that errors.Is fs.ErrNotExist.
func ReadPlugin ¶ added in v0.13.0
ReadPlugin returns a plugin file's text and revision.
func ReadRun ¶ added in v0.13.0
ReadRun is one record's bytes, found by id under any kind and name, and its file's modification time. A missing one errors.Is fs.ErrNotExist.
func ReadScript ¶ added in v0.9.0
ReadScript returns a script's text and revision. A missing script is an error that errors.Is fs.ErrNotExist.
func RemoveChat ¶
RemoveChat deletes one conversation. A missing file is success: the caller wanted it gone.
func RenameConsole ¶ added in v0.6.0
RenameConsole renames a console of database d. A console that was never written has no file, and renaming it is only a change of name: nothing to move, and success.
func RenamePipeline ¶ added in v0.13.0
RenamePipeline renames pipeline from to to, refusing to replace another.
func RenamePlugin ¶ added in v0.13.0
RenamePlugin renames a plugin file, refusing to replace another.
func RenameScript ¶ added in v0.9.0
RenameScript renames script from to to, refusing to replace another script. A rename that changes only the case of the name is allowed on a case-insensitive filesystem (macOS's default), where "to" already "exists" because it is the same file.
func RestoreJob ¶ added in v0.13.0
RestoreJob moves trashed job id back out of .trash, as to — or under its old name when to is "" — never replacing one.
func RestorePipeline ¶ added in v0.13.0
RestorePipeline moves trashed pipeline id back out of .trash, as to — or under its old name when to is "" — never replacing one.
func RestorePlugin ¶ added in v0.13.0
RestorePlugin moves trashed plugin file id back, as to (or its old name).
func RestoreScript ¶ added in v0.9.0
RestoreScript moves trashed script id back out of .trash, as to — or under its old name when to is "". It refuses to replace a script (ErrScriptExists): a user who made a new script by the old name restores the old one beside it, under another name. It returns the name used.
func RunsStamp ¶ added in v0.13.0
RunsStamp is the newest modification time among the record directories (<dir>/<kind>/<name>), zero when there are none. A record written, rewritten or pruned moves its directory's time — an atomic write renames a file into it — so a listing kept open (the TUI's Runs list) re-lists the records only when the stamp has moved: two directory reads and a stat per name, where a listing reads every directory, stats every record, and parses each one the heads cache does not hold.
func SaveBuffer ¶
SaveBuffer persists the editor buffer. The file is user-only: query scratchpads have a way of accumulating real values.
func SaveChat ¶
SaveChat writes c into dir as <id>.json, then trims the directory back to MaxChats. Rewriting the same id is the normal case — the live conversation is re-saved after every answer — so the write goes to a temp file that is renamed over the old one: a crash mid-write must not leave a half-written transcript where a readable one used to be.
An empty dir, id or message list is a no-op rather than an error. The caller saves unconditionally at teardown, and "there was no conversation" is not a failure.
The files are user-only, like the history: a conversation about a query carries the query, and on connections with ai_rows its result rows.
func SaveConsole ¶ added in v0.6.0
SaveConsole writes a console, user-only like the buffer it replaces. A console with nothing in it and no file yet is not written: looking at a database, or opening a console and leaving it empty, must not leave a file behind.
func SaveJob ¶ added in v0.13.0
SaveJob writes text as job name, made from revision base (SavePipeline's rules).
func SaveLayout ¶ added in v0.8.0
SaveLayout writes the layout, through a temp file renamed over the old one so a crash mid-write leaves the previous layout rather than a truncated file. Two TUIs quitting at once: the last one's layout wins, which is the one the user saw last.
func SavePick ¶ added in v0.3.0
func SavePick(path, conn string, pick SchemaPick) error
SavePick records one connection's pick in the file, keeping every other connection's.
It re-reads the file rather than writing the caller's map: two dbc TUIs can be open at once, each picking on its own connections, and writing a whole map loaded at startup would undo the other's picks since then. The write goes to a temp file renamed over the old one, so a crash mid-write leaves the old picks rather than a truncated file. (Two saves in the same instant can still lose one of them; a pick is a click, and the cost is a connection opening on its default schema once.)
The file is never pruned: an entry is a few bytes, and a connection that is gone from one config may be in another (-config).
func SavePipeline ¶ added in v0.13.0
SavePipeline writes text as pipeline name, made from revision base, by SaveScript's rules: "" creates and never overwrites; a changed file is a conflict (curRev is its revision now), not an error.
func SavePlugin ¶ added in v0.13.0
SavePlugin writes a plugin file by SaveScript's rules: base "" creates and never overwrites; a changed file is a conflict, not an error.
func SaveRun ¶ added in v0.13.0
SaveRun writes a run's record, replacing the last one written. The directories are 0700 and the file 0600: a record holds error texts, which may quote data.
func SaveScript ¶ added in v0.9.0
SaveScript writes text as script name, made from revision base:
base the file now → result
───── ───────────────────── ───────────────────────────────────
"" missing created (the directory too)
"" exists ErrScriptExists: a create never overwrites
rev has revision rev written
rev changed, or deleted conflict: nothing written, curRev is
the file's revision now ("" if gone)
On success rev is the new revision. A conflict is not an error: the caller shows the file's text and lets the user choose (as consoles do). To put back a script deleted elsewhere, save it again with base "".
The write is atomic (writeAtomic) and keeps an existing file's mode. A symlinked script is written through to its target, so the link stays a link. A new script is user-only (0600), as consoles are: scripts name connections and hold queries, which have a way of collecting real values.
func ScriptDesc ¶ added in v0.9.0
ScriptDesc is the description of the script at path (see DescOf); "" when the file cannot be read.
func TrashPipeline ¶ added in v0.13.0
TrashPipeline moves a pipeline into .trash and returns its trash ID.
func TrashPlugin ¶ added in v0.13.0
TrashPlugin moves a plugin file into .trash — where the loader does not look, so its plugin leaves the palette — and returns its trash ID.
func TrashScript ¶ added in v0.9.0
TrashScript moves a script into .trash and returns its trash ID. The ID carries the time in milliseconds, so trashing a script, making another by the same name and trashing that keeps both. Past trashMax, the oldest trashed scripts are deleted.
func ValidConsoleName ¶ added in v0.6.0
ValidConsoleName reports whether name may name a console, or be one level of a ConsoleDB: all three come from the browser as path segments and become file names.
func ValidJobName ¶ added in v0.13.0
ValidJobName reports whether name may name a job: the console-name rule for the stem, plus a required .json suffix.
func ValidPipelineName ¶ added in v0.13.0
ValidPipelineName reports whether name may name a pipeline: the console-name rule for the stem, plus a required .json suffix.
func ValidPluginName ¶ added in v0.13.0
ValidPluginName reports whether name may name a plugin file: a script name (letters, digits, . _ - ending in .go).
func ValidRunID ¶ added in v0.13.0
ValidRunID reports whether id is shaped like a run id, so it may name a file.
func ValidScriptName ¶ added in v0.9.0
ValidScriptName reports whether name may name a script: the console-name rule (console.go) for the stem, plus a required .go suffix. So a plain file name with nothing that could climb out of the directory, hide (a leading dot) or trip up another filesystem; ".go" alone has no stem, and "a..go" is refused as a console name ending in a dot is.
Types ¶
type Chat ¶
type Chat struct {
ID string `json:"id"`
Title string `json:"title"`
Agent string `json:"agent,omitempty"` // the backend's display name
Model string `json:"model,omitempty"` // the model's display name
Conn string `json:"conn,omitempty"` // the active connection at the last save
Started time.Time `json:"started"`
Updated time.Time `json:"updated"`
Msgs []ChatMsg `json:"msgs"`
}
Chat is one archived conversation.
func (Chat) RestoreNote ¶
RestoreNote is the transcript line shown when a saved conversation is reopened: what the user got back, and what they did not. A reopened conversation is a transcript, not a resumed agent session, and silence about that would let a follow-up get a confidently unrelated answer from a model that never saw the conversation. Both UIs show these words.
type ChatMeta ¶
type ChatMeta struct {
ID string
Title string
Agent string
Conn string
Updated time.Time
Count int // messages, so a row can say how much is in there
}
ChatMeta is the listing view: what a picker row needs, without the transcript. ListChats still reads whole files — they are few and small, and a partial parse would need a second schema to stay honest — but returning only this keeps a caller from holding every conversation in memory to draw a list of titles.
func ListChats ¶
ListChats returns the archived conversations newest first. A file that will not parse costs itself and nothing else: one truncated or hand-edited transcript must not take the whole list down with it. A missing directory is the common case — a user who has never asked anything — and is not an error.
type ChatMsg ¶
ChatMsg is one transcript entry. Role is a string ("user", "agent", "tool", "note", "info", "error") rather than the TUI's integer: an archive outlives the enum, and a reordered constant block must not silently restyle every stored conversation.
type ConsoleDB ¶ added in v0.6.0
ConsoleDB names one database's directory of consoles: Host, then Database, each one directory level (see the layout above). Both are directory names, not the host and database as the driver knows them — ConsoleDBOf makes one from those.
func ConsoleDBOf ¶ added in v0.6.0
ConsoleDBOf is the directory of database on host. host may be "" (a connection whose DSN could not be read — see db.ConsoleTarget).
func (ConsoleDB) Key ¶ added in v0.8.0
Key is d as one string, "host/database": its two directory levels, which ConsoleDBOf already made file-name safe, so neither holds a "/". It is how a history entry records its database (Entry.DB) — stable across connection renames, the same in the TUI and dbc web, and comparable as a plain string. The zero ConsoleDB's key is "".
type Entry ¶
type Entry struct {
At time.Time `json:"at"`
Conn string `json:"conn"`
SQL string `json:"sql"`
// DB is the database the statement ran on, as ConsoleDB.Key — the same
// host ─► database identity the consoles are kept by, so "this
// database's history" and "this database's consoles" agree, and two
// connection names onto one database share both. It is a key rather
// than the connection's name because a name is only a label (renaming
// "prod" must not orphan its history) and one server holds many
// databases.
//
// omitempty leaves entries written before the field existed as they
// were, and an older dbc reading a new line ignores the unknown field.
// "" means "database unknown": such an entry shows only under "all
// databases", never under a database it might not belong to.
DB string `json:"db,omitempty"`
}
Entry is one statement the user ran — one line of the history file.
func HistoryIn ¶ added in v0.8.0
HistoryIn keeps the entries recorded on database key (Entry.DB). An empty key keeps everything: with no database to scope to (no connection, consoles off), "this database" can only mean all of them. Entries with no DB — written before the field existed — are in no database's scope; they show under "all".
func MatchHistory ¶
MatchHistory keeps the entries whose SQL or connection name holds q, case-insensitively. An empty query keeps everything.
type History ¶
type History struct {
// contains filtered or unexported fields
}
History is the statements the user has run, oldest first, backed by a JSON-lines file: one object per line carries the multi-line SQL that a plain-text history would have to escape, and appending one entry costs one write rather than a rewrite of the file.
It is safe for concurrent use. The TUI touches it from one goroutine, but `dbc web` gives every browser tab its own workspace over ONE shared History (so a query run in any tab, or in the terminal's history file, is recallable from all of them), and those tabs record from their own request goroutines. mu also serializes the file appends, so two tabs recording at once cannot interleave half-lines.
func LoadHistory ¶
LoadHistory reads the history file, skipping lines it cannot parse — a half-written last line from a killed process must not cost the whole history. An over-long file is trimmed back to histMax here, which is the only point at which the file is rewritten rather than appended to.
func (*History) Add ¶
Add records a statement, unless it repeats the one just recorded — running the same query twice while watching a table change should not bury the rest of the history. The entry is kept in memory whether or not the file write works, so a read-only config directory costs persistence, not the session.
func (*History) AddEntry ¶ added in v0.8.0
AddEntry is Add with the whole entry given — the database (Entry.DB) included, which the workspace knows and Add's callers need not.
The repeat check compares the database too: the same query run on one database and then on another is two entries, or the second database's scoped history would be missing a statement that ran on it.
type JobInfo ¶ added in v0.13.0
type JobInfo struct {
Name string `json:"name"` // file name, with .json
Desc string `json:"desc"` // the spec's desc; "" if none or unreadable
Pipelines int `json:"pipelines"` // how many steps; 0 when the file does not parse
Schedule []string `json:"schedule"` // its cron lines, as written
Webhook bool `json:"webhook"`
Size int64 `json:"size"`
Mod time.Time `json:"mod"`
Rev string `json:"rev"`
}
JobInfo is one job, as a list shows it.
type Layout ¶ added in v0.8.0
type Layout struct {
SideW int `json:"side_w,omitempty"`
ChatW int `json:"chat_w,omitempty"`
LogH int `json:"log_h,omitempty"`
EdFrac float64 `json:"ed_frac,omitempty"`
SideHidden bool `json:"side_hidden,omitempty"`
// ChatRecentFolded folds the assistant's empty-pane list of recent
// conversations down to its header.
ChatRecentFolded bool `json:"chat_recent_folded,omitempty"`
// Tabs are the query tabs, in strip order, and ActiveTab the index of
// the one on screen. Empty from an older dbc: one tab, as before.
Tabs []LayoutTab `json:"tabs,omitempty"`
ActiveTab int `json:"active_tab,omitempty"`
// Groups are the query tabs' groups (tui/tabgroups.go). Empty from an
// older dbc, or when none was made.
Groups []LayoutTabGroup `json:"groups,omitempty"`
}
Layout is the terminal UI's pane geometry as the user left it: the sizes dragged at the pane borders, whether the sidebar was folded away (^B), and whether the assistant's recent conversations were folded. dbc web keeps the same things in its store's layout; the TUI has no store, so, like the schema picks, they get a small file of their own.
Zero means "never set": New keeps its default for a zero field, so a file from an older dbc (or one missing a field) costs only that field.
func LoadLayout ¶ added in v0.8.0
LoadLayout returns the saved layout. A missing or unreadable file is the zero Layout: the defaults, which is all losing it costs.
type LayoutTab ¶ added in v0.8.0
type LayoutTab struct {
Title string `json:"title"`
Conn string `json:"conn,omitempty"`
Console string `json:"console,omitempty"`
}
LayoutTab is one saved query tab: what it is called, the connection it was on, and the console it showed (a name within that connection's database's consoles). The console's text is in its file, not here.
type LayoutTabGroup ¶ added in v0.12.0
type LayoutTabGroup struct {
Name string `json:"name"`
// Conn is a connection group's connection; "" for an ad-hoc group.
Conn string `json:"conn,omitempty"`
Members []int `json:"members,omitempty"` // ad-hoc: indices into Tabs
Exclude []int `json:"exclude,omitempty"` // connection: tabs taken out by hand
Collapsed bool `json:"collapsed,omitempty"`
// Color indexes the TUI's group hues, kept so a group keeps its colour
// across restarts.
Color int `json:"color"`
}
LayoutTabGroup is one saved tab group. A TUI tab has no identity that outlives the run (its key is minted fresh each start), so Members and Exclude name tabs by their INDEX in Tabs — the strip as it was saved, which is the order restoreTabs rebuilds. dbc web keeps the same record by saved-tab key (web/groups.go's tabGroupRec); the two are not shared, as the tabs themselves are not.
type PipelineInfo ¶ added in v0.13.0
type PipelineInfo struct {
Name string `json:"name"` // file name, with .json
Desc string `json:"desc"` // the spec's desc; "" if none or unreadable
Fragments int `json:"fragments"` // how many; 0 when the file does not parse
Size int64 `json:"size"`
Mod time.Time `json:"mod"`
Rev string `json:"rev"`
}
PipelineInfo is one pipeline, as a list shows it.
func ListPipelines ¶ added in v0.13.0
func ListPipelines(dir string) ([]PipelineInfo, error)
ListPipelines lists the pipelines in dir by name. A missing dir is none and no error.
type PipelineTrashInfo ¶ added in v0.13.0
type PipelineTrashInfo = SpecTrashInfo
PipelineTrashInfo is one trashed pipeline.
func ListPipelineTrash ¶ added in v0.13.0
func ListPipelineTrash(dir string) []PipelineTrashInfo
ListPipelineTrash lists the trashed pipelines in dir, newest first.
type PluginInfo ¶ added in v0.13.0
type PluginInfo = ScriptInfo
PluginInfo is one plugin file, as a list shows it: its file name and the first sentence of its opening comment.
func ListPlugins ¶ added in v0.13.0
func ListPlugins(dir string) ([]PluginInfo, error)
ListPlugins lists the plugin files in dir by name; a missing dir is none.
type PluginTrashInfo ¶ added in v0.13.0
type PluginTrashInfo = TrashInfo
PluginTrashInfo is one trashed plugin file.
func ListPluginTrash ¶ added in v0.13.0
func ListPluginTrash(dir string) []PluginTrashInfo
ListPluginTrash lists the trashed plugin files, newest first.
type RunFilter ¶ added in v0.13.0
type RunFilter struct {
Kind string
Name string
Status string
Since time.Time // started at or after
Limit int // the newest this many, after the other filters
}
RunFilter narrows ListRuns. Zero values match everything; Limit 0 is no limit.
type RunHead ¶ added in v0.13.0
type RunHead struct {
ID string `json:"id"`
Kind string `json:"kind"`
Name string `json:"name"`
Trigger string `json:"trigger"`
By string `json:"by,omitempty"`
Status string `json:"status"`
Started time.Time `json:"started"`
Ended time.Time `json:"ended"`
Error string `json:"error,omitempty"`
// Rows is every fragment's committed rows, over all its pipelines.
Rows int64 `json:"rows"`
// Mod is when the file was last written: a "running" record that has
// not been rewritten for a while belongs to a process that is gone.
Mod time.Time `json:"mod"`
}
RunHead is what a listing reads off a record.
type SchemaPick ¶ added in v0.3.0
SchemaPick is the schema the terminal UI's Tables pane was last on for one connection: Name, or every schema (All). It mirrors workspace.SchemaPick rather than importing it, so this package stays below workspace.
dbc web keeps its picks in its own store's layout ("tableSchema.<conn>"); the TUI has no store, so its picks get a file of their own here.
type ScriptInfo ¶ added in v0.9.0
type ScriptInfo struct {
Name string `json:"name"` // file name, with .go
Desc string `json:"desc"` // its opening comment's first sentence; "" if none
Size int64 `json:"size"`
Mod time.Time `json:"mod"`
Rev string `json:"rev"` // textRev of its content: what a save names as its base
}
ScriptInfo is one script, as a list shows it.
func ListScripts ¶ added in v0.9.0
func ListScripts(dir string) ([]ScriptInfo, error)
ListScripts lists the scripts in dir by name. A missing dir is none and no error: it is created on the first save, and most users never make one.
type SpecTrashInfo ¶ added in v0.13.0
type SpecTrashInfo struct {
ID string `json:"id"`
Name string `json:"name"`
Trashed time.Time `json:"trashed"`
}
SpecTrashInfo is one trashed spec (a pipeline or a job).
func ListJobTrash ¶ added in v0.13.0
func ListJobTrash(dir string) []SpecTrashInfo
ListJobTrash lists the trashed jobs in dir, newest first.