yt

package
v0.0.0-...-5019c65 Latest Latest
Warning

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

Go to latest
Published: May 23, 2023 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Overview

Package yt defines interfaces of different YT services.

All API methods follow the same conventions:

  • First argument is context.Context.
  • Last argument is pointer to Options struct.
  • Other arguments are required parameters.

Zero value of every Options struct corresponds to default values of parameters.

You may pass nil as the last argument.

var ctx context.Context
var y yt.Client
p := ypath.Path("//foo/bar/@zog")

// These two calls do the same thing.
y.SetNode(ctx, p, 1, nil)
y.SetNode(ctx, p, 1, &yt.SetNodeOptions{})

By default, client retries all transient errors 5 times. Use context.WithTimeout to provide timeout for api call.

API methods are grouped into interfaces, according to part of the system they interact with:

  • CypressClient - cypress nodes
  • LowLevelTxClient - cypress transactions
  • LockClient - cypress locks
  • LowLevelSchedulerClient - scheduler
  • FileClient - file operations
  • TableClient - table operations
  • AdminClient - misc administrative commands
  • TabletClient - dynamic tables

Finally, yt.Client and yt.Tx provide high level api for transactions and embed interfaces of different subsystems.

Index

Examples

Constants

View Source
const (
	TVMOnlyHTTPProxyPort  = 9026
	TVMOnlyHTTPSProxyPort = 9443
	TVMOnlyRPCProxyPort   = 9027
)
View Source
const (
	DefaultLightRequestTimeout = 5 * time.Minute
	DefaultTxTimeout           = 15 * time.Second
	DefaultTxPingPeriod        = 3 * time.Second
)
View Source
const (
	// XYaServiceTicket is http header that should be used for service ticket transfer.
	XYaServiceTicket = "X-Ya-Service-Ticket"
	// XYaUserTicket is http header that should be used for user ticket transfer.
	XYaUserTicket = "X-Ya-User-Ticket"
)
View Source
const (
	TabletMounted    = "mounted"
	TabletMounting   = "mounting"
	TabletUnmounted  = "unmounted"
	TabletUnmounting = "unmounting"
	TabletFrozen     = "frozen"
	TabletFreezing   = "freezing"
	TabletTransient  = "transient"
)
View Source
const (
	DefaultExecTxRetryCount   = 5
	DefaultExecTxRetryBackoff = time.Second
)

Variables

View Source
var NullOperationID = OperationID(guid.FromHalves(0, 0))

Functions

func ApproximateRowCount

func ApproximateRowCount(r TableReader) (count int64, ok bool)

ApproximateRowCount returns approximation of total number of rows in this reader.

Might not be available, depending on the underlying implementation

func ConvertPermissionType

func ConvertPermissionType(typ *Permission) (*int32, error)

func ExecTabletTx

func ExecTabletTx(ctx context.Context, yc Client, f TabletTxFunc, opts *ExecTabletTxOptions) (err error)

ExecTabletTx a convenience method that creates new tablet transaction and executes commit/abort based on the error returned by the callback function.

In case of nil options default ones are used.

Retries could be stopped with the context cancellation.

If f returns a *backoff.PermanentError, the operation is not retried, and the wrapped error is returned.

func ExecTx

func ExecTx(ctx context.Context, yc Client, f TxFunc, opts *ExecTxOptions) (err error)

ExecTx is a convenience method that creates new master transaction and executes commit/abort based on the error returned by the callback function.

In case of nil options default ones are used.

Retries could be stopped with the context cancellation.

If f returns a *backoff.PermanentError, the operation is not retried, and the wrapped error is returned.

func MustConvertPermissionType

func MustConvertPermissionType(typ *Permission) *int32

func PollMaster

func PollMaster(ctx context.Context, yc Client, poll func() (stop bool, err error)) error

PollMaster abstracts away places where you would like to poll state change from the master.

Calls poll in a loop until either, poll() returns an error, poll() signals to stop or ctx is canceled.

func RangeJobs

func RangeJobs(ctx context.Context, yc Client, opID OperationID, opts *ListJobsOptions, cb RangeJobsCallback) error

RangeJobs iterates over operation jobs with pagination and calls cb on each job.

func RangeOperations

func RangeOperations(ctx context.Context, yc Client, opts *ListOperationsOptions, cb RangeOperationsCallback) error

RangeOperations iterates over operations with pagination and calls cb on each operation.

func StartRowIndex

func StartRowIndex(r TableReader) (rowIndex int64, ok bool)

StartRowIndex returns row index of the first row in table reader.

Index might not be available, depending on the underlying implementation

func WebUIOperationURL

func WebUIOperationURL(cluster string, opID OperationID) string

func WebUITableURL

func WebUITableURL(cluster string, path ypath.Path) string

func WithCredentials

func WithCredentials(ctx context.Context, credentials Credentials) context.Context

WithCredentials allows overriding client credentials on per-call basis.

Types

type ACE

type ACE struct {
	Action          SecurityAction `yson:"action,omitempty"`
	Subjects        []string       `yson:"subjects,omitempty"`
	Permissions     []Permission   `yson:"permissions,omitempty"`
	InheritanceMode string         `yson:"inheritance_mode,omitempty"`
	Columns         []string       `yson:"columns,omitempty"`
	Vital           *bool          `yson:"vital,omitempty"`
}

type AbortOperationOptions

type AbortOperationOptions struct {
	AbortMessage *string `http:"abort_message,omitnil"`
}

type AbortTxOptions

type AbortTxOptions struct {
	Sticky bool `http:"sticky"`

	*TransactionOptions
	*MutatingOptions
	*PrerequisiteOptions
}

type AccessTrackingOptions

type AccessTrackingOptions struct {
	SuppressAccessTracking       bool `http:"suppress_access_tracking"`
	SuppressModificationTracking bool `http:"suppress_modification_tracking"`
}

AccessTrackingOptions suppresses update of "modification_time", "access_time" and "access_counter" cypress attributes.

type AddMemberOptions

type AddMemberOptions struct {
	*MutatingOptions
	*PrerequisiteOptions
}

type AdminClient

type AdminClient interface {
	// http:verb:"add_member"
	// http:params:"group","member"
	AddMember(
		ctx context.Context,
		group string,
		member string,
		options *AddMemberOptions,
	) (err error)

	// http:verb:"build_master_snapshots"
	BuildMasterSnapshots(
		ctx context.Context,
		options *BuildMasterSnapshotsOptions,
	) (result *BuildMasterSnapshotsResponse, err error)

	// http:verb:"remove_member"
	// http:params:"group","member"
	RemoveMember(
		ctx context.Context,
		group string,
		member string,
		options *RemoveMemberOptions,
	) (err error)

	// http:verb:"transfer_account_resources"
	// http:params:"source_account","destination_account","resource_delta"
	TransferAccountResources(
		ctx context.Context,
		srcAccount string,
		dstAccount string,
		resourceDelta interface{},
		options *TransferAccountResourcesOptions,
	) (err error)

	// http:verb:"transfer_pool_resources"
	// http:params:"source_pool","destination_pool","pool_tree","resource_delta"
	TransferPoolResources(
		ctx context.Context,
		srcPool string,
		dstPool string,
		poolTree string,
		resourceDelta interface{},
		options *TransferPoolResourcesOptions,
	) (err error)

	// http:verb:"check_permission"
	// http:params:"user","permission","path"
	CheckPermission(
		ctx context.Context,
		user string,
		permission Permission,
		path ypath.YPath,
		options *CheckPermissionOptions,
	) (result *CheckPermissionResponse, err error)

	// http:verb:"disable_chunk_locations"
	// http:params:"node_address","location_uuids"
	DisableChunkLocations(
		ctx context.Context,
		nodeAddress string,
		locationUuids []guid.GUID,
	) (result *DisableChunkLocationsResponse, err error)

	// http:verb:"destroy_chunk_locations"
	// http:params:"node_address","location_uuids"
	DestroyChunkLocations(
		ctx context.Context,
		nodeAddress string,
		locationUuids []guid.GUID,
	) (result *DestroyChunkLocationsResponse, err error)

	// http:verb:"resurrect_chunk_locations"
	// http:params:"node_address","location_uuids"
	ResurrectChunkLocations(
		ctx context.Context,
		nodeAddress string,
		locationUuids []guid.GUID,
	) (result *ResurrectChunkLocationsResponse, err error)
}

