UBERF-8539: Do not store TypingInfo into memdb (#7043)

Signed-off-by: Andrey Sobolev <haiodo@gmail.com>
This commit is contained in:
Andrey Sobolev 2024-10-26 01:29:19 +07:00 committed by GitHub
parent d7fd553255
commit 470861ed09
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 55 additions and 14 deletions

View File

@ -15,30 +15,30 @@
import activity, { type ActivityMessageControl } from '@hcengineering/activity'
import { chunterId, type ChunterSpace } from '@hcengineering/chunter'
import presentation from '@hcengineering/model-presentation'
import contact from '@hcengineering/contact'
import { type Builder } from '@hcengineering/model'
import core from '@hcengineering/model-core'
import presentation from '@hcengineering/model-presentation'
import view from '@hcengineering/model-view'
import workbench from '@hcengineering/model-workbench'
import { WidgetType } from '@hcengineering/workbench'
import contact from '@hcengineering/contact'
import chunter from './plugin'
import { defineActions } from './actions'
import { defineNotifications } from './notifications'
import chunter from './plugin'
import {
DOMAIN_CHUNTER,
TChannel,
TChatMessage,
TChatMessageViewlet,
TChatSyncInfo,
TChunterExtension,
TChunterSpace,
TDirectMessage,
TInlineButton,
TObjectChatPanel,
TThreadMessage,
TTypingInfo,
TChunterExtension
TTypingInfo
} from './types'
export { chunterId } from '@hcengineering/chunter'
@ -161,6 +161,10 @@ export function createModel (builder: Builder): void {
presenter: chunter.component.ThreadMessagePresenter
})
builder.mixin(chunter.class.TypingInfo, core.class.Class, core.mixin.TransientConfiguration, {
broadcastOnly: true
})
builder.createDoc(
view.class.Viewlet,
core.space.Model,

View File

@ -14,8 +14,6 @@
//
import {
type Card,
type CollaborativeDoc,
DOMAIN_BLOB,
DOMAIN_CONFIGURATION,
DOMAIN_DOC_INDEX_STATE,
@ -27,8 +25,10 @@ import {
type ArrOf,
type AttachedDoc,
type Blob,
type Card,
type Class,
type ClassifierKind,
type CollaborativeDoc,
type Collection,
type Configuration,
type ConfigurationElement,
@ -50,6 +50,7 @@ import {
type RefTo,
type Space,
type Timestamp,
type TransientConfiguration,
type Type,
type TypeAny,
type Version
@ -403,3 +404,9 @@ export class TTypeCollaborativeDocVersion extends TType {}
@UX(core.string.Rank)
@Model(core.class.TypeRank, core.class.Type)
export class TTypeRank extends TType {}
@MMixin(core.mixin.TransientConfiguration, core.class.Class)
export class TTransientConfiguration extends TClass implements TransientConfiguration {
@Prop(TypeBoolean(), core.string.Private)
broadcastOnly!: boolean
}

View File

@ -39,12 +39,12 @@ import {
TAttachedDoc,
TAttribute,
TBlob,
TCard,
TClass,
TCollection,
TConfiguration,
TConfigurationElement,
TDoc,
TCard,
TDocIndexState,
TDomainIndexConfiguration,
TEnum,
@ -57,6 +57,7 @@ import {
TObj,
TPluginConfiguration,
TRefTo,
TTransientConfiguration,
TType,
TTypeAny,
TTypeBlob,
@ -173,7 +174,8 @@ export function createModel (builder: Builder): void {
TMigrationState,
TBlob,
TDomainIndexConfiguration,
TBenchmarkDoc
TBenchmarkDoc,
TTransientConfiguration
)
builder.createDoc(

View File

@ -15,8 +15,8 @@
//
import type { Asset, IntlString, Plugin } from '@hcengineering/platform'
import type { DocumentQuery } from './storage'
import { CollaborativeDoc } from './collaboration'
import type { DocumentQuery } from './storage'
/**
* @public
@ -346,6 +346,14 @@ export const DOMAIN_MIGRATION = '_migrations' as Domain
*/
export const DOMAIN_TRANSIENT = 'transient' as Domain
/**
* @public
*/
export interface TransientConfiguration extends Class<Doc> {
// If set will not store transient objects into memdb
broadcastOnly: boolean
}
/**
* Special domain to access s3 blob data.
* @public

View File

@ -48,6 +48,7 @@ import type {
SpaceTypeDescriptor,
SystemSpace,
Timestamp,
TransientConfiguration,
Type,
TypeAny,
TypedSpace,
@ -148,7 +149,8 @@ export default plugin(coreId, {
mixin: {
ConfigurationElement: '' as Ref<Mixin<ConfigurationElement>>,
IndexConfiguration: '' as Ref<Mixin<IndexingConfiguration<Doc>>>,
SpacesTypeData: '' as Ref<Mixin<Space>>
SpacesTypeData: '' as Ref<Mixin<Space>>,
TransientConfiguration: '' as Ref<Mixin<TransientConfiguration>>
},
space: {
Tx: '' as Ref<Space>,

View File

@ -30,10 +30,12 @@ import core, {
type StorageIterator,
toFindResult,
type Tx,
type TxCUD,
TxProcessor,
type TxResult,
type WorkspaceId
} from '@hcengineering/core'
import { type DbAdapterHandler, type DbAdapter, type DomainHelperOperations } from './adapter'
import { type DbAdapter, type DbAdapterHandler, type DomainHelperOperations } from './adapter'
/**
* @public
@ -119,7 +121,7 @@ export class DummyDbAdapter implements DbAdapter {
class InMemoryAdapter extends DummyDbAdapter implements DbAdapter {
private readonly modeldb: ModelDb
constructor (hierarchy: Hierarchy) {
constructor (readonly hierarchy: Hierarchy) {
super()
this.modeldb = new ModelDb(hierarchy)
}
@ -138,7 +140,23 @@ class InMemoryAdapter extends DummyDbAdapter implements DbAdapter {
}
async tx (ctx: MeasureContext, ...tx: Tx[]): Promise<TxResult[]> {
return await this.modeldb.tx(...tx)
// Filter transactions with broadcast only flags
const ftx = tx.filter((it) => {
if (TxProcessor.isExtendsCUD(it._class)) {
const cud = it as TxCUD<Doc>
const objClass = this.hierarchy.getClass(cud.objectClass)
const mix = this.hierarchy.hasMixin(objClass, core.mixin.TransientConfiguration)
if (mix && this.hierarchy.as(objClass, core.mixin.TransientConfiguration).broadcastOnly) {
// We do not need to store a broadcast only transactions into model.
return false
}
}
return true
})
if (ftx.length === 0) {
return []
}
return await this.modeldb.tx(...ftx)
}
}