Documentation ¶
Index ¶
- Variables
- type Adapter
- type Call
- func (c *Call) Cancel()
- func (c *Call) Done() chan struct{}
- func (c *Call) Err() error
- func (c *Call) GetID() CallID
- func (c *Call) GetQuery() string
- func (c *Call) GetResult() (*Result, error)
- func (c *Call) GetState() CallState
- func (c *Call) GetTimeTaken() time.Duration
- func (c *Call) GetTimestamp() time.Time
- func (s *Call) MarshalJSON() ([]byte, error)
- func (c *Call) UnmarshalJSON(data []byte) error
- type CallID
- type CallState
- type Column
- type Connection
- func (c *Connection) Close()
- func (c *Connection) Execute(query string, onEvent func(CallState, *Call)) *Call
- func (c *Connection) GetColumns(opts *TableOptions) ([]*Column, error)
- func (c *Connection) GetHelpers(opts *TableOptions) map[string]string
- func (c *Connection) GetID() ConnectionID
- func (c *Connection) GetName() string
- func (c *Connection) GetParams() *ConnectionParams
- func (c *Connection) GetStructure() ([]*Structure, error)
- func (c *Connection) GetType() string
- func (c *Connection) GetURL() string
- func (c *Connection) ListDatabases() (current string, available []string, err error)
- func (s *Connection) MarshalJSON() ([]byte, error)
- func (c *Connection) SelectDatabase(name string) error
- type ConnectionID
- type ConnectionParams
- type DatabaseSwitcher
- type Driver
- type Formatter
- type FormatterOptions
- type Header
- type Meta
- type Result
- func (cr *Result) Format(formatter Formatter, from, to int) ([]byte, error)
- func (cr *Result) Header() Header
- func (cr *Result) IsEmpty() bool
- func (cr *Result) Len() int
- func (cr *Result) Meta() *Meta
- func (cr *Result) Rows(from, to int) ([]Row, error)
- func (cr *Result) SetIter(iter ResultStream, onFillStart func()) error
- func (cr *Result) Wipe()
- type ResultStream
- type Row
- type SchemaType
- type Structure
- type StructureType
- type TableOptions
Constants ¶
This section is empty.
Variables ¶
var ErrDatabaseSwitchingNotSupported = errors.New("database switching not supported")
Functions ¶
This section is empty.
Types ¶
type Adapter ¶
type Adapter interface { Connect(url string) (Driver, error) GetHelpers(opts *TableOptions) map[string]string }
Adapter is an object which allows to connect to database using a url. It also has the GetHelpers method, which returns a list of operations for a given type.
type Call ¶
type Call struct {
// contains filtered or unexported fields
}
func (*Call) Done ¶
func (c *Call) Done() chan struct{}
Done returns a non-buffered channel that is closed when call finishes.
func (*Call) GetTimeTaken ¶
func (*Call) GetTimestamp ¶
func (*Call) MarshalJSON ¶
func (*Call) UnmarshalJSON ¶
type Connection ¶
type Connection struct {
// contains filtered or unexported fields
}
func NewConnection ¶
func NewConnection(params *ConnectionParams, adapter Adapter) (*Connection, error)
func (*Connection) Close ¶
func (c *Connection) Close()
func (*Connection) Execute ¶
func (c *Connection) Execute(query string, onEvent func(CallState, *Call)) *Call
func (*Connection) GetColumns ¶
func (c *Connection) GetColumns(opts *TableOptions) ([]*Column, error)
func (*Connection) GetHelpers ¶
func (c *Connection) GetHelpers(opts *TableOptions) map[string]string
func (*Connection) GetID ¶
func (c *Connection) GetID() ConnectionID
func (*Connection) GetName ¶
func (c *Connection) GetName() string
func (*Connection) GetParams ¶
func (c *Connection) GetParams() *ConnectionParams
GetParams returns the original source for this connection
func (*Connection) GetStructure ¶
func (c *Connection) GetStructure() ([]*Structure, error)
func (*Connection) GetType ¶
func (c *Connection) GetType() string
func (*Connection) GetURL ¶
func (c *Connection) GetURL() string
func (*Connection) ListDatabases ¶
func (c *Connection) ListDatabases() (current string, available []string, err error)
func (*Connection) MarshalJSON ¶
func (s *Connection) MarshalJSON() ([]byte, error)
func (*Connection) SelectDatabase ¶
func (c *Connection) SelectDatabase(name string) error
SelectDatabase tries to switch to a given database with the used client. on error, the switch doesn't happen and the previous connection remains active.
type ConnectionID ¶
type ConnectionID string
type ConnectionParams ¶
type ConnectionParams struct { ID ConnectionID Name string Type string URL string }
func (*ConnectionParams) Expand ¶
func (p *ConnectionParams) Expand() *ConnectionParams
Expand returns a copy of the original parameters with expanded fields
func (*ConnectionParams) MarshalJSON ¶
func (cp *ConnectionParams) MarshalJSON() ([]byte, error)
type DatabaseSwitcher ¶
type DatabaseSwitcher interface { SelectDatabase(string) error ListDatabases() (current string, available []string, err error) }
DatabaseSwitcher is an optional interface for drivers that have database switching capabilities.
type Driver ¶
type Driver interface { Query(ctx context.Context, query string) (ResultStream, error) Structure() ([]*Structure, error) Columns(opts *TableOptions) ([]*Column, error) Close() }
Driver is an interface for a specific database driver.
type Formatter ¶
type Formatter interface {
Format(header Header, rows []Row, opts *FormatterOptions) ([]byte, error)
}
Formatter converts header and rows to bytes
type FormatterOptions ¶
type FormatterOptions struct { SchemaType SchemaType ChunkStart int }
FormatterOptions provide various options for formatters
type Meta ¶
type Meta struct { // type of schema (schemaful or schemaless) SchemaType SchemaType }
Meta holds metadata
type Result ¶
type Result struct {
// contains filtered or unexported fields
}
Result is the cached form of the ResultStream iterator
func (*Result) SetIter ¶
func (cr *Result) SetIter(iter ResultStream, onFillStart func()) error
SetIter sets the ResultStream iterator to result. This can be done only once!
type ResultStream ¶
type ResultStream interface { Meta() *Meta Header() Header Next() (Row, error) HasNext() bool Close() }
ResultStream is a result from executed query and has a form of an iterator
type Structure ¶
type Structure struct { // Name to be displayed Name string Schema string // Type of layout Type StructureType // Children layout nodes Children []*Structure }
Structure represents the structure of a single database
type StructureType ¶
type StructureType int
const ( StructureTypeNone StructureType = iota StructureTypeTable StructureTypeView )
func StructureTypeFromString ¶
func StructureTypeFromString(s string) StructureType
func (StructureType) String ¶
func (s StructureType) String() string
type TableOptions ¶
type TableOptions struct { Table string Schema string Materialization StructureType }
TableOptions contain options for gathering information about specific table.