type AlterTableOptions

type AlterTableOptions struct {
	*MutatingOptions

	Schema            *schema.Schema `http:"schema,omitnil"`
	Dynamic           *bool          `http:"dynamic,omitnil"`
	UpstreamReplicaID *guid.GUID     `http:"upstream_replica_id,omitnil"`
}

type AlterTableReplicaOptions

type AlterTableReplicaOptions struct {
	Enabled *bool             `http:"enabled,omitnil"`
	Mode    *TableReplicaMode `http:"mode,omitnil"`
}

type Atomicity

type Atomicity string
var (
	AtomicityNone Atomicity = "none"
	AtomicityFull Atomicity = "full"
)

type BuildMasterSnapshot

type BuildMasterSnapshot struct {
	CellID     guid.GUID `yson:"cell_id"`
	SnapshotID int       `yson:"snapshot_id"`
}

type BuildMasterSnapshotsOptions

type BuildMasterSnapshotsOptions struct {
	SetReadOnly               *bool `yson:"set_read_only,omitnil"`
	WaitForSnapshotCompletion *bool `yson:"wait_for_snapshot_completion,omitnil"`
	Retry                     *bool `yson:"retry,omitnil"`
}

type BuildMasterSnapshotsResponse

type BuildMasterSnapshotsResponse = []BuildMasterSnapshot

type CheckPermissionOptions

type CheckPermissionOptions struct {
	*TransactionOptions
	*PrerequisiteOptions
	*MasterReadOptions

	Columns []string `http:"columns,omitnil"`
}

type CheckPermissionResponse

type CheckPermissionResponse struct {
	CheckPermissionResult

	Columns []CheckPermissionResult `yson:"columns,omitempty"`
}

type CheckPermissionResult

type CheckPermissionResult struct {
	Action      SecurityAction `yson:"action"`
	ObjectID    NodeID         `yson:"object_id,omitempty"`
	ObjectName  *string        `yson:"object_name,omitempty"`
	SubjectID   NodeID         `yson:"subject_id,omitempty"`
	SubjectName *string        `yson:"subject_name,omitempty"`
}

type ChunkSpec

type ChunkSpec struct {
	ChunkID    guid.GUID        `yson:"chunk_id"`
	RangeIndex int              `yson:"range_index"`
	RowIndex   int              `yson:"row_index"`
	RowCount   int              `yson:"row_count"`
	LowerLimit *ypath.ReadLimit `yson:"lower_limit"`
	UpperLimit *ypath.ReadLimit `yson:"upper_limit"`
	Replicas   []int            `yson:"replicas"`
}

type Client

type Client interface {
	CypressClient
	FileClient
	TableClient

	// BeginTx creates new tx.
	//
	// Tx lifetime is bound to ctx. Tx is automatically aborted when ctx is canceled.
	//
	// Active transaction consumes resources, client must finish transaction by calling Commit(), Abort()
	// or canceling ctx passed to BeginTx.
	BeginTx(ctx context.Context, options *StartTxOptions) (tx Tx, err error)

	// BeginTabletTx creates new tablet transaction.
	//
	// Tx lifetime is bound to ctx. Tx is automatically aborted when ctx is canceled.
	//
	// Active transaction consumes resources, client must finish transaction by calling Commit(), Abort()
	// or canceling ctx passed to BeginTabletTx.
	BeginTabletTx(ctx context.Context, options *StartTabletTxOptions) (tx TabletTx, err error)

	TabletClient
	MountClient

	// http:verb:"generate_timestamp"
	GenerateTimestamp(ctx context.Context, options *GenerateTimestampOptions) (ts Timestamp, err error)

	LowLevelTxClient
	LowLevelSchedulerClient

	AdminClient

	// http:verb:"locate_skynet_share"
	// http:params:"path"
	LocateSkynetShare(
		ctx context.Context,
		path ypath.YPath,
		options *LocateSkynetShareOptions,
	) (l ShareLocation, err error)

	// http:verb:"get_in_sync_replicas"
	// http:params:"path","timestamp"
	// http:extra
	GetInSyncReplicas(
		ctx context.Context,
		path ypath.Path,
		ts Timestamp,
		keys []interface{},
		options *GetInSyncReplicasOptions,
	) (ids []NodeID, err error)

	NewRowBatchWriter() RowBatchWriter

	// Stop() cancels and waits for completion of all background activity associated with this client.
	//
	// All transactions tracked by this client are aborted.
	Stop()
}

type ClientCompressionCodec

type ClientCompressionCodec int

ClientCompressionCodec. See yt.Config doc for more details.

const (
	// Default compression codec, selected by YT team. Particular choice may change in the future.
	ClientCodecDefault ClientCompressionCodec = iota

	// Use default GZIP codec, provided by net/http.
	ClientCodecGZIP

	// No compression at all. It almost never makes sense to disable compression in production.
	ClientCodecNone

	ClientCodecSnappy

	ClientCodecZSTDFastest
	ClientCodecZSTDDefault
	ClientCodecZSTDBetterCompression

	ClientCodecBrotliFastest
	ClientCodecBrotliDefault
)

func (ClientCompressionCodec) BlockCodec

func (c ClientCompressionCodec) BlockCodec() (string, bool)

type ClusterURL

type ClusterURL struct {
	Address          string
	DisableDiscovery bool
}

func NormalizeProxyURL

func NormalizeProxyURL(proxy string, tvmOnly bool, tvmOnlyPort int) ClusterURL

type CommitTxOptions

type CommitTxOptions struct {
	Sticky bool `http:"sticky"`

	*MutatingOptions
	*PrerequisiteOptions
	*TransactionOptions
}

type CompleteOperationOptions

type CompleteOperationOptions struct{}

type Config

