Documentation ¶
Index ¶
- Variables
- func Conn() *sql.DB
- func DisplayConfig()
- func ExecuteQuery(db *sql.DB, sql string)
- func HasErr(msg string, err error) bool
- func MarshalJSON(data interface{}) string
- func OverrideConfig(strArgs map[string]*string, intArgs map[string]*int, boolArgs map[string]*bool)
- func Ping(db *sql.DB)
- func ShaQuery(query string) string
- func UnmarshalJSON(data []byte, v interface{})
- func UuidFromString(uid string) uuid.UUID
- func UuidString(query string) string
- func UuidV5(str string) uuid.UUID
- type Databases
- type Queries
- type Query
- type QueryWorker
- type Source
- type Sources
Constants ¶
This section is empty.
Variables ¶
View Source
var ( Env = "dev" DBHost = "localhost" DBPort = "5432" DBUser = "postgres" DBPassword = "" DBName = "lantern" )
Default config values. These can be overwritten by the params passed in.
View Source
var UuidNamespace = uuid.MustParse("018e1b50-ee98-73f2-9839-420223323163")
UuidNamespace is the namespace for the uuid. There are 4 predefined namespaces, but you can also create your own.
Functions ¶
func DisplayConfig ¶
func DisplayConfig()
func ExecuteQuery ¶
func MarshalJSON ¶
func MarshalJSON(data interface{}) string
func OverrideConfig ¶
func UnmarshalJSON ¶
func UnmarshalJSON(data []byte, v interface{})
func UuidFromString ¶
func UuidString ¶
Types ¶
type Databases ¶
type Databases struct {
Databases map[string]uuid.UUID `json:"databases,omitempty"` // the key is the UUIDv5 sha of the database
}
func NewDatabases ¶
func NewDatabases() *Databases
type Queries ¶
type Queries struct { Queries map[string]*Query `json:"queries,omitempty"` FunctionsInQueries map[string]*extractor.FunctionsInQueries `json:"functions_in_queries,omitempty"` ColumnsInQueries map[string]*extractor.ColumnsInQueries `json:"columns_in_queries,omitempty"` TablesInQueries map[string]*extractor.TablesInQueries `json:"tables_in_queries,omitempty"` TableJoinsInQueries map[string]*extractor.TableJoinsInQueries `json:"table_joins_in_queries,omitempty"` }
func (*Queries) Analyze ¶
func (q *Queries) Analyze(w QueryWorker) bool
Analyze processes a query and returns a bool whether or not the query was parsed successfully
func (*Queries) ExtractStats ¶
func (q *Queries) ExtractStats()
func (*Queries) UpsertColumnsInQueries ¶
func (q *Queries) UpsertColumnsInQueries()
func (*Queries) UpsertTablesInQueries ¶
func (q *Queries) UpsertTablesInQueries()
type Query ¶
type Query struct { UID uuid.UUID `json:"uid,omitempty"` // unique sha of the query DatabaseUID uuid.UUID `json:"database_uid,omitempty"` // the dataset the query belongs to SourceUID uuid.UUID `json:"source_uid,omitempty"` // the source the query belongs to Command token.TokenType `json:"command,omitempty"` // the type of query TotalCount int64 `json:"total_count,omitempty"` // the number of times the query was executed TotalDuration int64 `json:"total_duration,omitempty"` // the total duration of all executions of the query in microseconds MaskedQuery string `json:"masked_query,omitempty"` // the query with parameters masked UnmaskedQuery string `json:"unmasked_query,omitempty"` // the query with parameters unmasked SourceQuery string `json:"source,omitempty"` // the original query from the source }
func (*Query) MarshalJSON ¶
func (*Query) Process ¶
func (q *Query) Process(w QueryWorker, qs *Queries) bool
Process processes a query and returns a bool whether or not the query was parsed successfully
func (*Query) UnmarshalJSON ¶
type QueryWorker ¶
type QueryWorker struct { Databases *Databases Source *Source SourceUID uuid.UUID Database string DatabaseUID uuid.UUID Input string // Original query. This may contain many queries Duration int64 MustExtract bool Command token.TokenType Masked string // Masked query. This is the query with all values replaced with ? Unmasked string // Unmasked query. This is the query with all values left alone }
This is an interim struct with additional Query meta data. The struct is passed around and built up instead of passing around a ton of individual variables. This is used both initially when compiling a list of queries and then individually when processing each query
Click to show internal directories.
Click to hide internal directories.