Skip to content

Commit

Permalink
Convert attributor to IFluidDataStoreChannel (#22120)
Browse files Browse the repository at this point in the history
## Description

Convert attributor to IFluidDataStoreChannel, so that it can have all
the capacity of a datastore channel like send/receive ops, summarize
etc.
This will be useful for custom attribution support where we will need
all this functionality.
Doc link for custom attribution where we will be using this to
send/receive ops:
https://microsoft-my.sharepoint-df.com/:w:/p/jatgarg/EaqG3AT4CrRHpN_l_vorFf4B35C5W39g8S1VI0_syIzUuQ?e=r5YiBX
Still working on some of the test in this PR but putting out there for
review.

---------

Co-authored-by: Jatin Garg <jatingarg@Jatins-MacBook-Pro-2.local>
  • Loading branch information
jatgarg and Jatin Garg committed Aug 16, 2024
1 parent 1850c61 commit bcfda79
Show file tree
Hide file tree
Showing 12 changed files with 698 additions and 592 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*/

import { IModelContainerRuntimeEntryPoint } from "@fluid-example/example-utils";
import { createRuntimeAttributor, mixinAttributor } from "@fluid-experimental/attributor";
import { mixinAttributor } from "@fluid-experimental/attributor";
import {
IContainer,
IContainerContext,
Expand Down Expand Up @@ -54,7 +54,6 @@ export abstract class ModelContainerRuntimeFactoryWithAttribution<ModelType>
this.createModel(containerRuntime, container),
}),
runtimeOptions: this.runtimeOptions,
containerScope: { IRuntimeAttributor: createRuntimeAttributor() },
existing,
});

Expand Down
1 change: 1 addition & 0 deletions packages/framework/attributor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@
"@fluidframework/container-runtime-definitions": "workspace:~",
"@fluidframework/core-interfaces": "workspace:~",
"@fluidframework/core-utils": "workspace:~",
"@fluidframework/datastore": "workspace:~",
"@fluidframework/datastore-definitions": "workspace:~",
"@fluidframework/driver-definitions": "workspace:~",
"@fluidframework/runtime-definitions": "workspace:~",
Expand Down
61 changes: 61 additions & 0 deletions packages/framework/attributor/src/attributorContracts.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/*!
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
* Licensed under the MIT License.
*/

import {
type AttributionInfo,
type AttributionKey,
} from "@fluidframework/runtime-definitions/internal";

// Summary tree keys
export const opBlobName = "opAttributor";

/**
* @internal
*/
export const enableOnNewFileKey = "Fluid.Attribution.EnableOnNewFile";

/**
* @internal
*/
export const IRuntimeAttributor: keyof IProvideRuntimeAttributor = "IRuntimeAttributor";

/**
* @internal
*/
export interface IProvideRuntimeAttributor {
readonly IRuntimeAttributor: IRuntimeAttributor;
}

/**
* @internal
*/
export const attributorDataStoreAlias = "attributor-cf9b6fe4-4c50-4a5d-9045-eb73b886f740";

/**
* Provides access to attribution information stored on the container runtime.
*
* @remarks Attributors are only populated after the container runtime into which they are being injected has initialized.
*
* @sealed
* @internal
*/
export interface IRuntimeAttributor extends IProvideRuntimeAttributor {
/**
* @throws - If no AttributionInfo exists for this key.
*/
get(key: AttributionKey): AttributionInfo;

/**
* @returns Whether any AttributionInfo exists for the provided key.
*/
has(key: AttributionKey): boolean;

/**
* @returns Whether the runtime is currently tracking attribution information for the loaded container.
* If enabled, the runtime attributor can be asked for the attribution info for different keys.
* See {@link mixinAttributor} for more details on when this happens.
*/
readonly isEnabled: boolean;
}
6 changes: 3 additions & 3 deletions packages/framework/attributor/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
*/

export { type IAttributor } from "./attributor.js";
export { mixinAttributor, getRuntimeAttributor } from "./mixinAttributor.js";
export {
createRuntimeAttributor,
attributorDataStoreAlias,
enableOnNewFileKey,
type IProvideRuntimeAttributor,
IRuntimeAttributor,
mixinAttributor,
} from "./mixinAttributor.js";
} from "./attributorContracts.js";
Loading

0 comments on commit bcfda79

Please sign in to comment.