type Config struct {
	// Proxy configures address of YT HTTP proxy.
	//
	// If Proxy is not set, value of YT_PROXY environment variable is used instead.
	//
	// Might be equal to cluster name. E.g. hahn or markov.
	//
	// Might be equal to hostname with optional port. E.g. localhost:12345 or sas5-1547-proxy-hahn.sas.yp-c.yandex.net.
	// In that case, provided host is used for all requests and proxy discovery is disabled.
	Proxy string

	// RPCProxy pins address of YT RPC proxy.
	//
	// If set, proxy discovery is disabled and provided value is used for all requests.
	//
	// If left empty, RPC proxies are discovered via HTTP using Proxy setting.
	//
	// Only relevant for RPC client.
	RPCProxy string

	// ProxyRole configures desired proxy role used by the client.
	//
	// If not set, default role is used.
	ProxyRole string

	// UseTLS enables TLS for all connections to cluster.
	//
	// This option is supported only in HTTP client.
	//
	// By default, client will not use TLS.
	//
	// TLS is not supported in local mode.
	UseTLS bool

	// Token configures OAuth token used by the client.
	//
	// If Token is not set, value of YT_TOKEN environment variable is used instead.
	Token string

	// ReadTokenFromFile
	//
	// When this variable is set, client tries reading token from ~/.yt/token file.
	ReadTokenFromFile bool

	// TVMFn is used to issue service tickets for YT API requests.
	//
	// TVM is a preferred way of service authentication.
	//
	// If TVMFn is not set, OAuth token is used.
	//
	// Assign yttvm.TVMFn(tvm.Client) to this field, if you wish to enable tvm authentication.
	TVMFn TVMFn

	// UseTVMOnlyEndpoint configures client to use tvm-only endpoints in cluster connection.
	UseTVMOnlyEndpoint bool

	// Logger overrides default logger, used by the client.
	//
	// When Logger is not set, logging behaviour is configured by YT_LOG_LEVEL environment variable.
	//
	// If YT_LOG_LEVEL is not set, no logging is performed. Otherwise logs are written to stderr,
	// with log level derived from value of YT_LOG_LEVEL variable.
	//
	// WARNING: Running YT client in production without debug logs is highly discouraged.
	Logger log.Structured

	// TracerProvider overrides default tracer provider, used by the client
	//
	// When Tracer is not set trace.GetTracerProvider is used.
	//
	// If default tracer provider is not set, no tracing is performed.
	TracerProvider trace.TracerProvider

	// TraceFn extracts trace parent from request context.
	//
	// This function is extracted into config in order to avoid direct dependency on jaeger client.
	//
	// Assign ytjaeger.TraceFn to this field, if you wish to enable tracing.
	TraceFn TraceFn

	// LightRequestTimeout specifies default timeout for light requests. Timeout includes all retries and backoffs.
	// Timeout for single request is not configurable right now.
	//
	// A Timeout of zero means no timeout. Client can still specify timeout on per-request basis using context.
	//
	// nil value means default timeout of 5 minutes.
	LightRequestTimeout *time.Duration

	// TxTimeout specifies timeout of YT transaction (both master and tablet).
	//
	// YT transaction is aborted by server after not receiving pings from client for TxTimeout seconds.
	//
	// TxTimeout of zero means default timeout of 15 seconds.
	TxTimeout time.Duration

	// TxPingPeriod specifies period of pings for YT transactions.
	//
	// TxPingPeriod of zero means default value of 3 seconds.
	TxPingPeriod time.Duration

	// AllowRequestsFromJob explicitly allows creating client inside YT job.
	//
	// WARNING: This option can be enabled ONLY after explicit approval from YT team. If you enable this option
	// without approval, your might be BANNED.
	//
	// If you need to read tables, or access cypress from YT job, use API provided by mapreduce package, or
	// redesign your application.
	//
	// Typical mapreduce operation can launch hundred of thousands concurrent jobs. If each job makes even a single request,
	// that could easily lead to master/proxy overload.
	AllowRequestsFromJob bool

	// CompressionCodec specifies codec used for compression of client requests and server responses.
	//
	// NOTE: this codec has nothing to do with codec used for storing table chunks.
	CompressionCodec ClientCompressionCodec
}

func (*Config) GetClientCompressionCodec

func (c *Config) GetClientCompressionCodec() ClientCompressionCodec

func (*Config) GetLightRequestTimeout

func (c *Config) GetLightRequestTimeout() time.Duration

func (*Config) GetLogger

func (c *Config) GetLogger() log.Structured

func (*Config) GetProxy

func (c *Config) GetProxy() (string, error)

func (*Config) GetToken

func (c *Config) GetToken() string

func (*Config) GetTracer

func (c *Config) GetTracer(name string) trace.Tracer

func (*Config) GetTxPingPeriod

func (c *Config) GetTxPingPeriod() time.Duration

func (*Config) GetTxTimeout

func (c *Config) GetTxTimeout() time.Duration

type CopyNodeOptions

type CopyNodeOptions struct {
	Recursive      bool `http:"recursive"`
	IgnoreExisting bool `http:"ignore_existing"`
	Force          bool `http:"force"`

	PreserveAccount           *bool `http:"preserve_account,omitnil"`
	PreserveExpirationTime    *bool `http:"preserve_expiration_time,omitnil"`
	PreserveExpirationTimeout *bool `http:"preserve_expiration_timeout,omitnil"`
	PreserveCreationTime      *bool `http:"preserve_creation_time,omitnil"`
	PessimisticQuotaCheck     *bool `http:"pessimistic_quota_check,omitnil"`

	*TransactionOptions
	// *AccessTrackingOptions
	*MutatingOptions
	*PrerequisiteOptions
}

type CreateNodeOptions

type CreateNodeOptions struct {
	Recursive      bool `http:"recursive"`
	IgnoreExisting bool `http:"ignore_existing"`
	Force          bool `http:"force"`

	Attributes map[string]interface{} `http:"attributes,omitnil"`

	*TransactionOptions
	*AccessTrackingOptions
	*MutatingOptions
	*PrerequisiteOptions
}

CreateNodeOptions.

See https://wiki.yandex-team.ru/yt/userdoc/api/#create

type CreateObjectOptions

type CreateObjectOptions struct {
	Recursive      bool `http:"recursive"`
	IgnoreExisting bool `http:"ignore_existing"`
	Force          bool `http:"force"`

	Attributes map[string]interface{} `http:"attributes,omitnil"`

	*PrerequisiteOptions
	*AccessTrackingOptions
	*MutatingOptions
}

type CreateTableOption

type CreateTableOption func(options *CreateNodeOptions)

func WithAttributes

func WithAttributes(attrs map[string]interface{}) CreateTableOption

func WithForce

func WithForce() CreateTableOption

func WithInferredSchema

func WithInferredSchema(row interface{}) CreateTableOption

func WithRecursive

func WithRecursive() CreateTableOption

func WithSchema

func WithSchema(schema schema.Schema) CreateTableOption

type Credentials

type Credentials interface {
	Set(r *http.Request)
	SetExtension(req *rpc.TRequestHeader)
}

func ContextCredentials

func ContextCredentials(ctx context.Context) Credentials

type CypressClient

type CypressClient interface {
	// http:verb:"create"
	// http:params:"path","type"
	CreateNode(
		ctx context.Context,
		path ypath.YPath,
		typ NodeType,
		options *CreateNodeOptions,
	) (id NodeID, err error)

	// http:verb:"create"
	// http:params:"type"
	CreateObject(
		ctx context.Context,
		typ NodeType,
		options *CreateObjectOptions,
	) (id NodeID, err error)

	// http:verb:"exists"
	// http:params:"path"
	NodeExists(
		ctx context.Context,
		path ypath.YPath,
		options *NodeExistsOptions,
	) (ok bool, err error)

	// http:verb:"remove"
	// http:params:"path"
	RemoveNode(
		ctx context.Context,
		path ypath.YPath,
		options *RemoveNodeOptions,
	) (err error)

	// http:verb:"get"
	// http:params:"path"
	// http:extra
	GetNode(
		ctx context.Context,
		path ypath.YPath,
		result interface{},
		options *GetNodeOptions,
	) (err error)

	// http:verb:"set"
	// http:params:"path"
	// http:extra
	SetNode(
		ctx context.Context,
		path ypath.YPath,
		value interface{},
		options *SetNodeOptions,
	) (err error)

	// http:verb:"multiset_attributes"
	// http:params:"path"
	// http:extra
	MultisetAttributes(
		ctx context.Context,
		path ypath.YPath,
		attributes map[string]interface{},
		options *MultisetAttributesOptions,
	) (err error)

	// http:verb:"list"
	// http:params:"path"
	// http:extra
	ListNode(
		ctx context.Context,
		path ypath.YPath,
		result interface{},
		options *ListNodeOptions,
	) (err error)

	// http:verb:"copy"
	// http:params:"source_path","destination_path"
	CopyNode(
		ctx context.Context,
		src ypath.YPath,
		dst ypath.YPath,
		options *CopyNodeOptions,
	) (id NodeID, err error)

	// http:verb:"move"
	// http:params:"source_path","destination_path"
	MoveNode(
		ctx context.Context,
		src ypath.YPath,
		dst ypath.YPath,
		options *MoveNodeOptions,
	) (id NodeID, err error)

	// http:verb:"link"
	// http:params:"target_path","link_path"
	LinkNode(
		ctx context.Context,
		target ypath.YPath,
		link ypath.YPath,
		options *LinkNodeOptions,
	) (id NodeID, err error)
}

type DeleteRowsOptions

type DeleteRowsOptions struct {
	RequireSyncReplica *bool `http:"require_sync_replica,omitnil"`

	*TransactionOptions
}

type DestroyChunkLocationsResponse

type DestroyChunkLocationsResponse struct {
	LocationUuids []guid.GUID
}

type DisableChunkLocationsResponse

type DisableChunkLocationsResponse struct {
	LocationUuids []guid.GUID
}

