use main redis for lock
This commit is contained in:
parent
90e2dfef4e
commit
70415bdab5
|
@ -49,8 +49,8 @@ export class ApInboxService {
|
|||
@Inject(DI.config)
|
||||
private config: Config,
|
||||
|
||||
@Inject(DI.redisForTimelines)
|
||||
private redisForTimelines: Redis.Redis,
|
||||
@Inject(DI.redis)
|
||||
private redisClient: Redis.Redis,
|
||||
|
||||
@Inject(DI.usersRepository)
|
||||
private usersRepository: UsersRepository,
|
||||
|
@ -311,7 +311,7 @@ export class ApInboxService {
|
|||
// アナウンス先が許可されているかチェック
|
||||
if (!this.utilityService.isFederationAllowedUri(uri)) return;
|
||||
|
||||
const unlock = await acquireApObjectLock(this.redisForTimelines, uri);
|
||||
const unlock = await acquireApObjectLock(this.redisClient, uri);
|
||||
|
||||
try {
|
||||
// 既に同じURIを持つものが登録されていないかチェック
|
||||
|
@ -438,7 +438,7 @@ export class ApInboxService {
|
|||
}
|
||||
}
|
||||
|
||||
const unlock = await acquireApObjectLock(this.redisForTimelines, uri);
|
||||
const unlock = await acquireApObjectLock(this.redisClient, uri);
|
||||
|
||||
try {
|
||||
const exist = await this.apNoteService.fetchNote(note);
|
||||
|
@ -522,7 +522,7 @@ export class ApInboxService {
|
|||
private async deleteNote(actor: MiRemoteUser, uri: string): Promise<string> {
|
||||
this.logger.info(`Deleting the Note: ${uri}`);
|
||||
|
||||
const unlock = await acquireApObjectLock(this.redisForTimelines, uri);
|
||||
const unlock = await acquireApObjectLock(this.redisClient, uri);
|
||||
|
||||
try {
|
||||
const note = await this.apDbResolverService.getNoteFromApId(uri);
|
||||
|
|
|
@ -49,8 +49,8 @@ export class ApNoteService {
|
|||
@Inject(DI.meta)
|
||||
private meta: MiMeta,
|
||||
|
||||
@Inject(DI.redisForTimelines)
|
||||
private redisForTimelines: Redis.Redis,
|
||||
@Inject(DI.redis)
|
||||
private redisClient: Redis.Redis,
|
||||
|
||||
@Inject(DI.pollsRepository)
|
||||
private pollsRepository: PollsRepository,
|
||||
|
@ -357,7 +357,7 @@ export class ApNoteService {
|
|||
throw new StatusError('blocked host', 451);
|
||||
}
|
||||
|
||||
const unlock = await acquireApObjectLock(this.redisForTimelines, uri);
|
||||
const unlock = await acquireApObjectLock(this.redisClient, uri);
|
||||
|
||||
try {
|
||||
//#region このサーバーに既に登録されていたらそれを返す
|
||||
|
|
|
@ -29,13 +29,13 @@ export default class ActiveUsersChart extends Chart<typeof schema> { // eslint-d
|
|||
@Inject(DI.db)
|
||||
private db: DataSource,
|
||||
|
||||
@Inject(DI.redisForTimelines)
|
||||
private redisForTimelines: Redis.Redis,
|
||||
@Inject(DI.redis)
|
||||
private redisClient: Redis.Redis,
|
||||
|
||||
private chartLoggerService: ChartLoggerService,
|
||||
private idService: IdService,
|
||||
) {
|
||||
super(db, (k) => acquireChartInsertLock(redisForTimelines, k), chartLoggerService.logger, name, schema);
|
||||
super(db, (k) => acquireChartInsertLock(redisClient, k), chartLoggerService.logger, name, schema);
|
||||
}
|
||||
|
||||
protected async tickMajor(): Promise<Partial<KVs<typeof schema>>> {
|
||||
|
|
|
@ -23,12 +23,12 @@ export default class ApRequestChart extends Chart<typeof schema> { // eslint-dis
|
|||
@Inject(DI.db)
|
||||
private db: DataSource,
|
||||
|
||||
@Inject(DI.redisForTimelines)
|
||||
private redisForTimelines: Redis.Redis,
|
||||
@Inject(DI.redis)
|
||||
private redisClient: Redis.Redis,
|
||||
|
||||
private chartLoggerService: ChartLoggerService,
|
||||
) {
|
||||
super(db, (k) => acquireChartInsertLock(redisForTimelines, k), chartLoggerService.logger, name, schema);
|
||||
super(db, (k) => acquireChartInsertLock(redisClient, k), chartLoggerService.logger, name, schema);
|
||||
}
|
||||
|
||||
protected async tickMajor(): Promise<Partial<KVs<typeof schema>>> {
|
||||
|
|
|
@ -24,12 +24,12 @@ export default class DriveChart extends Chart<typeof schema> { // eslint-disable
|
|||
@Inject(DI.db)
|
||||
private db: DataSource,
|
||||
|
||||
@Inject(DI.redisForTimelines)
|
||||
private redisForTimelines: Redis.Redis,
|
||||
@Inject(DI.redis)
|
||||
private redisClient: Redis.Redis,
|
||||
|
||||
private chartLoggerService: ChartLoggerService,
|
||||
) {
|
||||
super(db, (k) => acquireChartInsertLock(redisForTimelines, k), chartLoggerService.logger, name, schema);
|
||||
super(db, (k) => acquireChartInsertLock(redisClient, k), chartLoggerService.logger, name, schema);
|
||||
}
|
||||
|
||||
protected async tickMajor(): Promise<Partial<KVs<typeof schema>>> {
|
||||
|
|
|
@ -27,8 +27,8 @@ export default class FederationChart extends Chart<typeof schema> { // eslint-di
|
|||
@Inject(DI.meta)
|
||||
private meta: MiMeta,
|
||||
|
||||
@Inject(DI.redisForTimelines)
|
||||
private redisForTimelines: Redis.Redis,
|
||||
@Inject(DI.redis)
|
||||
private redisClient: Redis.Redis,
|
||||
|
||||
@Inject(DI.followingsRepository)
|
||||
private followingsRepository: FollowingsRepository,
|
||||
|
@ -38,7 +38,7 @@ export default class FederationChart extends Chart<typeof schema> { // eslint-di
|
|||
|
||||
private chartLoggerService: ChartLoggerService,
|
||||
) {
|
||||
super(db, (k) => acquireChartInsertLock(redisForTimelines, k), chartLoggerService.logger, name, schema);
|
||||
super(db, (k) => acquireChartInsertLock(redisClient, k), chartLoggerService.logger, name, schema);
|
||||
}
|
||||
|
||||
protected async tickMajor(): Promise<Partial<KVs<typeof schema>>> {
|
||||
|
|
|
@ -27,8 +27,8 @@ export default class InstanceChart extends Chart<typeof schema> { // eslint-disa
|
|||
@Inject(DI.db)
|
||||
private db: DataSource,
|
||||
|
||||
@Inject(DI.redisForTimelines)
|
||||
private redisForTimelines: Redis.Redis,
|
||||
@Inject(DI.redis)
|
||||
private redisClient: Redis.Redis,
|
||||
|
||||
@Inject(DI.usersRepository)
|
||||
private usersRepository: UsersRepository,
|
||||
|
@ -45,7 +45,7 @@ export default class InstanceChart extends Chart<typeof schema> { // eslint-disa
|
|||
private utilityService: UtilityService,
|
||||
private chartLoggerService: ChartLoggerService,
|
||||
) {
|
||||
super(db, (k) => acquireChartInsertLock(redisForTimelines, k), chartLoggerService.logger, name, schema, true);
|
||||
super(db, (k) => acquireChartInsertLock(redisClient, k), chartLoggerService.logger, name, schema, true);
|
||||
}
|
||||
|
||||
protected async tickMajor(group: string): Promise<Partial<KVs<typeof schema>>> {
|
||||
|
|
|
@ -25,15 +25,15 @@ export default class NotesChart extends Chart<typeof schema> { // eslint-disable
|
|||
@Inject(DI.db)
|
||||
private db: DataSource,
|
||||
|
||||
@Inject(DI.redisForTimelines)
|
||||
private redisForTimelines: Redis.Redis,
|
||||
@Inject(DI.redis)
|
||||
private redisClient: Redis.Redis,
|
||||
|
||||
@Inject(DI.notesRepository)
|
||||
private notesRepository: NotesRepository,
|
||||
|
||||
private chartLoggerService: ChartLoggerService,
|
||||
) {
|
||||
super(db, (k) => acquireChartInsertLock(redisForTimelines, k), chartLoggerService.logger, name, schema);
|
||||
super(db, (k) => acquireChartInsertLock(redisClient, k), chartLoggerService.logger, name, schema);
|
||||
}
|
||||
|
||||
protected async tickMajor(): Promise<Partial<KVs<typeof schema>>> {
|
||||
|
|
|
@ -26,8 +26,8 @@ export default class PerUserDriveChart extends Chart<typeof schema> { // eslint-
|
|||
@Inject(DI.db)
|
||||
private db: DataSource,
|
||||
|
||||
@Inject(DI.redisForTimelines)
|
||||
private redisForTimelines: Redis.Redis,
|
||||
@Inject(DI.redis)
|
||||
private redisClient: Redis.Redis,
|
||||
|
||||
@Inject(DI.driveFilesRepository)
|
||||
private driveFilesRepository: DriveFilesRepository,
|
||||
|
@ -35,7 +35,7 @@ export default class PerUserDriveChart extends Chart<typeof schema> { // eslint-
|
|||
private driveFileEntityService: DriveFileEntityService,
|
||||
private chartLoggerService: ChartLoggerService,
|
||||
) {
|
||||
super(db, (k) => acquireChartInsertLock(redisForTimelines, k), chartLoggerService.logger, name, schema, true);
|
||||
super(db, (k) => acquireChartInsertLock(redisClient, k), chartLoggerService.logger, name, schema, true);
|
||||
}
|
||||
|
||||
protected async tickMajor(group: string): Promise<Partial<KVs<typeof schema>>> {
|
||||
|
|
|
@ -26,8 +26,8 @@ export default class PerUserFollowingChart extends Chart<typeof schema> { // esl
|
|||
@Inject(DI.db)
|
||||
private db: DataSource,
|
||||
|
||||
@Inject(DI.redisForTimelines)
|
||||
private redisForTimelines: Redis.Redis,
|
||||
@Inject(DI.redis)
|
||||
private redisClient: Redis.Redis,
|
||||
|
||||
@Inject(DI.followingsRepository)
|
||||
private followingsRepository: FollowingsRepository,
|
||||
|
@ -35,7 +35,7 @@ export default class PerUserFollowingChart extends Chart<typeof schema> { // esl
|
|||
private userEntityService: UserEntityService,
|
||||
private chartLoggerService: ChartLoggerService,
|
||||
) {
|
||||
super(db, (k) => acquireChartInsertLock(redisForTimelines, k), chartLoggerService.logger, name, schema, true);
|
||||
super(db, (k) => acquireChartInsertLock(redisClient, k), chartLoggerService.logger, name, schema, true);
|
||||
}
|
||||
|
||||
protected async tickMajor(group: string): Promise<Partial<KVs<typeof schema>>> {
|
||||
|
|
|
@ -26,15 +26,15 @@ export default class PerUserNotesChart extends Chart<typeof schema> { // eslint-
|
|||
@Inject(DI.db)
|
||||
private db: DataSource,
|
||||
|
||||
@Inject(DI.redisForTimelines)
|
||||
private redisForTimelines: Redis.Redis,
|
||||
@Inject(DI.redis)
|
||||
private redisClient: Redis.Redis,
|
||||
|
||||
@Inject(DI.notesRepository)
|
||||
private notesRepository: NotesRepository,
|
||||
|
||||
private chartLoggerService: ChartLoggerService,
|
||||
) {
|
||||
super(db, (k) => acquireChartInsertLock(redisForTimelines, k), chartLoggerService.logger, name, schema, true);
|
||||
super(db, (k) => acquireChartInsertLock(redisClient, k), chartLoggerService.logger, name, schema, true);
|
||||
}
|
||||
|
||||
protected async tickMajor(group: string): Promise<Partial<KVs<typeof schema>>> {
|
||||
|
|
|
@ -24,12 +24,12 @@ export default class PerUserPvChart extends Chart<typeof schema> { // eslint-dis
|
|||
@Inject(DI.db)
|
||||
private db: DataSource,
|
||||
|
||||
@Inject(DI.redisForTimelines)
|
||||
private redisForTimelines: Redis.Redis,
|
||||
@Inject(DI.redis)
|
||||
private redisClient: Redis.Redis,
|
||||
|
||||
private chartLoggerService: ChartLoggerService,
|
||||
) {
|
||||
super(db, (k) => acquireChartInsertLock(redisForTimelines, k), chartLoggerService.logger, name, schema, true);
|
||||
super(db, (k) => acquireChartInsertLock(redisClient, k), chartLoggerService.logger, name, schema, true);
|
||||
}
|
||||
|
||||
protected async tickMajor(): Promise<Partial<KVs<typeof schema>>> {
|
||||
|
|
|
@ -26,13 +26,13 @@ export default class PerUserReactionsChart extends Chart<typeof schema> { // esl
|
|||
@Inject(DI.db)
|
||||
private db: DataSource,
|
||||
|
||||
@Inject(DI.redisForTimelines)
|
||||
private redisForTimelines: Redis.Redis,
|
||||
@Inject(DI.redis)
|
||||
private redisClient: Redis.Redis,
|
||||
|
||||
private userEntityService: UserEntityService,
|
||||
private chartLoggerService: ChartLoggerService,
|
||||
) {
|
||||
super(db, (k) => acquireChartInsertLock(redisForTimelines, k), chartLoggerService.logger, name, schema, true);
|
||||
super(db, (k) => acquireChartInsertLock(redisClient, k), chartLoggerService.logger, name, schema, true);
|
||||
}
|
||||
|
||||
protected async tickMajor(group: string): Promise<Partial<KVs<typeof schema>>> {
|
||||
|
|
|
@ -25,12 +25,12 @@ export default class TestGroupedChart extends Chart<typeof schema> { // eslint-d
|
|||
@Inject(DI.db)
|
||||
private db: DataSource,
|
||||
|
||||
@Inject(DI.redisForTimelines)
|
||||
private redisForTimelines: Redis.Redis,
|
||||
@Inject(DI.redis)
|
||||
private redisClient: Redis.Redis,
|
||||
|
||||
logger: Logger,
|
||||
) {
|
||||
super(db, (k) => acquireChartInsertLock(redisForTimelines, k), logger, name, schema, true);
|
||||
super(db, (k) => acquireChartInsertLock(redisClient, k), logger, name, schema, true);
|
||||
}
|
||||
|
||||
protected async tickMajor(group: string): Promise<Partial<KVs<typeof schema>>> {
|
||||
|
|
|
@ -23,12 +23,12 @@ export default class TestIntersectionChart extends Chart<typeof schema> { // esl
|
|||
@Inject(DI.db)
|
||||
private db: DataSource,
|
||||
|
||||
@Inject(DI.redisForTimelines)
|
||||
private redisForTimelines: Redis.Redis,
|
||||
@Inject(DI.redis)
|
||||
private redisClient: Redis.Redis,
|
||||
|
||||
logger: Logger,
|
||||
) {
|
||||
super(db, (k) => acquireChartInsertLock(redisForTimelines, k), logger, name, schema);
|
||||
super(db, (k) => acquireChartInsertLock(redisClient, k), logger, name, schema);
|
||||
}
|
||||
|
||||
protected async tickMajor(): Promise<Partial<KVs<typeof schema>>> {
|
||||
|
|
|
@ -23,12 +23,12 @@ export default class TestUniqueChart extends Chart<typeof schema> { // eslint-di
|
|||
@Inject(DI.db)
|
||||
private db: DataSource,
|
||||
|
||||
@Inject(DI.redisForTimelines)
|
||||
private redisForTimelines: Redis.Redis,
|
||||
@Inject(DI.redis)
|
||||
private redisClient: Redis.Redis,
|
||||
|
||||
logger: Logger,
|
||||
) {
|
||||
super(db, (k) => acquireChartInsertLock(redisForTimelines, k), logger, name, schema);
|
||||
super(db, (k) => acquireChartInsertLock(redisClient, k), logger, name, schema);
|
||||
}
|
||||
|
||||
protected async tickMajor(): Promise<Partial<KVs<typeof schema>>> {
|
||||
|
|
|
@ -25,12 +25,12 @@ export default class TestChart extends Chart<typeof schema> { // eslint-disable-
|
|||
@Inject(DI.db)
|
||||
private db: DataSource,
|
||||
|
||||
@Inject(DI.redisForTimelines)
|
||||
private redisForTimelines: Redis.Redis,
|
||||
@Inject(DI.redis)
|
||||
private redisClient: Redis.Redis,
|
||||
|
||||
logger: Logger,
|
||||
) {
|
||||
super(db, (k) => acquireChartInsertLock(redisForTimelines, k), logger, name, schema);
|
||||
super(db, (k) => acquireChartInsertLock(redisClient, k), logger, name, schema);
|
||||
}
|
||||
|
||||
protected async tickMajor(): Promise<Partial<KVs<typeof schema>>> {
|
||||
|
|
|
@ -26,8 +26,8 @@ export default class UsersChart extends Chart<typeof schema> { // eslint-disable
|
|||
@Inject(DI.db)
|
||||
private db: DataSource,
|
||||
|
||||
@Inject(DI.redisForTimelines)
|
||||
private redisForTimelines: Redis.Redis,
|
||||
@Inject(DI.redis)
|
||||
private redisClient: Redis.Redis,
|
||||
|
||||
@Inject(DI.usersRepository)
|
||||
private usersRepository: UsersRepository,
|
||||
|
@ -35,7 +35,7 @@ export default class UsersChart extends Chart<typeof schema> { // eslint-disable
|
|||
private userEntityService: UserEntityService,
|
||||
private chartLoggerService: ChartLoggerService,
|
||||
) {
|
||||
super(db, (k) => acquireChartInsertLock(redisForTimelines, k), chartLoggerService.logger, name, schema);
|
||||
super(db, (k) => acquireChartInsertLock(redisClient, k), chartLoggerService.logger, name, schema);
|
||||
}
|
||||
|
||||
protected async tickMajor(): Promise<Partial<KVs<typeof schema>>> {
|
||||
|
|
|
@ -25,7 +25,7 @@ describe('Chart', () => {
|
|||
const config = loadConfig();
|
||||
|
||||
let db: DataSource | undefined;
|
||||
let redisForTimelines = {
|
||||
let redisClient = {
|
||||
set: () => Promise.resolve('OK'),
|
||||
get: () => Promise.resolve(null),
|
||||
} as unknown as jest.Mocked<Redis.Redis>;
|
||||
|
@ -65,10 +65,10 @@ describe('Chart', () => {
|
|||
await db.initialize();
|
||||
|
||||
const logger = new Logger('chart'); // TODO: モックにする
|
||||
testChart = new TestChart(db, redisForTimelines, logger);
|
||||
testGroupedChart = new TestGroupedChart(db, redisForTimelines, logger);
|
||||
testUniqueChart = new TestUniqueChart(db, redisForTimelines, logger);
|
||||
testIntersectionChart = new TestIntersectionChart(db, redisForTimelines, logger);
|
||||
testChart = new TestChart(db, redisClient, logger);
|
||||
testGroupedChart = new TestGroupedChart(db, redisClient, logger);
|
||||
testUniqueChart = new TestUniqueChart(db, redisClient, logger);
|
||||
testIntersectionChart = new TestIntersectionChart(db, redisClient, logger);
|
||||
|
||||
clock = lolex.install({
|
||||
now: new Date(Date.UTC(2000, 0, 1, 0, 0, 0)),
|
||||
|
|
Loading…
Reference in New Issue