Skip to content

Commit

Permalink
feature: bind transfer features
Browse files Browse the repository at this point in the history
- Bind transfer gateway;
 -Load `ListTransferStatsFeature` and `ListTransfersFeature`.
  • Loading branch information
fno2010 committed Dec 14, 2023
1 parent 97f634e commit 3816bae
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 21 deletions.
13 changes: 12 additions & 1 deletion src/lib/infrastructure/ioc/container-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ import RuleGatewayOutputPort from "@/lib/core/port/secondary/rule-gateway-output
import RuleGateway from "../gateway/rule-gateway/rule-gateway";
import ListAccountRSEQuotasFeature from "./features/list-account-rse-quotas-feature";
import GetAccountInfoFeature from "./features/get-account-info-feature";
import TransferGatewayOutputPort from "@/lib/core/port/secondary/transfer-gateway-output-port";
import TransferGateway from "../gateway/transfer-gateway/transfer-gateway";
import ListTransferStatsFeature from "./features/list-transfer-stats-feature";
import ListTransfersFeature from "./features/list-transfers-feature";


/**
Expand All @@ -77,6 +81,7 @@ appContainer.bind<StreamGatewayOutputPort>(GATEWAYS.STREAM).to(StreamingGateway)
appContainer.bind<SubscriptionGatewayOutputPort>(GATEWAYS.SUBSCRIPTION).to(SubscriptionGateway);
appContainer.bind<ReplicaGatewayOutputPort>(GATEWAYS.REPLICA).to(ReplicaGateway);
appContainer.bind<RuleGatewayOutputPort>(GATEWAYS.RULE).to(RuleGateway);
appContainer.bind<TransferGatewayOutputPort>(GATEWAYS.TRANSFER).to(TransferGateway);

// Load Common Features
loadFeaturesSync(appContainer, [
Expand Down Expand Up @@ -126,6 +131,12 @@ loadFeaturesSync(appContainer, [
new ListSubscriptionRuleStatesFeature(appContainer),
])

// Features: List Transfers
loadFeaturesSync(appContainer, [
new ListTransferStatsFeature(appContainer),
new ListTransfersFeature(appContainer),
])

appContainer.bind<UserPassLoginInputPort>(INPUT_PORT.USERPASS_LOGIN).to(UserPassLoginUseCase).inRequestScope();
appContainer.bind<IUserPassLoginController>(CONTROLLERS.USERPASS_LOGIN).to(UserPassLoginController);
appContainer.bind<interfaces.Factory<UserPassLoginInputPort>>(USECASE_FACTORY.USERPASS_LOGIN).toFactory<UserPassLoginUseCase, [IronSession, NextApiResponse]>((context: interfaces.Context) =>
Expand Down Expand Up @@ -174,4 +185,4 @@ appContainer.bind<interfaces.Factory<SwitchAccountInputPort>>(USECASE_FACTORY.SW
}
);

export default appContainer;
export default appContainer;
24 changes: 4 additions & 20 deletions test/fixtures/table-fixtures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import {
RSEAttribute,
RequestType,
RequestState,
RequestStatsPerPair,
} from '@/lib/core/entity/rucio'
import { RSEAccountUsageLimitViewModel, RSEAttributeViewModel, RSEProtocolViewModel, RSEViewModel } from '@/lib/infrastructure/data/view-model/rse';
import { UseComDOM } from '@/lib/infrastructure/hooks/useComDOM';
Expand Down Expand Up @@ -76,17 +75,6 @@ function createRSEExpression(): string {
return strings.join("&")
}

function randomRequestStats(activities: string[]): RequestStatsPerPair[] {
const avail_activities = faker.helpers.arrayElements(activities)
return avail_activities.map<RequestStatsPerPair>((activity) => {
return {
activity: activity,
counter: faker.number.int({ max: 100 }),
bytes: faker.number.int({ min: 0, max: 1e12 }),
};
})
}

export function fixtureDIDViewModel(): DIDViewModel {
return {
...mockBaseVM(),
Expand Down Expand Up @@ -437,7 +425,7 @@ export function fixtureTransferViewModel(): TransferViewModel {
"lifetime": faker.date.future().toISOString()
}),
state: randomEnum<RequestState>(RequestState),
activity: faker.lorem.words({ min: 1, max: 3 }),
activity: faker.company.buzzPhrase(),
bytes: faker.number.int({ min: 0, max: 1e12 }),
account: faker.internet.userName(),
priority: faker.number.int({ min: 0, max: 3 }),
Expand All @@ -449,7 +437,6 @@ export function fixtureTransferViewModel(): TransferViewModel {
}

export function fixtureTransferStatsViewModel(): TransferStatsViewModel {
const activities = faker.helpers.multiple(() => faker.lorem.words({ min: 1, max: 3 }), { count: 9 })
return {
...mockBaseVM(),
account: faker.internet.userName(),
Expand All @@ -458,11 +445,8 @@ export function fixtureTransferStatsViewModel(): TransferStatsViewModel {
dest_rse_id: faker.string.uuid(),
source_rse: createRSEName(),
dest_rse: createRSEName(),
request_stats: randomRequestStats(activities),
activity: faker.company.buzzPhrase(),
counter: faker.number.int({ max: 100 }),
bytes: faker.number.int({ min: 0, max: 1e12 }),
}
}

export function fixtureRequestStatsPerPair(): RequestStatsPerPair[] {
const activities = faker.helpers.multiple(() => faker.lorem.words({ min: 1, max: 3 }), { count: 9 })
return randomRequestStats(activities)
}

0 comments on commit 3816bae

Please sign in to comment.