type ExecTabletTxOptions

type ExecTabletTxOptions struct {
	RetryOptions ExecTxRetryOptions
	*StartTabletTxOptions
}

type ExecTxOptions

type ExecTxOptions struct {
	RetryOptions ExecTxRetryOptions
	*StartTxOptions
}

type ExecTxRetryOptions

type ExecTxRetryOptions backoff.BackOff

type ExecTxRetryOptionsNone

type ExecTxRetryOptionsNone = backoff.StopBackOff

ExecTxRetryOptionsNone is a fixed retry policy that never retries the operation.

type FileClient

type FileClient interface {
	// http:verb:"write_file"
	// http:params:"path"
	WriteFile(
		ctx context.Context,
		path ypath.YPath,
		options *WriteFileOptions,
	) (w io.WriteCloser, err error)

	// http:verb:"read_file"
	// http:params:"path"
	ReadFile(
		ctx context.Context,
		path ypath.YPath,
		options *ReadFileOptions,
	) (r io.ReadCloser, err error)

	// http:verb:"put_file_to_cache"
	// http:params:"path","md5"
	PutFileToCache(
		ctx context.Context,
		path ypath.YPath,
		md5 string,
		options *PutFileToCacheOptions,
	) (cachedPath ypath.YPath, err error)

	// http:verb:"get_file_from_cache"
	// http:params:"md5"
	GetFileFromCache(
		ctx context.Context,
		md5 string,
		options *GetFileFromCacheOptions,
	) (path ypath.YPath, err error)
}

type FreezeTableOptions

type FreezeTableOptions struct {
	*TabletRangeOptions
	*MutatingOptions
}

type GenerateTimestampOptions

type GenerateTimestampOptions struct{}

type GetFileFromCacheOptions

type GetFileFromCacheOptions struct {
	CachePath ypath.YPath `http:"cache_path"`

	*MasterReadOptions
	*ReadRetryOptions
}

type GetInSyncReplicasOptions

type GetInSyncReplicasOptions struct{}

type GetJobStderrOptions

type GetJobStderrOptions struct{}

type GetNodeOptions

type GetNodeOptions struct {
	Attributes []string `http:"attributes,omitnil"`
	MaxSize    *int64   `http:"max_size,omitnil"`

	*TransactionOptions
	*AccessTrackingOptions
	*PrerequisiteOptions
	*MasterReadOptions

	*ReadRetryOptions
}

type GetOperationOptions

type GetOperationOptions struct {
	Attributes     []string `http:"attributes,omitnil"`
	IncludeRuntime *bool    `http:"include_runtime,omitnil"`

	*MasterReadOptions

	*ReadRetryOptions
}

type InsertRowsOptions

type InsertRowsOptions struct {
	Atomicity          *Atomicity `http:"atomicity,omitnil"`
	RequireSyncReplica *bool      `http:"require_sync_replica,omitnil"`
	Update             *bool      `http:"update,omitnil"`

	*TransactionOptions
}

type JobDataSource

type JobDataSource string
var (
	JobDataSourceArchive JobDataSource = "archive"
	JobDataSourceRuntime JobDataSource = "runtime"
	JobDataSourceAuto    JobDataSource = "auto"
	JobDataSourceManual  JobDataSource = "manual"
)

type JobExecAttributes

type JobExecAttributes struct {
	MediumName  string   `yson:"medium_name"`
	IPAddresses []string `yson:"ip_addresses"`
	SandboxPath string   `yson:"sandbox_path"`
	SlotIndex   int      `yson:"slot_index"`
}

type JobID

type JobID guid.GUID

func (JobID) MarshalYSON

func (id JobID) MarshalYSON(w *yson.Writer) error

func (JobID) String

func (id JobID) String() string

func (*JobID) UnmarshalYSON

func (id *JobID) UnmarshalYSON(data []byte) (err error)

type JobSortField

type JobSortField string
var (
	SortFieldNone       JobSortField = "none"
	SortFieldType       JobSortField = "type"
	SortFieldState      JobSortField = "state"
	SortFieldStartTime  JobSortField = "start_time"
	SortFieldFinishTime JobSortField = "finish_time"
	SortFieldAddress    JobSortField = "address"
	SortFieldDuration   JobSortField = "duration"
	SortFieldProgress   JobSortField = "progress"
	SortFieldID         JobSortField = "id"
)

type JobSortOrder

type JobSortOrder string
var (
	Ascending  JobSortOrder = "ascending"
	Descending JobSortOrder = "descending"
)

type JobState

type JobState string
var (
	JobRunning   JobState = "running"
	JobWaiting   JobState = "waiting"
	JobCompleted JobState = "completed"
	JobFailed    JobState = "failed"
	JobAborted   JobState = "aborted"
)

type JobStatus

type JobStatus struct {
	ID              JobID              `yson:"id"`
	Type            string             `yson:"type"`
	State           string             `yson:"state"`
	Address         string             `yson:"address"`
	StartTime       yson.Time          `yson:"start_time"`
	FinishTime      yson.Time          `yson:"finish_time,omitempty"`
	FailContextSize int                `yson:"fail_context_size,omitempty"`
	Error           yterrors.Error     `yson:"error,omitempty"`
	Progress        float64            `yson:"progress,omitempty"`
	ExecAttributes  *JobExecAttributes `yson:"exec_attributes,omitempty"`
}

func ListAllJobs

func ListAllJobs(ctx context.Context, yc Client, opID OperationID, opts *ListJobsOptions) ([]JobStatus, error)

ListAllJobs lists operation jobs with pagination.

Depending on the filters used the result might be quite big. Consider using RangeOperations to limit memory consumption.

type JobType

type JobType string
var (
	JobTypeMap              JobType = "map"
	JobTypePartitionMap     JobType = "partition_map"
	JobTypeSortedMerge      JobType = "sorted_merge"
	JobTypeOrderedMerge     JobType = "ordered_merge"
	JobTypeUnorderedMerge   JobType = "unordered_merge"
	JobTypePartition        JobType = "partition"
	JobTypeSimpleSort       JobType = "simple_sort"
	JobTypeFinalSort        JobType = "final_sort"
	JobTypeSortedReduce     JobType = "sorted_reduce"
	JobTypePartitionReduce  JobType = "partition_reduce"
	JobTypeReduceCombiner   JobType = "reduce_combiner"
	JobTypeRemoteCopy       JobType = "remote_copy"
	JobTypeIntermediateSort JobType = "intermediate_sort"
	JobTypeOrderedMap       JobType = "ordered_map"
	JobTypeJoinReduce       JobType = "join_reduce"
	JobTypeVanilla          JobType = "vanilla"
	JobTypeSchedulerUnknown JobType = "scheduler_unknown"
)

type LinkNodeOptions

type LinkNodeOptions struct {
	Recursive      bool `http:"recursive"`
	IgnoreExisting bool `http:"ignore_existing"`
	Force          bool `http:"force"`

	Attributes map[string]interface{} `http:"attributes,omitnil"`

	*TransactionOptions
	// *AccessTrackingOptions
	*MutatingOptions
	*PrerequisiteOptions
}

type ListJobsOptions

type ListJobsOptions struct {
	JobType         *JobType       `http:"job_type,omitnil"`
	JobState        *JobState      `http:"job_state,omitnil"`
	Address         *string        `http:"address,omitnil"`
	WithStderr      *bool          `http:"with_stderr,omitnil"`
	WithFailContext *bool          `http:"with_fail_context,omitnil"`
	SortField       *JobSortField  `http:"sort_field,omitnil"`
	SortOrder       *JobSortOrder  `http:"sort_order,omitnil"`
	Limit           *int           `http:"limit,omitnil"`
	Offset          *int           `http:"offset,omitnil"`
	DataSource      *JobDataSource `http:"data_source,omitnil"`
}

type ListJobsResult

type ListJobsResult struct {
	Jobs []JobStatus `yson:"jobs"`
}

type ListNodeOptions

