common

package
v0.5.12-rc.3 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2024 License: Apache-2.0 Imports: 44 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ForbidRetries = "forbid_retries"
	TestName      = "test_name"
)

Variables

View Source
var (
	ErrTableDoesNotExist                   = fmt.Errorf("table does not exist")
	ErrDataSourceNotSupported              = fmt.Errorf("data source not supported")
	ErrDataTypeNotSupported                = fmt.Errorf("data type not supported")
	ErrDataTypeMismatch                    = fmt.Errorf("data type mismatch")
	ErrMethodNotSupported                  = fmt.Errorf("method not supported")
	ErrReadLimitExceeded                   = fmt.Errorf("read limit exceeded")
	ErrInvalidRequest                      = fmt.Errorf("invalid request")
	ErrValueOutOfTypeBounds                = fmt.Errorf("value is out of possible range of values for the type")
	ErrUnimplementedTypedValue             = fmt.Errorf("unimplemented typed value")
	ErrUnimplementedExpression             = fmt.Errorf("unimplemented expression")
	ErrUnsupportedExpression               = fmt.Errorf("expression is not supported")
	ErrUnimplementedOperation              = fmt.Errorf("unimplemented operation")
	ErrUnimplementedPredicateType          = fmt.Errorf("unimplemented predicate type")
	ErrInvariantViolation                  = fmt.Errorf("implementation error (invariant violation)")
	ErrUnimplementedArithmeticalExpression = fmt.Errorf("unimplemented arithmetical expression")
	ErrEmptyTableName                      = fmt.Errorf("empty table name")
	ErrPageSizeExceeded                    = fmt.Errorf("page size exceeded, check service configuration")
)

Functions

func APIErrorToLogFields

func APIErrorToLogFields(apiErr *api_service_protos.TError) []zap.Field

func AllStreamResponsesSuccessfull

func AllStreamResponsesSuccessfull[T StreamResponse](responses []T) bool

func AnnotateLoggerForUnaryCall

func AnnotateLoggerForUnaryCall(l *zap.Logger, method string, dsi *api_common.TDataSourceInstance) *zap.Logger

func AnnotateLoggerWithDataSourceInstance

func AnnotateLoggerWithDataSourceInstance(l *zap.Logger, dsi *api_common.TDataSourceInstance) *zap.Logger

func AnnotateLoggerWithMethod

func AnnotateLoggerWithMethod(l *zap.Logger, method string) *zap.Logger

func DiffStatusSensors added in v0.2.13

func DiffStatusSensors(oldSnapshot, newSnapshot *MetricsSnapshot, typ, method, name, status string) (float64, error)

func DurationFromString added in v0.2.18

func DurationFromString(src string) (time.Duration, error)

func EndpointToString

func EndpointToString(ep *api_common.TEndpoint) string

func ExtractErrorFromReadResponses added in v0.5.11

func ExtractErrorFromReadResponses(responses []*api_service_protos.TReadSplitsResponse) error

func GetCallStackFunctionNames added in v0.5.12

func GetCallStackFunctionNames() []string

func IsSuccess

func IsSuccess(apiErr *api_service_protos.TError) bool

func LogCloserError

func LogCloserError(logger *zap.Logger, closer io.Closer, msg string)

func MakeListType added in v0.4.8

func MakeListType(ydbType *Ydb.Type) *Ydb.Type

func MakeOptionalType

func MakeOptionalType(ydbType *Ydb.Type) *Ydb.Type

func MakePrimitiveType

func MakePrimitiveType(typeId Ydb.Type_PrimitiveTypeId) *Ydb.Type

func MakeTypedValue

func MakeTypedValue(ydbType *Ydb.Type, value any) *Ydb.TypedValue

func MakeYdbDateTimeType added in v0.1.2

func MakeYdbDateTimeType(ydbTypeID Ydb.Type_PrimitiveTypeId, format api_service_protos.EDateTimeFormat) (*Ydb.Type, error)

func MustDurationFromString added in v0.2.18

func MustDurationFromString(src string) time.Duration

func MustTimeToYDBType

func MustTimeToYDBType[OUT ydbTime](f func(t *time.Time) (OUT, error), t time.Time) OUT

func NewAPIErrorFromStdError

func NewAPIErrorFromStdError(err error, kind api_common.EDataSourceKind) *api_service_protos.TError

func NewConfigFromPrototextFile added in v0.1.2

func NewConfigFromPrototextFile[T AppConfig](configPath string, dst T) error

func NewDefaultLogger

func NewDefaultLogger() *zap.Logger

func NewLoggerFromConfig

func NewLoggerFromConfig(cfg *config.TLoggerConfig) (*zap.Logger, error)

func NewSTDErrorFromAPIError

func NewSTDErrorFromAPIError(apiErr *api_service_protos.TError) error

func NewSuccess

func NewSuccess() *api_service_protos.TError

func NewTestLogger

func NewTestLogger(t *testing.T) *zap.Logger

func ReadResponsesToArrowRecords

func ReadResponsesToArrowRecords(responses []*api_service_protos.TReadSplitsResponse) ([]arrow.Record, error)

func SchemaToSelectWhatItems

func SchemaToSelectWhatItems(
	schema *api_service_protos.TSchema,
	whitelist map[string]struct{},
) *api_service_protos.TSelect_TWhat

func SelectToFields

func SelectToFields(slct *api_service_protos.TSelect) []zap.Field

func SelectWhatToArrowSchema

func SelectWhatToArrowSchema(selectWhat *api_service_protos.TSelect_TWhat) (*arrow.Schema, error)

func SelectWhatToYDBTypes

func SelectWhatToYDBTypes(selectWhat *api_service_protos.TSelect_TWhat) ([]*Ydb.Type, error)

