response

package
v0.0.0-...-9bbf556 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 5, 2025 License: Apache-2.0 Imports: 9 Imported by: 26

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExpandSQL

func ExpandSQL(SQL string, args []interface{}) string

Types

type Buffered

type Buffered struct {
	// contains filtered or unexported fields
}

Buffered represents a buffered response

func NewBuffered

func NewBuffered(options ...Option) *Buffered

func (*Buffered) Body

func (b *Buffered) Body() io.Reader

func (*Buffered) CompressionType

func (b *Buffered) CompressionType() string

func (*Buffered) Headers

func (b *Buffered) Headers() http.Header

func (*Buffered) SetStatusCode

func (b *Buffered) SetStatusCode(status int)

func (*Buffered) Size

func (b *Buffered) Size() int

func (*Buffered) StatusCode

func (b *Buffered) StatusCode() int

type CacheStats

type CacheStats struct {
	Type           string
	RecordsCounter int
	Key            string
	Dataset        string
	Namespace      string
	FoundWarmup    bool   `json:",omitempty"`
	FoundLazy      bool   `json:",omitempty"`
	ErrorType      string `json:",omitempty"`
	ErrorCode      int    `json:",omitempty"`
	ExpiryTime     *time.Time
}

type Compressed

type Compressed interface {
	CompressionType() string
}

Compressed represents a compressed response

type Error

type Error struct {
	View      string      `json:"view,omitempty" `
	Parameter string      `json:"parameter,omitempty" `
	Code      int         `json:"statusCode,omitempty" `
	Err       error       `json:"-"`
	Message   string      `json:"message,omitempty" `
	Object    interface{} `json:"object,omitempty" `
}

Error represents an error

func NewError

func NewError(code int, message string, opts ...ErrorOption) *Error

NewError creates a new error

func NewParameterError

func NewParameterError(view, parameter string, err error, opts ...ErrorOption) *Error

NewParameterError creates a new parameter error

func (*Error) Error

func (e *Error) Error() string

func (*Error) Reader

func (e *Error) Reader() io.Reader

func (*Error) SetStatusCode

func (e *Error) SetStatusCode(code int)

func (*Error) StatusCode

func (e *Error) StatusCode() int

type ErrorOption

type ErrorOption func(e *Error)

ErrorOption represents an error option

func WithError

func WithError(err error) ErrorOption

WithError sets the error

func WithErrorMessage

func WithErrorMessage(message string) ErrorOption

WithErrorMessage sets the error message

func WithErrorStatusCode

func WithErrorStatusCode(code int) ErrorOption

WithErrorStatusCode sets the error status code

func WithObject

func WithObject(object interface{}) ErrorOption

WithObject sets the object

func WithParameter

func WithParameter(parameter string) ErrorOption

WithParameter sets the error parameter

func WithView

func WithView(view string) ErrorOption

WithView sets the error view

type Errors

type Errors struct {
	Message string `json:",omitempty" `
	Errors  []*Error
	// contains filtered or unexported fields
}

Errors represents a list of errors

func NewErrors

func NewErrors() *Errors

NewErrors creates a new errors

func (*Errors) AddError

func (e *Errors) AddError(view, param string, err error, opts ...ErrorOption)

AddError adds an error

func (*Errors) Append

func (e *Errors) Append(err error)

Append appends an error

func (*Errors) Error

func (e *Errors) Error() string

Error represents an error

func (*Errors) HasError

func (e *Errors) HasError() bool

HasError returns true if has error

func (*Errors) SetStatusCode

func (e *Errors) SetStatusCode(status int)

SetStatusCode sets status code

func (*Errors) StatusCode

func (e *Errors) StatusCode() int

type Execution

type Execution struct {
	View    []*SQLExecution `json:",omitempty"`
	Summary []*SQLExecution `json:",omitempty"`
	Elapsed string          `json:",omitempty"`
}

type JobInfo