type ListNodeOptions struct {
	Attributes []string `http:"attributes,omitnil"`
	MaxSize    *int64   `http:"max_size,omitnil"`

	*TransactionOptions
	*MasterReadOptions
	*AccessTrackingOptions
	*PrerequisiteOptions

	*ReadRetryOptions
}

type ListOperationsOptions

type ListOperationsOptions struct {
	*MasterReadOptions

	*ReadRetryOptions

	FromTime *yson.Time      `http:"from_time,omitnil"`
	ToTime   *yson.Time      `http:"to_time,omitnil"`
	Cursor   *yson.Time      `http:"cursor_time,omitnil"`
	User     *string         `http:"user,omitnil"`
	State    *OperationState `http:"state,omitnil"`
	Type     *OperationType  `http:"type,omitnil"`
	Filter   *string         `http:"filter,omitnil"`
	Limit    *int            `http:"limit,omitnil"`
}

type ListOperationsResult

type ListOperationsResult struct {
	Operations      []OperationStatus `yson:"operations"`
	Incomplete      bool              `yson:"incomplete"`
	PoolCounts      map[string]int    `yson:"pool_counts"`
	UserCounts      map[string]int    `yson:"user_counts"`
	StateCounts     map[string]int    `yson:"state_counts"`
	TypeCounts      map[string]int    `yson:"type_counts"`
	FailedJobsCount int               `yson:"failed_jobs_count"`
}

type LocateSkynetShareOptions

type LocateSkynetShareOptions struct{}

type LockClient

type LockClient interface {
	// http:verb:"lock"
	// http:params:"path","mode"
	LockNode(
		ctx context.Context,
		path ypath.YPath,
		mode LockMode,
		options *LockNodeOptions,
	) (res LockResult, err error)

	// http:verb:"unlock"
	// http:params:"path"
	UnlockNode(
		ctx context.Context,
		path ypath.YPath,
		options *UnlockNodeOptions,
	) (err error)
}

type LockMode

type LockMode string
const (
	LockSnapshot  LockMode = "snapshot"
	LockShared    LockMode = "shared"
	LockExclusive LockMode = "exclusive"
)

type LockNodeOptions

type LockNodeOptions struct {
	Waitable     bool    `http:"waitable"`
	ChildKey     *string `http:"child_key,omitnil"`
	AttributeKey *string `http:"attribute_key,omitnil"`

	*TransactionOptions
	*MutatingOptions
}

type LockResult

type LockResult struct {
	NodeID NodeID    `yson:"node_id"`
	LockID guid.GUID `yson:"lock_id"`
}

type LockRowsOptions

type LockRowsOptions struct {
	*TransactionOptions
}

type LockState

type LockState string

LockState type holds available lock states.

const (
	// LockPending is a state of a queued waitable lock.
	LockPending LockState = "pending"
	// LockAcquired is a state of an acquired lock.
	LockAcquired LockState = "acquired"
)

type LockType

type LockType string
const (
	LockTypeNone         LockType = "none"
	LockTypeSharedWeak   LockType = "shared_weak"
	LockTypeSharedStrong LockType = "shared_strong"
	LockTypeExclusive    LockType = "exclusive"
)

type LookupRowsOptions

type LookupRowsOptions struct {
	// KeepMissingRows changes handling of missing rows.
	//
	// When this flag is not set, missing rows are skipped.
	// When flag is set, nil values are returned for missing rows.
	KeepMissingRows bool `http:"keep_missing_rows"`

	// Timestamp overrides timestamp for lookup.
	//
	// By default, lookup returns data from the point in time when
	// transaction was started.
	Timestamp *Timestamp `http:"timestamp,omitnil"`

	// Columns filters columns in lookup result.
	Columns []string `http:"column_names,omitnil"`

	*TransactionOptions
}

type LowLevelSchedulerClient

type LowLevelSchedulerClient interface {
	OperationStartClient

	// http:verb:"abort_operation"
	// http:params:"operation_id"
	AbortOperation(
		ctx context.Context,
		opID OperationID,
		options *AbortOperationOptions,
	) (err error)

	// http:verb:"suspend_operation"
	// http:params:"operation_id"
	SuspendOperation(
		ctx context.Context,
		opID OperationID,
		options *SuspendOperationOptions,
	) (err error)

	// http:verb:"resume_operation"
	// http:params:"operation_id"
	ResumeOperation(
		ctx context.Context,
		opID OperationID,
		options *ResumeOperationOptions,
	) (err error)

	// http:verb:"complete_operation"
	// http:params:"operation_id"
	CompleteOperation(
		ctx context.Context,
		opID OperationID,
		options *CompleteOperationOptions,
	) (err error)

	// http:verb:"update_operation_parameters"
	// http:params:"operation_id","parameters"
	UpdateOperationParameters(
		ctx context.Context,
		opID OperationID,
		params interface{},
		options *UpdateOperationParametersOptions,
	) (err error)

	// http:verb:"get_operation"
	// http:params:"operation_id"
	GetOperation(
		ctx context.Context,
		opID OperationID,
		options *GetOperationOptions,
	) (status *OperationStatus, err error)

	// http:verb:"list_operations"
	ListOperations(
		ctx context.Context,
		options *ListOperationsOptions,
	) (operations *ListOperationsResult, err error)

	// http:verb:"list_jobs"
	// http:params:"operation_id"
	ListJobs(
		ctx context.Context,
		opID OperationID,
		options *ListJobsOptions,
	) (r *ListJobsResult, err error)

	// http:verb:"get_job_stderr"
	// http:params:"operation_id","job_id"
	GetJobStderr(
		ctx context.Context,
		opID OperationID,
		jobID JobID,
		options *GetJobStderrOptions,
	) (r []byte, err error)
}

LowLevelSchedulerClient is stateless interface to the YT scheduler.

Clients should use package mapreduce instead.

type LowLevelTxClient

type LowLevelTxClient interface {
	// http:verb:"start_transaction"
	StartTx(
		ctx context.Context,
		options *StartTxOptions,
	) (id TxID, err error)

	// http:verb:"start_transaction"
	StartTabletTx(
		ctx context.Context,
		options *StartTabletTxOptions,
	) (id TxID, err error)

	// http:verb:"ping_transaction"
	// http:params:"transaction_id"
	PingTx(
		ctx context.Context,
		id TxID,
		options *PingTxOptions,
	) (err error)

	// http:verb:"abort_transaction"
	// http:params:"transaction_id"
	AbortTx(
		ctx context.Context,
		id TxID,
		options *AbortTxOptions,
	) (err error)

	// http:verb:"commit_transaction"
	// http:params:"transaction_id"
	CommitTx(
		ctx context.Context,
		id TxID,
		options *CommitTxOptions,
	) (err error)
}

LowLevelTxClient provides stateless interface to YT transactions.

Clients should rarely use it directly.

type MasterReadOptions

type MasterReadOptions struct {
	ReadFrom ReadKind `http:"read_from"`
}

MasterReadOptions specify where cypress read requests are routed.

By default read requests are served from followers.

type MountClient

type MountClient interface {
	// http:verb:"mount_table"
	// http:params:"path"
	MountTable(
		ctx context.Context,
		path ypath.Path,
		options *MountTableOptions,
	) (err error)

	// http:verb:"unmount_table"
	// http:params:"path"
	UnmountTable(
		ctx context.Context,
		path ypath.Path,
		options *UnmountTableOptions,
	) (err error)

	// http:verb:"remount_table"
	// http:params:"path"
	RemountTable(
		ctx context.Context,
		path ypath.Path,
		options *RemountTableOptions,
	) (err error)

	// http:verb:"reshard_table"
	// http:params:"path"
	ReshardTable(
		ctx context.Context,
		path ypath.Path,
		options *ReshardTableOptions,
	) (err error)

	// http:verb:"alter_table"
	// http:params:"path"
	AlterTable(
		ctx context.Context,
		path ypath.Path,
		options *AlterTableOptions,
	) (err error)

	// http:verb:"freeze_table"
	// http:params:"path"
	FreezeTable(
		ctx context.Context,
		path ypath.Path,
		options *FreezeTableOptions,
	) (err error)

	// http:verb:"unfreeze_table"
	// http:params:"path"
	UnfreezeTable(
		ctx context.Context,
		path ypath.Path,
		options *UnfreezeTableOptions,
	) (err error)

	// http:verb:"alter_table_replica"
	// http:params:"replica_id"
	AlterTableReplica(
		ctx context.Context,
		id NodeID,
		options *AlterTableReplicaOptions,
	) (err error)
}

