Documentation
¶
Index ¶
- Constants
- Variables
- type AsyncCache
- type Cache
- type CachedData
- type ContentMetadata
- type Key
- type RedisCacheCorruptionError
- type RedisCacheError
- type Stats
- type TmpFileResponseWriter
- func (rw *TmpFileResponseWriter) Close() error
- func (rw *TmpFileResponseWriter) CloseNotify() <-chan bool
- func (rw *TmpFileResponseWriter) GetCapturedContentEncoding() string
- func (rw *TmpFileResponseWriter) GetCapturedContentLength() (int64, error)
- func (rw *TmpFileResponseWriter) GetCapturedContentType() string
- func (rw *TmpFileResponseWriter) GetFile() (*os.File, error)
- func (rw *TmpFileResponseWriter) Reader() (io.Reader, error)
- func (rw *TmpFileResponseWriter) ResetFileOffset() error
- func (rw *TmpFileResponseWriter) StatusCode() int
- func (rw *TmpFileResponseWriter) Write(b []byte) (int, error)
- func (rw *TmpFileResponseWriter) WriteHeader(statusCode int)
- type TransactionRegistry
- type TransactionState
- type TransactionStatus
Constants ¶
const Version = 5
Version must be increased with each backward-incompatible change in the cache storage.
Variables ¶
var ErrMissing = errors.New("missing cache entry")
ErrMissing is returned when the entry isn't found in the cache.
Functions ¶
This section is empty.
Types ¶
type AsyncCache ¶ added in v1.15.0
type AsyncCache struct {
Cache
TransactionRegistry
MaxPayloadSize config.ByteSize
// contains filtered or unexported fields
}
AsyncCache is a transactional cache enabled to serve the results from concurrent queries. When query A and B are equal, and query B arrives after query A with no more than defined deadline interval [[graceTime]], query B will await for the results of query B for the max time equal to: max_awaiting_time = graceTime - (arrivalB - arrivalA)
func NewAsyncCache ¶ added in v1.15.0
func (*AsyncCache) AwaitForConcurrentTransaction ¶ added in v1.15.0
func (c *AsyncCache) AwaitForConcurrentTransaction(key *Key) (TransactionStatus, error)
func (*AsyncCache) Close ¶ added in v1.15.0
func (c *AsyncCache) Close() error
type Cache ¶
type Cache interface {
io.Closer
// TODO consider the value of Stats in future iterations. Maybe it is not needed?
Stats() Stats
Get(key *Key) (*CachedData, error)
Put(r io.Reader, ctMetadata ContentMetadata, key *Key) (time.Duration, error)
Name() string
}
Cache stores results of executed queries identified by Key
type CachedData ¶ added in v1.15.0
type CachedData struct {
ContentMetadata
Data io.ReadCloser // we need a ReadCloser because the reader is used oustide the scope where it was created and need to be closed by the function using it.
Ttl time.Duration
}
type ContentMetadata ¶ added in v1.15.0
type Key ¶
type Key struct {
// Query must contain full request query.
Query []byte
// AcceptEncoding must contain 'Accept-Encoding' request header value.
AcceptEncoding string
// ClientProtocolVersion must contain `client_protocol_version` query arg.
ClientProtocolVersion string
// DefaultFormat must contain `default_format` query arg.
DefaultFormat string
// Database must contain `database` query arg.
Database string
// Compress must contain `compress` query arg.
Compress string
// EnableHTTPCompression must contain `enable_http_compression` query arg.
EnableHTTPCompression string
// Namespace is an optional cache namespace.
Namespace string
// MaxResultRows must contain `max_result_rows` query arg
MaxResultRows string
// Extremes must contain `extremes` query arg
Extremes string
// ResultOverflowMode must contain `result_overflow_mode` query arg
ResultOverflowMode string
// UserParamsHash must contain hashed value of users params
UserParamsHash uint32
// Version represents data encoding version number
Version int
// QueryParamsHash must contain hashed value of query params
QueryParamsHash uint32
// UserCredentialHash must contain hashed value of username & password
UserCredentialHash uint32
}
Key is the key for use in the cache.
type RedisCacheCorruptionError ¶ added in v1.17.0
type RedisCacheCorruptionError struct {
}
func (*RedisCacheCorruptionError) Error ¶ added in v1.17.0
func (e *RedisCacheCorruptionError) Error() string
type RedisCacheError ¶ added in v1.17.0
type RedisCacheError struct {
// contains filtered or unexported fields
}
func (*RedisCacheError) Error ¶ added in v1.17.0
func (e *RedisCacheError) Error() string
type Stats ¶
type Stats struct {
// Size is the cache size in bytes.
Size uint64
// Items is the number of items in the cache.
Items uint64
}
Stats represents cache stats
type TmpFileResponseWriter ¶ added in v1.17.0
type TmpFileResponseWriter struct {
http.ResponseWriter // the original response writer
// contains filtered or unexported fields
}
TmpFileResponseWriter caches Clickhouse response. the http header are kept in memory
func NewTmpFileResponseWriter ¶ added in v1.17.0
func NewTmpFileResponseWriter(rw http.ResponseWriter, dir string) (*TmpFileResponseWriter, error)
func (*TmpFileResponseWriter) Close ¶ added in v1.17.0
func (rw *TmpFileResponseWriter) Close() error
func (*TmpFileResponseWriter) CloseNotify ¶ added in v1.17.0
func (rw *TmpFileResponseWriter) CloseNotify() <-chan bool
CloseNotify implements http.CloseNotifier
func (*TmpFileResponseWriter) GetCapturedContentEncoding ¶ added in v1.17.0
func (rw *TmpFileResponseWriter) GetCapturedContentEncoding() string
func (*TmpFileResponseWriter) GetCapturedContentLength ¶ added in v1.17.0
func (rw *TmpFileResponseWriter) GetCapturedContentLength() (int64, error)
func (*TmpFileResponseWriter) GetCapturedContentType ¶ added in v1.17.0
func (rw *TmpFileResponseWriter) GetCapturedContentType() string
func (*TmpFileResponseWriter) GetFile ¶ added in v1.17.0
func (rw *TmpFileResponseWriter) GetFile() (*os.File, error)
func (*TmpFileResponseWriter) Reader ¶ added in v1.17.0
func (rw *TmpFileResponseWriter) Reader() (io.Reader, error)
func (*TmpFileResponseWriter) ResetFileOffset ¶ added in v1.17.0
func (rw *TmpFileResponseWriter) ResetFileOffset() error
func (*TmpFileResponseWriter) StatusCode ¶ added in v1.17.0
func (rw *TmpFileResponseWriter) StatusCode() int
StatusCode returns captured status code from WriteHeader.
func (*TmpFileResponseWriter) Write ¶ added in v1.17.0
func (rw *TmpFileResponseWriter) Write(b []byte) (int, error)
Write writes b into rw.
func (*TmpFileResponseWriter) WriteHeader ¶ added in v1.17.0
func (rw *TmpFileResponseWriter) WriteHeader(statusCode int)
WriteHeader captures response status code.
type TransactionRegistry ¶ added in v1.15.0
type TransactionRegistry interface {
io.Closer
// Create creates a new transaction record
Create(key *Key) error
// Complete completes a transaction for given key
Complete(key *Key) error
// Fail fails a transaction for given key
Fail(key *Key, reason string) error
// Status checks the status of the transaction
Status(key *Key) (TransactionStatus, error)
}
TransactionRegistry is a registry of ongoing queries identified by Key.
type TransactionState ¶ added in v1.15.1
type TransactionState uint8
func (*TransactionState) IsAbsent ¶ added in v1.15.1
func (t *TransactionState) IsAbsent() bool
func (*TransactionState) IsCompleted ¶ added in v1.15.1
func (t *TransactionState) IsCompleted() bool
func (*TransactionState) IsFailed ¶ added in v1.15.1
func (t *TransactionState) IsFailed() bool
func (*TransactionState) IsPending ¶ added in v1.15.1
func (t *TransactionState) IsPending() bool
type TransactionStatus ¶ added in v1.17.2
type TransactionStatus struct {
State TransactionState
FailReason string // filled in only if state of transaction is transactionFailed
}