func TimeToYDBDate

func TimeToYDBDate(t *time.Time) (uint16, error)

func TimeToYDBDatetime

func TimeToYDBDatetime(t *time.Time) (uint32, error)

func TimeToYDBTimestamp

func TimeToYDBTimestamp(t *time.Time) (uint64, error)

func YdbTypeToYdbPrimitiveTypeID

func YdbTypeToYdbPrimitiveTypeID(ydbType *Ydb.Type) (Ydb.Type_PrimitiveTypeId, error)

func YdbTypesToArrowBuilders

func YdbTypesToArrowBuilders(ydbTypes []*Ydb.Type, arrowAllocator memory.Allocator) ([]array.Builder, error)

Types

type AppConfig added in v0.1.2

type AppConfig interface {
	*config.TClientConfig | *config.TBenchmarkConfig
	proto.Message
}

type ArrowArrayType

type ArrowArrayType[VT ValueType] interface {
	*array.Boolean |
		*array.Int8 | *array.Int16 | *array.Int32 | *array.Int64 |
		*array.Uint8 | *array.Uint16 | *array.Uint32 | *array.Uint64 |
		*array.Float32 | *array.Float64 |
		*array.String | *array.Binary

	Len() int
	Value(int) VT
	IsNull(int) bool
}

type ArrowBuilder

type ArrowBuilder[VT ValueType] interface {
	AppendNull()
	Append(value VT)
}

type ClientBuffering added in v0.1.2

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

func NewClientBufferingFromClientConfig added in v0.1.2

func NewClientBufferingFromClientConfig(logger *zap.Logger, clientCfg *config.TClientConfig) (*ClientBuffering, error)

func NewClientBufferingFromServerConfig added in v0.1.2

func NewClientBufferingFromServerConfig(logger *zap.Logger, serverCfg *config.TServerConfig) (*ClientBuffering, error)

func (*ClientBuffering) Close added in v0.1.2

func (c *ClientBuffering) Close()

func (*ClientBuffering) DescribeTable added in v0.1.2

func (c *ClientBuffering) DescribeTable(
	ctx context.Context,
	dsi *api_common.TDataSourceInstance,
	typeMappingSettings *api_service_protos.TTypeMappingSettings,
	tableName string,
) (*api_service_protos.TDescribeTableResponse, error)

func (*ClientBuffering) ListSplits added in v0.1.2

func (*ClientBuffering) ReadSplits added in v0.1.2

type ClientStreaming added in v0.1.2

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

func NewClientStreamingFromClientConfig added in v0.1.2

func NewClientStreamingFromClientConfig(logger *zap.Logger, clientCfg *config.TClientConfig) (*ClientStreaming, error)

func NewClientStreamingFromServerConfig added in v0.1.2

func NewClientStreamingFromServerConfig(logger *zap.Logger, serverCfg *config.TServerConfig) (*ClientStreaming, error)

func (*ClientStreaming) Close added in v0.1.2

func (c *ClientStreaming) Close()

func (*ClientStreaming) DescribeTable added in v0.1.2

func (c *ClientStreaming) DescribeTable(
	ctx context.Context,
	dsi *api_common.TDataSourceInstance,
	typeMappingSettings *api_service_protos.TTypeMappingSettings,
	tableName string,
) (*api_service_protos.TDescribeTableResponse, error)

func (*ClientStreaming) ListSplits added in v0.1.2

func (*ClientStreaming) ReadSplits added in v0.1.2

type MetricsSnapshot added in v0.2.13

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

MetricsSnapshot is an instant view of statistics provided by the `fq-connector-go` service

func NewMetricsSnapshot added in v0.2.13

func NewMetricsSnapshot(endpoint *api_common.TEndpoint, useTLS bool) (*MetricsSnapshot, error)

func (*MetricsSnapshot) FindStatusSensors added in v0.2.13

func (ms *MetricsSnapshot) FindStatusSensors(typ, method, name, status string) []StatusSensor

type QueryLogger

type QueryLogger struct {
	*zap.Logger
	// contains filtered or unexported fields
}

func (*QueryLogger) Dump

func (ql *QueryLogger) Dump(query string, args ...any)

type QueryLoggerFactory

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

func NewQueryLoggerFactory

func NewQueryLoggerFactory(cfg *config.TLoggerConfig) QueryLoggerFactory

func (*QueryLoggerFactory) Make

func (f *QueryLoggerFactory) Make(logger *zap.Logger) QueryLogger

type ReadSplitsOption added in v0.5.11

type ReadSplitsOption interface {
	// contains filtered or unexported methods
}

func WithFiltering added in v0.5.11

type StatusSensor added in v0.2.13

type StatusSensor struct {
	Method string
	Name   string
	Status string
	Value  float64
}

type StreamResult added in v0.1.2

type StreamResult[T StreamResponse] struct {
	Response T
	Err      error
}

type TestingServer added in v0.2.21

type TestingServer interface {
	Start()
	ClientBuffering() *ClientBuffering
	ClientStreaming() *ClientStreaming
	MetricsSnapshot() (*MetricsSnapshot, error)
	Stop()
}

TestingServer is mainly used in integration tests or benchmarks. It may be either a real Connector server embedded in this process, or a Connector client connected to the remote server instance.

func NewTestingServerRemote added in v0.2.21

func NewTestingServerRemote(logger *zap.Logger, clientCfg *config.TClientConfig) (TestingServer, error)

type ValueType

type ValueType interface {
	bool |
		int8 | int16 | int32 | int64 |
		uint8 | uint16 | uint32 | uint64 |
		float32 | float64 |
		string | []byte |
		time.Time
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL