yqlclient

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2023 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Overview

Package yqlclient provides YTSaurus YQL client.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ReadResult

func ReadResult[T any](ctx context.Context, c *Client, queryID ytqueryapi.QueryID, format ResultFormat[T]) (iterators.Iterator[T], error)

ReadResult reads result of given query ID.

func YQLQuery

func YQLQuery[T any](ctx context.Context, c *Client, q string) (iterators.Iterator[T], error)

YQLQuery makes an YQL query.

Types

type Client

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

Client is a YQL client.

func NewClient

func NewClient(proxyURL string, opts ClientOptions) (*Client, error)

NewClient creates new Client.

func (*Client) ExecuteQuery

func (c *Client) ExecuteQuery(ctx context.Context, q string, params ExecuteQueryParams) (queryID ytqueryapi.QueryID, rerr error)

ExecuteQuery starts query and waits for query completion.

Caller may abort the query by canceling the context.

func (*Client) RawClient

func (c *Client) RawClient() *ytqueryapi.Client

RawClient returns raw client.

type ClientOptions

type ClientOptions struct {
	// Token to use. If empty, authentication would not be used.
	Token string

	// Client to use. Defaults to http.DefaultClient.
	Client *http.Client

	// TracerProvider is a tracer provider. Defaults to otel.GetTracerProvider.
	TracerProvider trace.TracerProvider
	// MeterProvider is a meter provider. Defaults to otel.GetMeterProvider.
	MeterProvider metric.MeterProvider
}

ClientOptions is a Client creation options.

type Error

type Error struct {
	Err ytqueryapi.Error
}

Error is a wrapper for API error.

func (*Error) Error

func (e *Error) Error() string

Error implements error.

type ExecuteQueryParams

type ExecuteQueryParams struct {
	// PollInterval is a query result polling interval. Defaults to 1s.
	PollInterval time.Duration

	// AbortTimeout sets timeout for aborting query. Defaults to 10s.
	AbortTimeout time.Duration

	// Engine to run query. Defaults to YQL.
	Engine ytqueryapi.Engine
}

ExecuteQueryParams sets ExecuteQuery parameters.

type ResultFormat

type ResultFormat[T any] interface {
	Format() ytqueryapi.OutputFormat
	Iter(r io.Reader) (iterators.Iterator[T], error)
}

ResultFormat defines result decoder.

type YSONFormat

type YSONFormat[T any] struct{}

YSONFormat decodes result as YSON.

func (YSONFormat[T]) Format

func (YSONFormat[T]) Format() ytqueryapi.OutputFormat

Format implements ResultFormat.

func (YSONFormat[T]) Iter

func (YSONFormat[T]) Iter(r io.Reader) (iterators.Iterator[T], error)

Iter implements ResultFormat.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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