type MountTableOptions

type MountTableOptions struct {
	*TabletRangeOptions
	*MutatingOptions

	CellID        *guid.GUID  `http:"cell_id,omitnil"`
	TargetCellIDs []guid.GUID `http:"target_cell_ids,omitnil"`
	Freeze        bool        `http:"freeze"`
}

type MoveNodeOptions

type MoveNodeOptions struct {
	Recursive bool `http:"recursive"`
	Force     bool `http:"force"`

	PreserveAccount           *bool `http:"preserve_account,omitnil"`
	PreserveExpirationTime    *bool `http:"preserve_expiration_time,omitnil"`
	PreserveExpirationTimeout *bool `http:"preserve_expiration_timeout,omitnil"`
	PessimisticQuotaCheck     *bool `http:"pessimistic_quota_check,omitnil"`

	*TransactionOptions
	// *AccessTrackingOptions
	*MutatingOptions
	*PrerequisiteOptions
}

type MutatingOptions

type MutatingOptions struct {
	MutationID MutationID `http:"mutation_id"`
	Retry      bool       `http:"retry"`
}

MutatingOptions enable safe retries of cypress commands in the presence of network errors.

MutatingOptions are managed internally by the library.

type MutationID

type MutationID guid.GUID

func (MutationID) MarshalYSON

func (id MutationID) MarshalYSON(w *yson.Writer) error

func (MutationID) String

func (id MutationID) String() string

func (*MutationID) UnmarshalYSON

func (id *MutationID) UnmarshalYSON(data []byte) (err error)

type NodeAddress

type NodeAddress struct {
	NodeID    uint              `yson:"node_id"`
	Addresses map[string]string `yson:"addresses"`
}

type NodeID

type NodeID guid.GUID

func CreateTable

func CreateTable(ctx context.Context, yc CypressClient, path ypath.Path, opts ...CreateTableOption) (id NodeID, err error)

func (NodeID) MarshalText

func (id NodeID) MarshalText() ([]byte, error)

func (NodeID) MarshalYSON

func (id NodeID) MarshalYSON(w *yson.Writer) error

func (NodeID) String

func (id NodeID) String() string

func (*NodeID) UnmarshalText

func (id *NodeID) UnmarshalText(data []byte) (err error)

func (*NodeID) UnmarshalYSON

func (id *NodeID) UnmarshalYSON(data []byte) (err error)

func (NodeID) YPath

func (id NodeID) YPath() ypath.Path

type NodeType

type NodeType string
const (
	// NodeMap is cypress analog for directory.
	NodeMap NodeType = "map_node"
	// NodeLink is symbolic link.
	NodeLink NodeType = "link"
	// NodeFile is regular file. Used for artifacts and opaque blobs.
	NodeFile NodeType = "file"
	// NodeTable is table.
	NodeTable NodeType = "table"

	NodeString  NodeType = "string_node"
	NodeBoolean NodeType = "boolean_node"

	NodeDocument          NodeType = "document"
	NodeTableReplica      NodeType = "table_replica"
	NodeReplicatedTable   NodeType = "replicated_table"
	NodeUser              NodeType = "user"
	NodeGroup             NodeType = "group"
	NodeAccount           NodeType = "account"
	NodeMedium            NodeType = "medium"
	NodeTabletCellBundle  NodeType = "tablet_cell_bundle"
	NodeTabletCell        NodeType = "tablet_cell"
	NodeSys               NodeType = "sys_node"
	NodePortalEntrance    NodeType = "portal_entrance"
	NodePortalExit        NodeType = "portal_exit"
	NodeSchedulerPool     NodeType = "scheduler_pool"
	NodeSchedulerPoolTree NodeType = "scheduler_pool_tree"

	NodeAccessControlObject          NodeType = "access_control_object"
	NodeAccessControlObjectNamespace NodeType = "access_control_object_namespace"
)

func (NodeType) String

func (n NodeType) String() string

type OperationID

type OperationID guid.GUID

func (OperationID) MarshalYSON

func (id OperationID) MarshalYSON(w *yson.Writer) error

func (OperationID) String

func (id OperationID) String() string

func (*OperationID) UnmarshalYSON

func (id *OperationID) UnmarshalYSON(data []byte) (err error)

type OperationResult

type OperationResult struct {
	Error *yterrors.Error `yson:"error"`
}

type OperationRuntimeParameters

type OperationRuntimeParameters struct {
	ACL                          []ACE                  `yson:"acl"`
	SchedulingOptionsPerPoolTree map[string]interface{} `yson:"scheduling_options_per_pool_tree"`
	Annotations                  map[string]interface{} `yson:"annotations"`
	ErasedTrees                  []string               `yson:"erased_trees"`
}

type OperationStartClient

type OperationStartClient interface {
	// http:verb:"start_operation"
	// http:params:"operation_type","spec"
	StartOperation(
		ctx context.Context,
		opType OperationType,
		spec interface{},
		options *StartOperationOptions,
	) (opID OperationID, err error)
}

type OperationState

type OperationState string
var (
	StateRunning       OperationState = "running"
	StatePending       OperationState = "pending"
	StateCompleted     OperationState = "completed"
	StateFailed        OperationState = "failed"
	StateAborted       OperationState = "aborted"
	StateReviving      OperationState = "reviving"
	StateInitializing  OperationState = "initializing"
	StatePreparing     OperationState = "preparing"
	StateMaterializing OperationState = "materializing"
	StateCompleting    OperationState = "completing"
	StateAborting      OperationState = "aborting"
	StateFailing       OperationState = "failing"
)

func (OperationState) IsFinished

func (o OperationState) IsFinished() bool

type OperationStatus

type OperationStatus struct {
	ID                OperationID                `yson:"id"`
	State             OperationState             `yson:"state"`
	Result            *OperationResult           `yson:"result"`
	Type              OperationType              `yson:"type"`
	BriefSpec         map[string]interface{}     `yson:"brief_spec"`
	FullSpec          yson.RawValue              `yson:"full_spec"`
	StartTime         yson.Time                  `yson:"start_time"`
	Suspend           bool                       `yson:"suspend"`
	AuthenticatedUser string                     `yson:"authenticated_user"`
	RuntimeParameters OperationRuntimeParameters `yson:"runtime_parameters"`
}

func ListAllOperations

func ListAllOperations(ctx context.Context, yc Client, opts *ListOperationsOptions) ([]OperationStatus, error)

ListAllOperations lists operations with pagination.

Depending on the filters used the result might be quite big. Consider using RangeOperations to limit memory consumption.

type OperationType

type OperationType string
var (
	OperationMap        OperationType = "map"
	OperationReduce     OperationType = "reduce"
	OperationMapReduce  OperationType = "map_reduce"
	OperationSort       OperationType = "sort"
	OperationMerge      OperationType = "merge"
	OperationErase      OperationType = "erase"
	OperationRemoteCopy OperationType = "remote_copy"
	OperationVanilla    OperationType = "vanilla"
)

type Permission

type Permission = string

TODO(dakovalkov): create a different type for Permission

const (
	PermissionRead           Permission = "read"
	PermissionWrite          Permission = "write"
	PermissionUse            Permission = "use"
	PermissionAdminister     Permission = "administer"
	PermissionCreate         Permission = "create"
	PermissionRemove         Permission = "remove"
	PermissionMount          Permission = "mount"
	PermissionManage         Permission = "manage"
	PermissionModifyChildren Permission = "modify_children"
)

type PingTxOptions

type PingTxOptions struct {
	*TransactionOptions
}

type PrerequisiteOptions