type JobInfo struct {
	RequestTime  time.Time `json:",omitempty"`
	JobStatus    string    `json:",omitempty"`
	CreateTime   time.Time `json:",omitempty"`
	WaitTimeInMs int       `json:",omitempty"`
	RunTimeInMs  int       `json:",omitempty"`
	ExpiryInSec  int       `json:",omitempty"`
	CacheKey     string    `json:",omitempty"`
	CacheHit     bool      `json:",omitempty"`
	MatchKey     string    `json:",omitempty"`
}

type Metric

type Metric struct {
	View      string     `json:",omitempty"`
	Elapsed   string     `json:",omitempty"`
	ElapsedMs int        `json:",omitempty"`
	Rows      int        `json:",omitempty"`
	Execution *Execution `json:",omitempty"`
}

func (*Metric) HideSQL

func (m *Metric) HideSQL() *Metric

func (*Metric) Name

func (m *Metric) Name() string

func (*Metric) ParametrizedSQL

func (m *Metric) ParametrizedSQL() []*ParametrizedSQL

func (*Metric) SQL

func (m *Metric) SQL() string

type Metrics

type Metrics []*Metric

func (Metrics) Basic

func (m Metrics) Basic() Metrics

Basic returns n

func (Metrics) Lookup

func (m Metrics) Lookup(viewName string) *Metric

Lookup looks up view metric by name

func (Metrics) ParametrizedSQL

func (m Metrics) ParametrizedSQL() []*ParametrizedSQL

func (Metrics) SQL

func (m Metrics) SQL() string

SQL returns main view SQL

type Option

type Option func(r *Buffered)

Option represents a buffered response option

func WithBuffer

func WithBuffer(buffer *bytes.Buffer) Option

WithBuffer returns an option that sets the buffer

func WithBytes

func WithBytes(bs []byte) Option

WithBytes returns an option that sets the payload

func WithCompressions

func WithCompressions(compressions string) Option

WithCompressions returns an option that sets the compression type

func WithHeader

func WithHeader(name, value string) Option

WithHeader returns an option that sets the header

func WithHeaders

func WithHeaders(header http.Header) Option

WithHeaders returns an option that sets the headers

func WithSize

func WithSize(compressions string) Option

WithSize returns an option that sets the size

func WithStatusCode

func WithStatusCode(statusCode int) Option

WithStatusCode returns an option that sets the status code

type Options

type Options []Option

Options represents a list of buffered response options

func (*Options) AdjustStatusCode

func (o *Options) AdjustStatusCode(candidates ...interface{})

AdjustStatusCode adjusts the status code

func (*Options) Append

func (o *Options) Append(opts ...Option)

Append appends options

func (*Options) Options

func (o *Options) Options() Options

type ParametrizedSQL

type ParametrizedSQL struct {
	Query string
	Args  []interface{}
}

type Response

type Response interface {
	StatusCoder
	Body() io.Reader
	Headers() http.Header
	Size() int
	SetStatusCode(int)
}

Response represents a response

func BuildErrorResponse

func BuildErrorResponse(err error) Response

BuildErrorResponse builds an error response

type SQLExecution

type SQLExecution struct {
	SQL        string        `json:",omitempty"`
	Args       []interface{} `json:",omitempty"`
	CacheStats *CacheStats   `json:",omitempty"`
	Error      string        `json:",omitempty"`
	CacheError string        `json:",omitempty"`
}

type Status

type Status struct {
	Status  string                 `json:"status,omitempty"`
	Message string                 `json:"message,omitempty"`
	Errors  interface{}            `json:"errors,omitempty"`
	Warning []*Warning             `json:"warning,omitempty"`
	Extras  map[string]interface{} `json:"extras,omitempty" format:"inline=true"`
}

type StatusCoder

type StatusCoder interface {
	StatusCode() int
}

StatusCoder represents a status code

type Warning

type Warning struct {
	Message string `json:"message,omitempty"`
	Reason  string `json:"reason,omitempty"`
}

Directories

Path Synopsis
tabular
xml

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