Skip to content

Commit 8a62327

Browse files
authored
UBERF-9367: Use domain hash (#7897)
Signed-off-by: Andrey Sobolev <[email protected]>
1 parent 98330cf commit 8a62327

File tree

20 files changed

+211
-78
lines changed

20 files changed

+211
-78
lines changed

Diff for: .vscode/launch.json

+5-3
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@
294294
"name": "Debug backup tool",
295295
"type": "node",
296296
"request": "launch",
297-
"args": ["src/__start.ts", "backup-restore", "../../../hardware/dump/alex-staff-agency", "w-haiodo-alex-staff-c-673ee7ab-87df5406ea-2b8b4d", "--skip", "blob"],
297+
"args": ["src/__start.ts", "backup", "../../../hardware/dump/githubcr", "w-haiodo-githubcr-67403799-de2a46aa46-beb3b2"],
298298
"env": {
299299
"MINIO_ACCESS_KEY": "minioadmin",
300300
"MINIO_SECRET_KEY": "minioadmin",
@@ -304,12 +304,14 @@
304304
"ACCOUNTS_URL": "http://localhost:3000",
305305
"TELEGRAM_DATABASE": "telegram-service"
306306
},
307+
"smartStep": true,
308+
"sourceMapRenames": true,
307309
"runtimeArgs": ["--nolazy", "-r", "ts-node/register"],
308310
"sourceMaps": true,
309311
"cwd": "${workspaceRoot}/dev/tool",
310312
"protocol": "inspector",
311313
"outputCapture": "std",
312-
"runtimeVersion": "20",
314+
"runtimeVersion": "22",
313315
"showAsyncStacks": true
314316
},
315317
{
@@ -399,7 +401,7 @@
399401
"SECRET": "secret",
400402
"REGION": "cockroach",
401403
"BUCKET_NAME":"backups",
402-
"INTERVAL":"43200"
404+
"INTERVAL":"0"
403405
},
404406
"runtimeArgs": ["--nolazy", "-r", "ts-node/register"],
405407
"showAsyncStacks": true,

Diff for: packages/core/src/__tests__/client.test.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import { ModelDb, TxDb } from '../memdb'
2424
import { TxOperations } from '../operations'
2525
import type { DocumentQuery, FindResult, SearchOptions, SearchQuery, SearchResult, TxResult } from '../storage'
2626
import { Tx, TxFactory, TxProcessor } from '../tx'
27-
import { fillConfiguration, pluginFilterTx } from '../utils'
27+
import { fillConfiguration, generateId, pluginFilterTx } from '../utils'
2828
import { connect } from './connection'
2929
import { genMinModel } from './minmodel'
3030

@@ -142,6 +142,10 @@ describe('client', () => {
142142
finished: true
143143
})
144144

145+
async getDomainHash (domain: Domain): Promise<string> {
146+
return generateId()
147+
}
148+
145149
async closeChunk (idx: number): Promise<void> {}
146150
async loadDocs (domain: Domain, docs: Ref<Doc>[]): Promise<Doc[]> {
147151
return []

Diff for: packages/core/src/__tests__/connection.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
// limitations under the License.
1414
//
1515

16-
import { ClientConnectEvent, DocChunk } from '..'
16+
import { ClientConnectEvent, DocChunk, generateId } from '..'
1717
import type { Account, Class, Doc, Domain, Ref, Timestamp } from '../classes'
1818
import { ClientConnection } from '../client'
1919
import core from '../component'
@@ -82,6 +82,10 @@ export async function connect (handler: (tx: Tx) => void): Promise<ClientConnect
8282
}
8383
}
8484

85+
async getDomainHash (domain: Domain): Promise<string> {
86+
return generateId()
87+
}
88+
8589
async closeChunk (idx: number): Promise<void> {}
8690
async loadDocs (domain: Domain, docs: Ref<Doc>[]): Promise<Doc[]> {
8791
return []

Diff for: packages/core/src/backup.ts

+2
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,7 @@ export interface BackupClient {
2626
upload: (domain: Domain, docs: Doc[]) => Promise<void>
2727
clean: (domain: Domain, docs: Ref<Doc>[]) => Promise<void>
2828

29+
getDomainHash: (domain: Domain) => Promise<string>
30+
2931
sendForceClose: () => Promise<void>
3032
}

Diff for: packages/core/src/client.ts

+4
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,10 @@ class ClientImpl implements AccountClient, BackupClient {
182182
return await this.conn.loadChunk(domain, idx)
183183
}
184184

185+
async getDomainHash (domain: Domain): Promise<string> {
186+
return await this.conn.getDomainHash(domain)
187+
}
188+
185189
async closeChunk (idx: number): Promise<void> {
186190
await this.conn.closeChunk(idx)
187191
}

Diff for: packages/core/src/server.ts

+2
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,8 @@ export interface LowLevelStorage {
102102
query: DocumentQuery<T>,
103103
options?: Pick<FindOptions<T>, 'sort' | 'limit' | 'projection'>
104104
) => Promise<Iterator<T>>
105+
106+
getDomainHash: (ctx: MeasureContext, domain: Domain) => Promise<string>
105107
}
106108

107109
export interface Iterator<T extends Doc> {

Diff for: packages/query/src/__tests__/connection.ts

+5
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import core, {
2828
FindOptions,
2929
FindResult,
3030
FulltextStorage,
31+
generateId,
3132
Hierarchy,
3233
LoadModelResponse,
3334
ModelDb,
@@ -126,6 +127,10 @@ FulltextStorage & {
126127
}
127128
}
128129

130+
async getDomainHash (domain: Domain): Promise<string> {
131+
return generateId()
132+
}
133+
129134
async loadModel (lastTxTime: Timestamp): Promise<Tx[]> {
130135
return txes
131136
}

Diff for: plugins/client-resources/src/connection.ts

+4
Original file line numberDiff line numberDiff line change
@@ -802,6 +802,10 @@ class Connection implements ClientConnection {
802802
return this.sendRequest({ method: 'loadChunk', params: [domain, idx] })
803803
}
804804

805+
async getDomainHash (domain: Domain): Promise<string> {
806+
return await this.sendRequest({ method: 'getDomainHash', params: [domain] })
807+
}
808+
805809
closeChunk (idx: number): Promise<void> {
806810
return this.sendRequest({ method: 'closeChunk', params: [idx] })
807811
}

0 commit comments

Comments
 (0)