type PrerequisiteOptions struct {
	TransactionIDs []TxID                 `http:"prerequisite_transaction_ids,omitnil"`
	Revisions      []PrerequisiteRevision `http:"prerequisite_revisions,omitnil"`
}

type PrerequisiteRevision

type PrerequisiteRevision struct {
	Path          ypath.Path `yson:"path"`
	TransactionID TxID       `yson:"transaction_id"`
	Revision      Revision   `yson:"revision"`
}

type PutFileToCacheOptions

type PutFileToCacheOptions struct {
	CachePath ypath.YPath `http:"cache_path"`

	*MasterReadOptions
	*MutatingOptions
	*PrerequisiteOptions
}

type RangeJobsCallback

type RangeJobsCallback func(job JobStatus)

type RangeOperationsCallback

type RangeOperationsCallback func(op OperationStatus)

type ReadFileOptions

type ReadFileOptions struct {
	Offset     *int64      `http:"offset,omitnil"`
	Length     *int64      `http:"length,omitnil"`
	FileReader interface{} `http:"file_reader"`

	*TransactionOptions
	*AccessTrackingOptions
}

type ReadKind

type ReadKind string
const (
	ReadFromLeader      ReadKind = "leader"
	ReadFromFollower    ReadKind = "follower"
	ReadFromCache       ReadKind = "cache"
	ReadFromMasterCache ReadKind = "master_cache"
)

type ReadRetryOptions

type ReadRetryOptions struct{}

ReadRetryOptions is marker for distinguishing requests that might be safely retried.

TODO(prime@): rename to SafeRetryOptions

type ReadTableOptions

type ReadTableOptions struct {
	Unordered   bool        `http:"unordered"`
	TableReader interface{} `http:"table_reader"`

	ControlAttributes interface{} `http:"control_attributes,omitnil"`
	StartRowIndexOnly *bool       `http:"start_row_index_only,omitnil"`

	// Smart flag enables client side retries.
	//
	// When used outside of transaction, ReadTable automatically creates new transaction and
	// acquired table snapshot lock.
	//
	// When used inside of transaction, ReadTable does not create any additional transactions.
	//
	// Internal retries continue indefinitely. User must set appropriate timeout on request context.
	//
	// This is experimental option, that is currently off by default.
	Smart *bool

	*TransactionOptions
	*AccessTrackingOptions
}

type RemountTableOptions

type RemountTableOptions struct {
	*TabletRangeOptions
	*MutatingOptions
}

type RemoveMemberOptions

type RemoveMemberOptions struct {
	*MutatingOptions
	*PrerequisiteOptions
}

type RemoveNodeOptions

type RemoveNodeOptions struct {
	Recursive bool `http:"recursive"`
	Force     bool `http:"force"`

	*TransactionOptions
	*AccessTrackingOptions
	*PrerequisiteOptions
	*MutatingOptions
}

type ReshardTableOptions

type ReshardTableOptions struct {
	*TabletRangeOptions
	*MutatingOptions

	PivotKeys   interface{} `http:"pivot_keys,omitnil"`
	TabletCount *int        `http:"tablet_count,omitnil"`
}

type ResumeOperationOptions

type ResumeOperationOptions struct{}

type ResurrectChunkLocationsResponse

type ResurrectChunkLocationsResponse struct {
	LocationUuids []guid.GUID
}

type Revision

type Revision uint64

type RowBatch

type RowBatch interface {
	// Len returns estimated memory consumption by this object.
	Len() int
}

RowBatch is serialized blob containing batch of rows.

type RowBatchWriter

type RowBatchWriter interface {
	TableWriter

	Batch() RowBatch
}

type SecurityAction

type SecurityAction string
const (
	ActionAllow SecurityAction = "allow"
	ActionDeny  SecurityAction = "deny"
)

type SelectRowsOptions

type SelectRowsOptions struct {
	FailOnIncompleteResult *bool `http:"fail_on_incomplete_result,omitnil"`
	InputRowLimit          *int  `http:"input_row_limit,omitnil"`
	OutputRowLimit         *int  `http:"output_row_limit,omitnil"`

	Timestamp *Timestamp `http:"timestamp,omitnil"`

	PlaceholderValues interface{} `http:"placeholder_values,omitnil"`

	*TransactionOptions
	*TimeoutOptions
}

type ServiceTicketCredentials

type ServiceTicketCredentials struct {
	Ticket string
}

ServiceTicketCredentials implements TVM service-tickets authentication.

func (*ServiceTicketCredentials) Set

func (*ServiceTicketCredentials) SetExtension

func (c *ServiceTicketCredentials) SetExtension(req *rpc.TRequestHeader)

type SetNodeOptions

type SetNodeOptions struct {
	Recursive bool `http:"recursive"`
	Force     bool `http:"force"`

	*TransactionOptions
	*AccessTrackingOptions
	*MutatingOptions
	*PrerequisiteOptions
}

type ShareLocation

type ShareLocation struct {
	Nodes      []NodeAddress `yson:"nodes"`
	ChunkSpecs []ChunkSpec   `yson:"chunk_specs"`
}

type StartOperationOptions

type StartOperationOptions struct {
	*TransactionOptions
	*MutatingOptions
}

type StartTabletTxOptions

type StartTabletTxOptions struct {
	Atomicity *Atomicity     `http:"atomicity,omitnil"`
	Timeout   *yson.Duration `http:"timeout,omitnil"`

	Type   TxType `http:"type"`
	Sticky bool   `http:"sticky"`
}

type StartTxOptions

type StartTxOptions struct {
	Timeout  *yson.Duration `http:"timeout,omitnil"`
	Deadline *yson.Time     `http:"deadline,omitnil"`

	Type   *TxType `http:"type,omitnil"`
	Sticky bool    `http:"sticky"`

	PrerequisiteTransactionIDs []TxID                 `http:"prerequisite_transaction_ids,omitnil"`
	Attributes                 map[string]interface{} `http:"attributes,omitnil"`

	*TransactionOptions
	*ReadRetryOptions
}

type SuspendOperationOptions

type SuspendOperationOptions struct {
	AbortRunningJobs bool `http:"abort_running_jobs"`
}

type TVMFn

type TVMFn func(ctx context.Context) (string, error)

type TableClient

type TableClient interface {
	// WriteTable opens low-level table writer. Use yt.WriteTable() function instead of calling this method directly.
	//
	// http:verb:"write_table"
	// http:params:"path"
	WriteTable(
		ctx context.Context,
		path ypath.YPath,
		options *WriteTableOptions,
	) (w TableWriter, err error)

	// http:verb:"read_table"
	// http:params:"path"
	ReadTable(
		ctx context.Context,
		path ypath.YPath,
		options *ReadTableOptions,
	) (r TableReader, err error)
}

type TableReader

type TableReader interface {
	// Scan unmarshals current row into value.
	//
	// It is safe to call Scan multiple times for a single row.
	Scan(value interface{}) error

	// Next prepares the next result row for reading with the Scan method.
	//
	// It returns true on success, or false if there is no next result row or an error
	// happened while preparing it. Err should be consulted to distinguish between the two cases.
	Next() bool

	// Err returns error that occurred during read.
	Err() error

	// Close frees any associated resources.
	//
	// User MUST call Close(). Failure to do so will result in resource leak.
	//
	// Error returned from Close() may be safely ignored.
	Close() error
}

TableReader is interface for reading stream of rows.

Example
var r TableReader

_ = func() error {
	// Always close reader to release associated resources.
	defer r.Close()

	var testRow struct {
		Key, Value int
	}

	for r.Next() {
		if err := r.Scan(&testRow); err != nil {
			return err
		}

		// Process row
	}

	// Always check reader Err().
	if r.Err() != nil {
		return r.Err()
	}

	return nil
}()
Output:

type TableReplicaMode

type TableReplicaMode string
var (
	SyncMode  TableReplicaMode = "sync"
	AsyncMode TableReplicaMode = "async"
)

type TableWriter

