Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Take out shared code that works with YDB sessions #349

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ All notable changes to this project will be documented in this file. See [standa
- decimal value is present as string instead of bigint
(it wasn't working for float values before)
- fix uuid and tz-date types conversion (it wasn't working before)
* signatures of most methods in Session are changed:
* signatures of most methods in TableSession are changed:
- executeQuery
Before: `(query, params, txControl, operationParams?, settings?, collectStats?)`
After: `(query, params, txControl, settings?)`
Expand Down Expand Up @@ -336,7 +336,7 @@ All notable changes to this project will be documented in this file. See [standa

* drop support of old environment variables ([963819a](https://www.github.com/ydb-platform/ydb-nodejs-sdk/commit/963819af9209a45749f5118077f1da4bdb390fa6))
* reorganize signature of SchemeClient's methods ([734d57a](https://www.github.com/ydb-platform/ydb-nodejs-sdk/commit/734d57a2dd7c655cf727b96df415212504339cf8))
* reorganize signatures of Session's methods ([431f149](https://www.github.com/ydb-platform/ydb-nodejs-sdk/commit/431f1491bf880f3ba9541d9455d8dd2f2b7849e6))
* reorganize signatures of TableSession's methods ([431f149](https://www.github.com/ydb-platform/ydb-nodejs-sdk/commit/431f1491bf880f3ba9541d9455d8dd2f2b7849e6))
* use identity names conversion in TypedData ([275598a](https://www.github.com/ydb-platform/ydb-nodejs-sdk/commit/275598aa444e1e977386a3dadd02bbc9ba01f38e))

### [2.9.2](https://www.github.com/ydb-platform/ydb-nodejs-sdk/compare/v2.9.1...v2.9.2) (2022-02-09)
Expand Down Expand Up @@ -431,7 +431,7 @@ All notable changes to this project will be documented in this file. See [standa
* and many other changes in protobufs.

### 1.10.0
* Add `alterTable` method to Session class
* Add `alterTable` method to TableSession class
* Put compiled protobufs to a separate 'ydb-sdk' namespace

### 1.9.0
Expand Down
4 changes: 2 additions & 2 deletions src/__tests__/alter-table.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import {
AlterTableDescription,
AlterTableSettings,
Column,
OperationParams,
TableDescription,
TableIndex,
} from '../table';
} from '../table/table-client';
import { Types } from '../types';
import {OperationParams} from "../table/session";

const getTableName = () => `table_alter_${Math.trunc(1000 * Math.random())}`;

Expand Down
4 changes: 2 additions & 2 deletions src/__tests__/bulk-upsert.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ import {
Row,
TABLE
} from '../test-utils';
import {Session} from '../table';
import {TableSession} from '../table/table-client';
import {Ydb} from 'ydb-sdk-proto';

async function readTable(session: Session): Promise<Row[]> {
async function readTable(session: TableSession): Promise<Row[]> {
const rows: Row[] = [];

await session.streamReadTable(TABLE, (result) => {
Expand Down
6 changes: 3 additions & 3 deletions src/__tests__/bytestring-identity.test.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import Driver from '../driver';
import {destroyDriver, initDriver, TABLE} from '../test-utils';
import {Column, Session, TableDescription} from '../table';
import {Column, TableSession, TableDescription} from '../table/table-client';
import {declareType, TypedData, Types} from '../types';
import {withRetries} from '../retries';

async function createTable(session: Session) {
async function createTable(session: TableSession) {
await session.dropTable(TABLE);
await session.createTable(
TABLE,
Expand Down Expand Up @@ -46,7 +46,7 @@ class Row extends TypedData {
}
}

export async function fillTableWithData(session: Session, rows: Row[]) {
export async function fillTableWithData(session: TableSession, rows: Row[]) {
const query = `
DECLARE $data AS List<Struct<id: Uint64, field1: Text, field2: String, field3: Yson>>;

Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/create-table.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Driver from '../driver';
import {destroyDriver, initDriver} from '../test-utils';
import {Column, DescribeTableSettings, TableDescription} from '../table';
import {Column, DescribeTableSettings, TableDescription} from '../table/table-client';
import {TypedValues, Types} from '../types';
import Long from 'long';
import {Ydb} from 'ydb-sdk-proto';
Expand Down
4 changes: 2 additions & 2 deletions src/__tests__/read-table.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ import {
Row,
TABLE
} from '../test-utils';
import {ReadTableSettings, Session} from '../table';
import {ReadTableSettings, TableSession} from '../table/table-client';
import {TypedValues, TypedData} from '../types';

async function readTable(session: Session, settings: ReadTableSettings): Promise<TypedData[]> {
async function readTable(session: TableSession, settings: ReadTableSettings): Promise<TypedData[]> {
const rows: TypedData[] = [];

await session.streamReadTable(TABLE, (result) => {
Expand Down
4 changes: 2 additions & 2 deletions src/__tests__/scan-query.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ import {
initDriver,
Row,
} from '../test-utils';
import {Session} from '../table';
import {TableSession} from '../table/table-client';
import {TypedData} from '../types';

async function executeScanQuery(session: Session): Promise<TypedData[]> {
async function executeScanQuery(session: TableSession): Promise<TypedData[]> {
const query = `SELECT * FROM ${TABLE};`;

const rows: TypedData[] = [];
Expand Down
2 changes: 1 addition & 1 deletion src/driver.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import DiscoveryService from './discovery';
import {TableClient} from './table';
import {TableClient} from './table/table-client';
import SchemeService from './scheme';
import {ENDPOINT_DISCOVERY_PERIOD} from './constants';
import {IAuthService} from './credentials';
Expand Down
17 changes: 9 additions & 8 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,10 @@ export {
StringFunction,
} from './types';
export {
SessionPool,
Session,
TableSession,
CreateTableSettings,
AlterTableSettings,
DropTableSettings,
BeginTransactionSettings,
CommitTransactionSettings,
RollbackTransactionSettings,
DescribeTableSettings,
PrepareQuerySettings,
ExecuteQuerySettings,
Expand All @@ -54,9 +50,8 @@ export {
CompactionPolicy,
ExecutionPolicy,
CachingPolicy,
OperationParams,
AUTO_TX,
} from './table';

} from './table/table-client';
export {
MakeDirectorySettings,
RemoveDirectorySettings,
Expand All @@ -78,3 +73,9 @@ export {
export {ISslCredentials} from './ssl-credentials';
export {withRetries, RetryParameters} from './retries';
export {YdbError, StatusCode} from './errors';
export {SessionPool} from "./table/session-pool";
export {RollbackTransactionSettings} from "./table/session";
export {CommitTransactionSettings} from "./table/session";
export {BeginTransactionSettings} from "./table/session";
export {OperationParams} from "./table/session";
export {AUTO_TX} from "./table/session";
2 changes: 1 addition & 1 deletion src/scheme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import {Logger} from './logging';
import DiscoveryService, {Endpoint} from './discovery';
import {retryable} from "./retries";
import {ISslCredentials} from './ssl-credentials';
import {OperationParamsSettings} from './table';

import SchemeServiceAPI = Ydb.Scheme.V1.SchemeService;
import ListDirectoryResult = Ydb.Scheme.ListDirectoryResult;
Expand All @@ -22,6 +21,7 @@ import IMakeDirectoryRequest = Ydb.Scheme.IMakeDirectoryRequest;
import IPermissions = Ydb.Scheme.IPermissions;
import {util} from "protobufjs";
import EventEmitter = util.EventEmitter;
import {OperationParamsSettings} from "./table/session";


function preparePermissions(action?: IPermissions | null) {
Expand Down
3 changes: 3 additions & 0 deletions src/table/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export * from './session-pool';
export * from './session';
export * from './table-client';
Loading
Loading