Documentation
¶
Index ¶
- Constants
- Variables
- func AutoCast(val any) any
- func InjectHTTPClient(httpClient *http.Client)
- func MockResponse(statusCode int, body string)
- func MockResponseWithRequestInspect(statusCode int, body string, requestInspect func(r *http.Request))
- func Version() string
- type Adapter
- type Data
- type Duration
- type Event
- type HTTPClient
- type Logger
- type LogrusAdapter
- type Meta
- type MockRoundTripper
- type Pipe
- type Request
- type Requests
- type Response
- type Row
- type Statistics
- type Workspace
Constants ¶
const ( Format string = "json" JSON = "json" NDJSON = "ndjson" CSV = "csv" )
Variables ¶
var CONNS_TIMEOUT int
var MAX_CONNS_PER_HOST int
var MAX_IDLE_CONNS int
var MAX_IDLE_CONNS_PER_HOST int
var URL_BASE string
Functions ¶
func AutoCast ¶ added in v1.6.0
AutoCast attempts to infer the real type of a value. If the value is a string it tries to parse it as int64 first, then float64. Non-string values and strings that cannot be parsed are returned unchanged.
func InjectHTTPClient ¶
func MockResponse ¶
Types ¶
type Data ¶ added in v1.5.0
type Data []Row
Data represents a collection (slice) of rows returned from a query or dataset.
func (Data) FetchOne ¶ added in v1.5.0
FetchOne retrieves the value of a specific field from the first Row in the Data slice, using the provided field name (key). If the key doesn't exist, it returns nil.
func (Data) First ¶ added in v1.5.0
First returns the first Row in the Data slice. It assumes the slice is not empty.
func (Data) Get ¶ added in v1.6.0
Get retrieves a value from the first row of the Data structure by traversing a dot-separated path.
The path represents nested keys within Row maps (e.g. "a.b.c"). If the Data slice is empty, the path does not exist, or an intermediate value is not a Row, Get returns nil.
func (*Data) Set ¶ added in v1.6.0
Set assigns a value in the first row of the Data structure at the location specified by a dot-separated path.
Intermediate Row nodes are created as needed if they do not exist. An error is returned if Data is empty, the path is empty, or a non-Row value is encountered while traversing the path.
func (*Data) SetWithAutoCast ¶ added in v1.6.0
SetWithAutoCast works like Set but applies AutoCast to the value before storing it, converting numeric strings to their int64 or float64 equivalents.
type LogrusAdapter ¶
type LogrusAdapter struct{}
func (LogrusAdapter) Debugf ¶
func (l LogrusAdapter) Debugf(fmt string, args ...interface{})
type MockRoundTripper ¶
type Pipe ¶
type Pipe struct {
// Name of pipe. Define by user.
Name string
// Alias of pipe. Optional.
Alias string
// Is for internal purpose and is generated by code.
URL string
// Parameters use on pipe. Define by user.
Parameters url.Values
// Is an area that contains a set of Tinybird resources, including Pipes,
// Nodes, APIs, Data Sources & Auth Tokens. Define by user.
Workspace Workspace
// Return format.
Format string
}
Pipe is a object on tinybird, contains one or more SQL queries (Nodes) that result in either an API endpoint or a Materialized View.
func (Pipe) GetFormat ¶ added in v1.4.0
Verify the variable Format value to return json, ndjson or csv.
func (*Pipe) GetParameters ¶
type Request ¶
type Request struct {
After func(*Request) // Run after execute request.
Before func(*Request) bool // Run before execute request.
Data []byte // Data to send.
Elapsed Duration // Elapsed time of client request.
Error error // Error on client request.
Event Event // Send event to data source.
Method string // Define HTTP method.
Pipe Pipe // Pipe details.
Response Response // Response data.
}
Basic request struct.
type Requests ¶
type Requests []Request
Slice for all request to execute in parallel.
func (*Requests) GetByAlias ¶
type Response ¶
type Response struct {
Cached bool // Flag control to use to determine the origin this response.
Raw io.ReadCloser // Raw is the original data from response.
Body string // Body in string format, same a Data but in struct format and Raw in original format.
Data Data `json:"data,omitempty"` // Data is part a tinybird response.
Documentation string `json:"documentation,omitempty"` // Documentation is part a tinybird response.
Error string `json:"error,omitempty"` // Error is part a tinybird response.
Meta []Meta `json:"meta,omitempty"` // Meta is part a tinybird response.
Rows uint `json:"rows,omitempty"` // Rows is part a tinybird response.
RowsBeforeLimitAtLeast uint `json:"rows_before_limit_at_least,omitempty"` // RowsBeforeLimitAtLeast is part a tinybird response.
Statistics Statistics `json:"statistics,omitempty"` // Statistics is part a tinybird response.
Status int // Status is a HTTP status code, ej: 200, 400, 500 etc...
Header http.Header // Headers contains the HTTP response headers returned by the server
Format string // Save format setting.
SuccessfulRows int `json:"successful_rows"`
QuarantinedRows int `json:"quarantined_rows"`
}
Basic JSON struct for all response by Tinybird.
type Row ¶
Row is a generic map-based structure that can hold fields of any type. Each key corresponds to a field name, and each value can be any Go type.
type Statistics ¶
type Statistics struct {
Elapsed float64 `json:"elapsed,omitempty"`
RowsRead uint64 `json:"rows_read,omitempty"`
BytesRead uint64 `json:"bytes_read,omitempty"`
}
Statistics information about the response.