-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #400 from ydb-platform/topic
Add topic write retrier, test reader and continues reauth
- Loading branch information
Showing
48 changed files
with
1,506 additions
and
786 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
YDB_ANONYMOUS_CREDENTIALS=1 | ||
YDB_SSL_ROOT_CERTIFICATES_FILE=../slo-tests/playground/data/ydb_certs/ca.pem | ||
YDB_ENDPOINT=grpc://<localhost / fqdn / ip-address>:<2135 / 2136> | ||
YDB_ENDPOINT=grpc://localhost:2136 | ||
YDB_LOG_LEVEL=debug | ||
YDB_DETAILED_TRACE_STACK=true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Due to a problem with a reference to json - TEMPORARY example is as md-file |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import {Driver as YDB} from '../../src'; | ||
import {AnonymousAuthService} from "../../src/credentials/anonymous-auth-service"; | ||
import {Ydb} from "ydb-sdk-proto"; | ||
import {SimpleLogger} from "../../src/logger/simple-logger"; | ||
import {Context} from "../../src/context"; | ||
|
||
require('dotenv').config(); | ||
|
||
const DATABASE = '/local'; | ||
const ENDPOINT = process.env.YDB_ENDPOINT || 'grpc://localhost:2136'; | ||
|
||
async function main() { | ||
const db = new YDB({ | ||
endpoint: ENDPOINT, | ||
database: DATABASE, | ||
authService: new AnonymousAuthService(), | ||
logger: new SimpleLogger({envKey: 'YDB_TEST_LOG_LEVEL'}), | ||
}); | ||
if (!(await db.ready(3000))) throw new Error('Driver is not ready!'); | ||
await db.topic.createTopic({ | ||
path: 'demoTopic', | ||
consumers: [{ | ||
name: 'demo', | ||
}], | ||
}); | ||
const writer = await db.topic.createWriter({ | ||
path: 'demoTopic', | ||
// producerId: '...', // will be genereted automatically | ||
// messageGroupId: '...' // will be the same as producerId | ||
getLastSeqNo: true, // seqNo will be assigned automatically | ||
}); | ||
await writer.sendMessages({ | ||
codec: Ydb.Topic.Codec.CODEC_RAW, | ||
messages: [{ | ||
data: Buffer.from('Hello, world'), | ||
uncompressedSize: 'Hello, world'.length, | ||
}], | ||
}); | ||
const promises = []; | ||
for (let n = 0; n < 4; n++) { | ||
// ((writer as any).innerWriteStream as TopicWriteStreamWithEvents).close(Context.createNew().ctx, new Error('Fake error')); | ||
|
||
// await sleep(3000); // TODO: | ||
|
||
promises.push(writer.sendMessages({ | ||
codec: Ydb.Topic.Codec.CODEC_RAW, | ||
messages: [{ | ||
data: Buffer.from(`Message N${n}`), | ||
uncompressedSize: `Message N${n}`.length, | ||
}], | ||
})); | ||
} | ||
await Promise.all(promises); | ||
const reader = await db.topic.createReader(Context.createNew({ | ||
timeout: 3000, | ||
}).ctx, { | ||
topicsReadSettings: [{ | ||
path: 'demoTopic', | ||
}], | ||
consumer: 'demo', | ||
receiveBufferSizeInBytes: 10_000_000, | ||
}); | ||
for await (const message of reader.messages) { | ||
console.info(`Message: ${message.data!.toString()}`); | ||
await message.commit(); | ||
} | ||
await reader.close(); // graceful close() - complete when all messages are commited | ||
} | ||
|
||
main(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.