Documentation
¶
Index ¶
- Constants
- Variables
- func BuildUserAgent(cfg *config.Config) string
- func CheckStatus(resp interface{}) error
- func LoggerAndContext(ctx context.Context, c any) (*logger.DBSQLLogger, context.Context)
- func PooledClient(cfg *config.Config) *http.Client
- func PooledTransport(cfg *config.Config) *http.Transport
- func RetryPolicy(ctx context.Context, resp *http.Response, err error) (bool, error)
- func RetryableClient(cfg *config.Config) *http.Client
- func SprintGuid(bts []byte) string
- func WithSkipTransientRetries(ctx context.Context) context.Context
- type TestClient
- func (c *TestClient) CancelDelegationToken(ctx context.Context, req *cli_service.TCancelDelegationTokenReq) (_r *cli_service.TCancelDelegationTokenResp, _err error)
- func (c *TestClient) CancelOperation(ctx context.Context, req *cli_service.TCancelOperationReq) (_r *cli_service.TCancelOperationResp, _err error)
- func (c *TestClient) CloseOperation(ctx context.Context, req *cli_service.TCloseOperationReq) (_r *cli_service.TCloseOperationResp, _err error)
- func (c *TestClient) CloseSession(ctx context.Context, req *cli_service.TCloseSessionReq) (_r *cli_service.TCloseSessionResp, _err error)
- func (c *TestClient) ExecuteStatement(ctx context.Context, req *cli_service.TExecuteStatementReq) (_r *cli_service.TExecuteStatementResp, _err error)
- func (c *TestClient) FetchResults(ctx context.Context, req *cli_service.TFetchResultsReq) (_r *cli_service.TFetchResultsResp, _err error)
- func (c *TestClient) GetCatalogs(ctx context.Context, req *cli_service.TGetCatalogsReq) (_r *cli_service.TGetCatalogsResp, _err error)
- func (c *TestClient) GetColumns(ctx context.Context, req *cli_service.TGetColumnsReq) (_r *cli_service.TGetColumnsResp, _err error)
- func (c *TestClient) GetCrossReference(ctx context.Context, req *cli_service.TGetCrossReferenceReq) (_r *cli_service.TGetCrossReferenceResp, _err error)
- func (c *TestClient) GetDelegationToken(ctx context.Context, req *cli_service.TGetDelegationTokenReq) (_r *cli_service.TGetDelegationTokenResp, _err error)
- func (c *TestClient) GetFunctions(ctx context.Context, req *cli_service.TGetFunctionsReq) (_r *cli_service.TGetFunctionsResp, _err error)
- func (c *TestClient) GetInfo(ctx context.Context, req *cli_service.TGetInfoReq) (_r *cli_service.TGetInfoResp, _err error)
- func (c *TestClient) GetOperationStatus(ctx context.Context, req *cli_service.TGetOperationStatusReq) (_r *cli_service.TGetOperationStatusResp, _err error)
- func (c *TestClient) GetPrimaryKeys(ctx context.Context, req *cli_service.TGetPrimaryKeysReq) (_r *cli_service.TGetPrimaryKeysResp, _err error)
- func (c *TestClient) GetResultSetMetadata(ctx context.Context, req *cli_service.TGetResultSetMetadataReq) (_r *cli_service.TGetResultSetMetadataResp, _err error)
- func (c *TestClient) GetSchemas(ctx context.Context, req *cli_service.TGetSchemasReq) (_r *cli_service.TGetSchemasResp, _err error)
- func (c *TestClient) GetTableTypes(ctx context.Context, req *cli_service.TGetTableTypesReq) (_r *cli_service.TGetTableTypesResp, _err error)
- func (c *TestClient) GetTables(ctx context.Context, req *cli_service.TGetTablesReq) (_r *cli_service.TGetTablesResp, _err error)
- func (c *TestClient) GetTypeInfo(ctx context.Context, req *cli_service.TGetTypeInfoReq) (_r *cli_service.TGetTypeInfoResp, _err error)
- func (c *TestClient) OpenSession(ctx context.Context, req *cli_service.TOpenSessionReq) (_r *cli_service.TOpenSessionResp, _err error)
- func (c *TestClient) RenewDelegationToken(ctx context.Context, req *cli_service.TRenewDelegationTokenReq) (_r *cli_service.TRenewDelegationTokenResp, _err error)
- type ThriftResponse
- type ThriftServiceClient
- func (tsc *ThriftServiceClient) CancelOperation(ctx context.Context, req *cli_service.TCancelOperationReq) (*cli_service.TCancelOperationResp, error)
- func (tsc *ThriftServiceClient) CloseOperation(ctx context.Context, req *cli_service.TCloseOperationReq) (*cli_service.TCloseOperationResp, error)
- func (tsc *ThriftServiceClient) CloseSession(ctx context.Context, req *cli_service.TCloseSessionReq) (*cli_service.TCloseSessionResp, error)
- func (tsc *ThriftServiceClient) ExecuteStatement(ctx context.Context, req *cli_service.TExecuteStatementReq) (*cli_service.TExecuteStatementResp, error)
- func (tsc *ThriftServiceClient) FetchResults(ctx context.Context, req *cli_service.TFetchResultsReq) (*cli_service.TFetchResultsResp, error)
- func (tsc *ThriftServiceClient) GetOperationStatus(ctx context.Context, req *cli_service.TGetOperationStatusReq) (*cli_service.TGetOperationStatusResp, error)
- func (tsc *ThriftServiceClient) GetResultSetMetadata(ctx context.Context, req *cli_service.TGetResultSetMetadataReq) (*cli_service.TGetResultSetMetadataResp, error)
- func (tsc *ThriftServiceClient) OpenSession(ctx context.Context, req *cli_service.TOpenSessionReq) (*cli_service.TOpenSessionResp, error)
- type Transport
Constants ¶
const ( ClientMethod contextKey = iota // SkipTransientRetries, when set to true on the request context, makes // RetryPolicy treat every status code recognized by // isRetryableServerResponse (currently 429 and 503) as a non-retryable // response — the request returns after a single attempt. Generic 5xx // (500/502/504) and transport errors are still gated by ClientMethod // as usual; callers that omit ClientMethod (e.g. the telemetry // exporter) already get one-shot semantics on those, so the net effect // is exactly one HTTP transaction per request. // // Set by callers that own their own backoff and need each HTTP // outcome surfaced individually (e.g. the telemetry exporter, whose // circuit breaker is the sole arbiter of when to back off). SkipTransientRetries )
Variables ¶
var ErrNotImplemented = errors.New("databricks: not implemented")
var RecordResults bool
RecordResults is used to generate test data. Developer should change this manually
Functions ¶
func BuildUserAgent ¶ added in v1.12.0
BuildUserAgent constructs the User-Agent header value used by the driver for Thrift, telemetry, and feature-flag requests so all traffic from a single connection is attributable to the same identifier in access logs.
Format: "<driverName>/<driverVersion>[ (<userAgentEntry>)][ agent/<detectedAgent>]"
func CheckStatus ¶
func CheckStatus(resp interface{}) error
CheckStatus checks the status code after a thrift operation. Returns nil if the operation is successful or still executing, otherwise returns an error.
func LoggerAndContext ¶ added in v1.5.1
Create an updated context and a logger that includes query and connection id
func RetryPolicy ¶ added in v1.1.0
func SprintGuid ¶
SprintGuid is a convenience function to format a byte array into GUID.
func WithSkipTransientRetries ¶ added in v1.12.0
WithSkipTransientRetries returns a context that disables retryablehttp's retries for the transient-server-response codes (429 + 503). The caller takes responsibility for handling these responses (e.g. via a circuit breaker that parses Retry-After).
Combined with a ClientMethod that already opts out of generic-5xx retries (the default zero value clientMethodUnknown does), this gives one-shot semantics on every failure mode: each call to httpClient.Do returns exactly one outcome to the caller.
Types ¶
type TestClient ¶
type TestClient struct {
FnOpenSession func(ctx context.Context, req *cli_service.TOpenSessionReq) (_r *cli_service.TOpenSessionResp, _err error)
FnCloseSession func(ctx context.Context, req *cli_service.TCloseSessionReq) (_r *cli_service.TCloseSessionResp, _err error)
FnGetInfo func(ctx context.Context, req *cli_service.TGetInfoReq) (_r *cli_service.TGetInfoResp, _err error)
FnExecuteStatement func(ctx context.Context, req *cli_service.TExecuteStatementReq) (_r *cli_service.TExecuteStatementResp, _err error)
FnGetTypeInfo func(ctx context.Context, req *cli_service.TGetTypeInfoReq) (_r *cli_service.TGetTypeInfoResp, _err error)
FnGetCatalogs func(ctx context.Context, req *cli_service.TGetCatalogsReq) (_r *cli_service.TGetCatalogsResp, _err error)
FnGetSchemas func(ctx context.Context, req *cli_service.TGetSchemasReq) (_r *cli_service.TGetSchemasResp, _err error)
FnGetTables func(ctx context.Context, req *cli_service.TGetTablesReq) (_r *cli_service.TGetTablesResp, _err error)
FnGetTableTypes func(ctx context.Context, req *cli_service.TGetTableTypesReq) (_r *cli_service.TGetTableTypesResp, _err error)
FnGetColumns func(ctx context.Context, req *cli_service.TGetColumnsReq) (_r *cli_service.TGetColumnsResp, _err error)
FnGetFunctions func(ctx context.Context, req *cli_service.TGetFunctionsReq) (_r *cli_service.TGetFunctionsResp, _err error)
FnGetPrimaryKeys func(ctx context.Context, req *cli_service.TGetPrimaryKeysReq) (_r *cli_service.TGetPrimaryKeysResp, _err error)
FnGetCrossReference func(ctx context.Context, req *cli_service.TGetCrossReferenceReq) (_r *cli_service.TGetCrossReferenceResp, _err error)
FnGetOperationStatus func(ctx context.Context, req *cli_service.TGetOperationStatusReq) (_r *cli_service.TGetOperationStatusResp, _err error)
FnCancelOperation func(ctx context.Context, req *cli_service.TCancelOperationReq) (_r *cli_service.TCancelOperationResp, _err error)
FnCloseOperation func(ctx context.Context, req *cli_service.TCloseOperationReq) (_r *cli_service.TCloseOperationResp, _err error)
FnGetResultSetMetadata func(ctx context.Context, req *cli_service.TGetResultSetMetadataReq) (_r *cli_service.TGetResultSetMetadataResp, _err error)
FnFetchResults func(ctx context.Context, req *cli_service.TFetchResultsReq) (_r *cli_service.TFetchResultsResp, _err error)
FnGetDelegationToken func(ctx context.Context, req *cli_service.TGetDelegationTokenReq) (_r *cli_service.TGetDelegationTokenResp, _err error)
FnCancelDelegationToken func(ctx context.Context, req *cli_service.TCancelDelegationTokenReq) (_r *cli_service.TCancelDelegationTokenResp, _err error)
FnRenewDelegationToken func(ctx context.Context, req *cli_service.TRenewDelegationTokenReq) (_r *cli_service.TRenewDelegationTokenResp, _err error)
}
func (*TestClient) CancelDelegationToken ¶
func (c *TestClient) CancelDelegationToken(ctx context.Context, req *cli_service.TCancelDelegationTokenReq) (_r *cli_service.TCancelDelegationTokenResp, _err error)
func (*TestClient) CancelOperation ¶
func (c *TestClient) CancelOperation(ctx context.Context, req *cli_service.TCancelOperationReq) (_r *cli_service.TCancelOperationResp, _err error)
func (*TestClient) CloseOperation ¶
func (c *TestClient) CloseOperation(ctx context.Context, req *cli_service.TCloseOperationReq) (_r *cli_service.TCloseOperationResp, _err error)
func (*TestClient) CloseSession ¶
func (c *TestClient) CloseSession(ctx context.Context, req *cli_service.TCloseSessionReq) (_r *cli_service.TCloseSessionResp, _err error)
func (*TestClient) ExecuteStatement ¶
func (c *TestClient) ExecuteStatement(ctx context.Context, req *cli_service.TExecuteStatementReq) (_r *cli_service.TExecuteStatementResp, _err error)
func (*TestClient) FetchResults ¶
func (c *TestClient) FetchResults(ctx context.Context, req *cli_service.TFetchResultsReq) (_r *cli_service.TFetchResultsResp, _err error)
func (*TestClient) GetCatalogs ¶
func (c *TestClient) GetCatalogs(ctx context.Context, req *cli_service.TGetCatalogsReq) (_r *cli_service.TGetCatalogsResp, _err error)
func (*TestClient) GetColumns ¶
func (c *TestClient) GetColumns(ctx context.Context, req *cli_service.TGetColumnsReq) (_r *cli_service.TGetColumnsResp, _err error)
func (*TestClient) GetCrossReference ¶
func (c *TestClient) GetCrossReference(ctx context.Context, req *cli_service.TGetCrossReferenceReq) (_r *cli_service.TGetCrossReferenceResp, _err error)
func (*TestClient) GetDelegationToken ¶
func (c *TestClient) GetDelegationToken(ctx context.Context, req *cli_service.TGetDelegationTokenReq) (_r *cli_service.TGetDelegationTokenResp, _err error)
func (*TestClient) GetFunctions ¶
func (c *TestClient) GetFunctions(ctx context.Context, req *cli_service.TGetFunctionsReq) (_r *cli_service.TGetFunctionsResp, _err error)
func (*TestClient) GetInfo ¶
func (c *TestClient) GetInfo(ctx context.Context, req *cli_service.TGetInfoReq) (_r *cli_service.TGetInfoResp, _err error)
func (*TestClient) GetOperationStatus ¶
func (c *TestClient) GetOperationStatus(ctx context.Context, req *cli_service.TGetOperationStatusReq) (_r *cli_service.TGetOperationStatusResp, _err error)
func (*TestClient) GetPrimaryKeys ¶
func (c *TestClient) GetPrimaryKeys(ctx context.Context, req *cli_service.TGetPrimaryKeysReq) (_r *cli_service.TGetPrimaryKeysResp, _err error)
func (*TestClient) GetResultSetMetadata ¶
func (c *TestClient) GetResultSetMetadata(ctx context.Context, req *cli_service.TGetResultSetMetadataReq) (_r *cli_service.TGetResultSetMetadataResp, _err error)
func (*TestClient) GetSchemas ¶
func (c *TestClient) GetSchemas(ctx context.Context, req *cli_service.TGetSchemasReq) (_r *cli_service.TGetSchemasResp, _err error)
func (*TestClient) GetTableTypes ¶
func (c *TestClient) GetTableTypes(ctx context.Context, req *cli_service.TGetTableTypesReq) (_r *cli_service.TGetTableTypesResp, _err error)
func (*TestClient) GetTables ¶
func (c *TestClient) GetTables(ctx context.Context, req *cli_service.TGetTablesReq) (_r *cli_service.TGetTablesResp, _err error)
func (*TestClient) GetTypeInfo ¶
func (c *TestClient) GetTypeInfo(ctx context.Context, req *cli_service.TGetTypeInfoReq) (_r *cli_service.TGetTypeInfoResp, _err error)
func (*TestClient) OpenSession ¶
func (c *TestClient) OpenSession(ctx context.Context, req *cli_service.TOpenSessionReq) (_r *cli_service.TOpenSessionResp, _err error)
func (*TestClient) RenewDelegationToken ¶
func (c *TestClient) RenewDelegationToken(ctx context.Context, req *cli_service.TRenewDelegationTokenReq) (_r *cli_service.TRenewDelegationTokenResp, _err error)
type ThriftResponse ¶
type ThriftResponse interface {
GetStatus() *cli_service.TStatus
}
ThriftResponse represents the thrift rpc response
type ThriftServiceClient ¶
type ThriftServiceClient struct {
*cli_service.TCLIServiceClient
}
func InitThriftClient ¶
InitThriftClient is a wrapper of the http transport, so we can have access to response code and headers. It is important to know the code and headers to know if we need to retry or not
func (*ThriftServiceClient) CancelOperation ¶
func (tsc *ThriftServiceClient) CancelOperation(ctx context.Context, req *cli_service.TCancelOperationReq) (*cli_service.TCancelOperationResp, error)
CancelOperation is a wrapper around the thrift operation CancelOperation If RecordResults is true, the results will be marshalled to JSON format and written to CancelOperation<index>.json
func (*ThriftServiceClient) CloseOperation ¶
func (tsc *ThriftServiceClient) CloseOperation(ctx context.Context, req *cli_service.TCloseOperationReq) (*cli_service.TCloseOperationResp, error)
CloseOperation is a wrapper around the thrift operation CloseOperation If RecordResults is true, the results will be marshalled to JSON format and written to CloseOperation<index>.json
func (*ThriftServiceClient) CloseSession ¶
func (tsc *ThriftServiceClient) CloseSession(ctx context.Context, req *cli_service.TCloseSessionReq) (*cli_service.TCloseSessionResp, error)
CloseSession is a wrapper around the thrift operation CloseSession If RecordResults is true, the results will be marshalled to JSON format and written to CloseSession<index>.json
func (*ThriftServiceClient) ExecuteStatement ¶
func (tsc *ThriftServiceClient) ExecuteStatement(ctx context.Context, req *cli_service.TExecuteStatementReq) (*cli_service.TExecuteStatementResp, error)
ExecuteStatement is a wrapper around the thrift operation ExecuteStatement If RecordResults is true, the results will be marshalled to JSON format and written to ExecuteStatement<index>.json
func (*ThriftServiceClient) FetchResults ¶
func (tsc *ThriftServiceClient) FetchResults(ctx context.Context, req *cli_service.TFetchResultsReq) (*cli_service.TFetchResultsResp, error)
FetchResults is a wrapper around the thrift operation FetchResults If RecordResults is true, the results will be marshalled to JSON format and written to FetchResults<index>.json
func (*ThriftServiceClient) GetOperationStatus ¶
func (tsc *ThriftServiceClient) GetOperationStatus(ctx context.Context, req *cli_service.TGetOperationStatusReq) (*cli_service.TGetOperationStatusResp, error)
GetOperationStatus is a wrapper around the thrift operation GetOperationStatus If RecordResults is true, the results will be marshalled to JSON format and written to GetOperationStatus<index>.json
func (*ThriftServiceClient) GetResultSetMetadata ¶
func (tsc *ThriftServiceClient) GetResultSetMetadata(ctx context.Context, req *cli_service.TGetResultSetMetadataReq) (*cli_service.TGetResultSetMetadataResp, error)
GetResultSetMetadata is a wrapper around the thrift operation GetResultSetMetadata If RecordResults is true, the results will be marshalled to JSON format and written to GetResultSetMetadata<index>.json
func (*ThriftServiceClient) OpenSession ¶
func (tsc *ThriftServiceClient) OpenSession(ctx context.Context, req *cli_service.TOpenSessionReq) (*cli_service.TOpenSessionResp, error)
OpenSession is a wrapper around the thrift operation OpenSession If RecordResults is true, the results will be marshalled to JSON format and written to OpenSession<index>.json