Add refreshByRefreshKey to refresh service
Signed-off-by: Kiss Miklos <miklos@roadie.io>
This commit is contained in:
@@ -66,7 +66,7 @@ export const processingResult = Object.freeze({
|
||||
return { type: 'relation', relation: spec };
|
||||
},
|
||||
|
||||
refresh(entity, key) {
|
||||
refresh(entity: Entity, key: String) {
|
||||
return { type: 'refresh', entity, key };
|
||||
},
|
||||
} as const);
|
||||
|
||||
@@ -20,7 +20,11 @@ import {
|
||||
AuthorizeResult,
|
||||
PermissionEvaluator,
|
||||
} from '@backstage/plugin-permission-common';
|
||||
import { RefreshOptions, RefreshService } from './types';
|
||||
import {
|
||||
RefreshByRefreshKeysOptions,
|
||||
RefreshOptions,
|
||||
RefreshService,
|
||||
} from './types';
|
||||
|
||||
export class AuthorizedRefreshService implements RefreshService {
|
||||
constructor(
|
||||
@@ -45,4 +49,7 @@ export class AuthorizedRefreshService implements RefreshService {
|
||||
}
|
||||
await this.service.refresh(options);
|
||||
}
|
||||
async refreshByRefreshKey(options: RefreshByRefreshKeysOptions) {
|
||||
await this.service.refreshByRefreshKey(options);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,7 +15,11 @@
|
||||
*/
|
||||
|
||||
import { DefaultProcessingDatabase } from '../database/DefaultProcessingDatabase';
|
||||
import { RefreshOptions, RefreshService } from './types';
|
||||
import {
|
||||
RefreshByRefreshKeysOptions,
|
||||
RefreshOptions,
|
||||
RefreshService,
|
||||
} from './types';
|
||||
|
||||
export class DefaultRefreshService implements RefreshService {
|
||||
private database: DefaultProcessingDatabase;
|
||||
@@ -45,4 +49,9 @@ export class DefaultRefreshService implements RefreshService {
|
||||
});
|
||||
});
|
||||
}
|
||||
async refreshByRefreshKey(options: RefreshByRefreshKeysOptions) {
|
||||
await this.database.transaction(async tx => {
|
||||
await this.database.refreshByRefreshKey(tx, options);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,6 +61,9 @@ export type RefreshOptions = {
|
||||
authorizationToken?: string;
|
||||
};
|
||||
|
||||
export type RefreshByRefreshKeysOptions = {
|
||||
key: string;
|
||||
};
|
||||
/**
|
||||
* A service that manages refreshes of entities in the catalog.
|
||||
*
|
||||
@@ -71,6 +74,7 @@ export interface RefreshService {
|
||||
* Request a refresh of entities in the catalog.
|
||||
*/
|
||||
refresh(options: RefreshOptions): Promise<void>;
|
||||
refreshByRefreshKey(options: RefreshByRefreshKeysOptions): Promise<void>;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user