Documentation
¶
Overview ¶
Package dataview reads what a database holds, for the panel's data viewer. It never writes: queries are built here from a typed request, names are checked against the database's own catalog, and every query runs in a read-only transaction with a time limit, through the client that ships in the database's image.
Index ¶
Constants ¶
const ( PageTimeout = 5 * time.Second ExportTimeout = 10 * time.Minute )
How long a query may take: a page is meant to be quick, and a slow one should be narrowed with a filter rather than hold the database.
const ( MaxCell = 1000 MaxFull = 64 << 10 )
A value longer than this is cut in a page; a row asked for in full keeps up to MaxFull characters of each.
const ( OpEq = "eq" OpNe = "ne" OpContains = "contains" OpStarts = "starts" OpGt = "gt" OpLt = "lt" OpNull = "null" OpNotNull = "notnull" )
The filters there are.
const ItemCount = 100
ItemCount is how many items of a list, hash, set, sorted set or stream are shown.
const PageSize = 50
PageSize is how many rows a page holds.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Column ¶
type Column struct {
Name string `json:"name"`
Type string `json:"type"`
Nullable bool `json:"nullable"`
// Key is set for the columns of the primary key.
Key bool `json:"key,omitempty"`
// Binary columns are shown as hex.
Binary bool `json:"binary,omitempty"`
}
Column describes one column of a table.
type Exec ¶
type Exec func(ctx context.Context, args []string, stdin io.Reader, stdout, stderr io.Writer) (uint32, error)
Exec runs a command in the database's container, with the container's environment, which holds the database's password.
type Filter ¶
type Filter struct {
Column string `json:"column"`
Op string `json:"op"`
Value string `json:"value,omitempty"`
}
Filter narrows the rows to those whose column matches.
type Key ¶
type Key struct {
ID string `json:"id"`
Name string `json:"name"`
Binary bool `json:"binary,omitempty"`
Type string `json:"type"`
// TTL is in seconds, -1 for a key that never expires.
TTL int64 `json:"ttl"`
}
Key is one key. ID is its name in Redis's quoting, which the viewer sends back to open it; Name is how it reads.
type KeyPage ¶
KeyPage is one step through the keys. Cursor is where the next step starts, "0" when the whole key space has been gone through.
type Page ¶
type Page struct {
Columns []string `json:"columns"`
Rows [][]*string `json:"rows"`
// Cut lists the values that were cut short, as row and column.
Cut [][2]int `json:"cut,omitempty"`
// More says there are rows after this page.
More bool `json:"more"`
}
Page is what a query found.
type Query ¶
type Query struct {
Schema string `json:"schema"`
Table string `json:"table"`
Filters []Filter `json:"filters,omitempty"`
// Search looks for text in every column.
Search string `json:"search,omitempty"`
Sort string `json:"sort,omitempty"`
Desc bool `json:"desc,omitempty"`
Offset int `json:"offset,omitempty"`
// Full keeps each value up to MaxFull characters, for one row opened
// on its own.
Full bool `json:"full,omitempty"`
}
Query asks for a page of a table's rows.
type Table ¶
type Table struct {
Schema string `json:"schema"`
Name string `json:"name"`
View bool `json:"view,omitempty"`
Rows int64 `json:"rows"`
Bytes int64 `json:"bytes"`
Columns []Column `json:"columns"`
}
Table is a table or view. Rows is the database's own estimate, -1 when it has none yet; counting a large table exactly would take too long.
type Value ¶
type Value struct {
Key Key `json:"key"`
Size int64 `json:"size"`
Columns []string `json:"columns"`
Rows [][]*string `json:"rows"`
// Binary lists the cells shown as hex, as row and column, and Cut the
// ones cut short.
Binary [][2]int `json:"binary,omitempty"`
Cut [][2]int `json:"cut,omitempty"`
}
Value is what a key holds: up to ItemCount items, as rows under Columns. Size is its full length: characters, items or entries.