type TableWriter interface {
	// Write writes single row.
	//
	// Error returned from write indicates that the whole write operation has failed.
	Write(value interface{}) error

	// Commit closes table writer.
	Commit() error

	// Rollback aborts table upload and frees associated resources.
	//
	// It is safe to call Rollback() concurrently with Write or Commit.
	//
	// Rollback blocks until upload transaction is aborted.
	//
	// If you need to cancel table writer without blocking, use context cancelFunc.
	//
	// Error returned from Rollback() may be safely ignored.
	Rollback() error
}

TableWriter is interface for writing stream of rows.

func WriteTable

func WriteTable(ctx context.Context, yc Client, path ypath.Path, opts ...WriteTableOption) (TableWriter, error)

WriteTable creates high level table writer.

By default, WriteTable overrides existing table, automatically creating table with schema inferred from the first row.

type TabletClient

type TabletClient interface {
	// SelectRows executes query.
	//
	// Use strconv.Quote or %q format to escape string literals inside query.
	//
	// http:verb:"select_rows"
	// http:params:"query"
	SelectRows(
		ctx context.Context,
		query string,
		options *SelectRowsOptions,
	) (r TableReader, err error)

	// LookupRows performs lookup by key.
	//
	// Rows are returned in the order of provided keys.
	//
	// By default, returns one row for each key that is present in the table.
	//
	// When KeepMissingRows option is set, returns exactly len(keys) number of rows. If key is missing
	// from the table, corresponding row will be nil.
	//
	// http:verb:"lookup_rows"
	// http:params:"path"
	// http:extra
	LookupRows(
		ctx context.Context,
		path ypath.Path,
		keys []interface{},
		options *LookupRowsOptions,
	) (r TableReader, err error)

	// LockRows acquires lock for given keys, without changing row values.
	//
	// http:verb:"lock_rows"
	// http:params:"path","locks","lock_type"
	// http:extra
	LockRows(
		ctx context.Context,
		path ypath.Path,
		locks []string,
		lockType LockType,
		keys []interface{},
		options *LockRowsOptions,
	) (err error)

	// http:verb:"insert_rows"
	// http:params:"path"
	// http:extra
	InsertRows(
		ctx context.Context,
		path ypath.Path,
		rows []interface{},
		options *InsertRowsOptions,
	) (err error)

	// InsertRowBatch is API optimized for performance.
	//
	// It works just like InsertRows, but allows serializing rows ahead of time.
	InsertRowBatch(
		ctx context.Context,
		path ypath.Path,
		rowBatch RowBatch,
		options *InsertRowsOptions,
	) (err error)

	// http:verb:"delete_rows"
	// http:params:"path"
	// http:extra
	DeleteRows(
		ctx context.Context,
		path ypath.Path,
		keys []interface{},
		options *DeleteRowsOptions,
	) (err error)
}

type TabletRangeOptions

type TabletRangeOptions struct {
	FirstTabletIndex int `http:"first_tablet_index"`
	LastTabletIndex  int `http:"last_tablet_index"`
}

type TabletTx

type TabletTx interface {
	TabletClient

	ID() TxID
	Commit() error
	Abort() error
}

type TabletTxFunc

type TabletTxFunc func(ctx context.Context, tx TabletTx) error

TabletTxFunc is a callback used in ExecTabletTx function.

type TimeoutOptions

type TimeoutOptions struct {
	Timeout yson.Duration `http:"timeout"`
}

TimeoutOptions specify request timeout that is propagated through internal YT RPC framework.

type Timestamp

type Timestamp uint64

Timestamp is a cluster-wide unique monotonically increasing number used to implement the MVCC.

type TokenCredentials

type TokenCredentials struct {
	Token string
}

func (*TokenCredentials) Set

func (c *TokenCredentials) Set(r *http.Request)

func (*TokenCredentials) SetExtension

func (c *TokenCredentials) SetExtension(req *rpc.TRequestHeader)

type TraceFn

type TraceFn func(ctx context.Context) (traceID guid.GUID, spanID uint64, flags byte, ok bool)

type TransactionOptions

type TransactionOptions struct {
	TransactionID                      TxID `http:"transaction_id"`
	Ping                               bool `http:"ping"`
	PingAncestors                      bool `http:"ping_ancestor_transactions"`
	SuppressTransactionCoordinatorSync bool `http:"suppress_transaction_coordinator_sync"`
	SuppressUpstreamSync               bool `http:"suppress_upstream_sync"`
}

TransactionOptions control transactional context of cypress command.

Do not use this options directly. Use Transaction instead.

type TransferAccountResourcesOptions

type TransferAccountResourcesOptions struct {
	*MutatingOptions
}

type TransferPoolResourcesOptions

type TransferPoolResourcesOptions struct {
	*MutatingOptions
}

type Tx

type Tx interface {
	CypressClient
	FileClient
	TableClient
	LockClient

	OperationStartClient

	ID() TxID
	Commit() error
	Abort() error

	// Finished returns a channel that is closed when transaction finishes, either because it was committed or aborted.
	Finished() <-chan struct{}

	// BeginTx creates nested transaction.
	BeginTx(ctx context.Context, options *StartTxOptions) (tx Tx, err error)
}

Tx is high level API for master transactions.

Create new tx by calling BeginTx() method on Client or other Tx.

Cleanup of started tx is responsibility of the user. Tx is terminated, either by calling Commit() or Abort(), or by canceling ctx passed to BeginTx().

Unterminated tx will result in goroutine leak.

type TxFunc

type TxFunc func(ctx context.Context, tx Tx) error

TxFunc is a callback used in ExecTx function.

type TxID

type TxID guid.GUID

func (TxID) MarshalYSON

func (id TxID) MarshalYSON(w *yson.Writer) error

func (TxID) String

func (id TxID) String() string

func (*TxID) UnmarshalYSON

func (id *TxID) UnmarshalYSON(data []byte) (err error)

type TxType

type TxType string
var (
	TxTypeMaster TxType = "master"
	TxTypeTablet TxType = "tablet"
)

type UnfreezeTableOptions

type UnfreezeTableOptions struct {
	*TabletRangeOptions
	*MutatingOptions
}

type UnlockNodeOptions

type UnlockNodeOptions struct {
	*TransactionOptions
	*MutatingOptions
}

type UnmountTableOptions

type UnmountTableOptions struct {
	*TabletRangeOptions
	*MutatingOptions

	Force bool `http:"force"`
}

type UpdateOperationParametersOptions

type UpdateOperationParametersOptions struct{}

type UserTicketCredentials

type UserTicketCredentials struct {
	Ticket string
}

UserTicketCredentials implements TVM user-tickets authentication.

func (*UserTicketCredentials) Set

func (c *UserTicketCredentials) Set(r *http.Request)

func (*UserTicketCredentials) SetExtension

func (c *UserTicketCredentials) SetExtension(req *rpc.TRequestHeader)

type WriteFileOptions

type WriteFileOptions struct {
	ComputeMD5 bool        `http:"compute_md5"`
	FileWriter interface{} `http:"file_writer"`

	*TransactionOptions
	*PrerequisiteOptions
}

type WriteTableOption

type WriteTableOption func(*tableWriter)

func WithBatchSize

func WithBatchSize(batchSize int) WriteTableOption

WithBatchSize sets batch size (in bytes) for WriteTable.

func WithCreateOptions

func WithCreateOptions(opts ...CreateTableOption) WriteTableOption

WithCreateOptions disables default behavior of creating table on first Write().

Instead, table is created when WriteTable() is called.

func WithExistingTable

func WithExistingTable() WriteTableOption

WithExisting table disables automatic table creation.

func WithTableWriterConfig

func WithTableWriterConfig(config map[string]interface{}) WriteTableOption

type WriteTableOptions

type WriteTableOptions struct {
	TableWriter interface{} `http:"table_writer"`

	*TransactionOptions
	*AccessTrackingOptions
}

Directories

Path Synopsis
package ythttp provides YT client over HTTP protocol.
package ythttp provides YT client over HTTP protocol.

Jump to

Keyboard shortcuts

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