style(api): apply prettier formatting

This commit is contained in:
dahyeon committed 2026-07-24 21:42:28 -07:00
1 parent 80fef25af3
commit 96fede9fe5
75 files changed
+955 -674

No files matched your search

@@ -35,8 +35,7 @@ export interface RunWithDistributedLockOptions {
lockRetryDelayMilliseconds?: number;
}
export interface RunWithRenewedDistributedLockOptions
extends RunWithDistributedLockOptions {
export interface RunWithRenewedDistributedLockOptions extends RunWithDistributedLockOptions {
lockRenewalIntervalMilliseconds: number;
}
@@ -55,14 +54,16 @@ export class DistributedLockService {
);
const lockOwnershipToken = options.lockOwnershipToken ?? randomUUID();
const result = await this.redisService.raw().sendCommand([
'SET',
options.lockKey,
lockOwnershipToken,
'NX',
'PX',
String(options.lockExpirationDurationMilliseconds),
]);
const result = await this.redisService
.raw()
.sendCommand([
'SET',
options.lockKey,
lockOwnershipToken,
'NX',
'PX',
String(options.lockExpirationDurationMilliseconds),
]);
if (String(result) !== 'OK') return null;
return {
@@ -76,34 +77,37 @@ export class DistributedLockService {
public async releaseLockIfOwned(
lockOwnership: DistributedLockOwnership,
): Promise<boolean> {
const result = await this.redisService.raw().sendCommand([
'EVAL',
RELEASE_LOCK_IF_OWNED_SCRIPT,
'1',
lockOwnership.lockKey,
lockOwnership.lockOwnershipToken,
]);
const result = await this.redisService
.raw()
.sendCommand([
'EVAL',
RELEASE_LOCK_IF_OWNED_SCRIPT,
'1',
lockOwnership.lockKey,
lockOwnership.lockOwnershipToken,
]);
return Number(result) === 1;
}
public async extendLockIfOwned(
lockOwnership: DistributedLockOwnership,
lockExpirationDurationMilliseconds =
lockOwnership.lockExpirationDurationMilliseconds,
lockExpirationDurationMilliseconds = lockOwnership.lockExpirationDurationMilliseconds,
): Promise<boolean> {
this.assertPositiveDuration(
lockExpirationDurationMilliseconds,
'lockExpirationDurationMilliseconds',
);
const result = await this.redisService.raw().sendCommand([
'EVAL',
EXTEND_LOCK_IF_OWNED_SCRIPT,
'1',
lockOwnership.lockKey,
lockOwnership.lockOwnershipToken,
String(lockExpirationDurationMilliseconds),
]);
const result = await this.redisService
.raw()
.sendCommand([
'EVAL',
EXTEND_LOCK_IF_OWNED_SCRIPT,
'1',
lockOwnership.lockKey,
lockOwnership.lockOwnershipToken,
String(lockExpirationDurationMilliseconds),
]);
return Number(result) === 1;
}
@@ -25,7 +25,9 @@ async function readFirstSecret(
{
provide: REDIS_CLIENT,
inject: [SecretService],
useFactory: async (secretService: SecretService): Promise<RedisClient> => {
useFactory: async (
secretService: SecretService,
): Promise<RedisClient> => {
await secretService.ready();
const [url, endpoint, username, password] = await Promise.all([
@@ -6,15 +6,17 @@ function createRedisService(client: Record<string, unknown>) {
describe('RedisService stream pending recovery', () => {
it('normalizes XAUTOCLAIM array replies into stream entries', async () => {
const sendCommand = jest.fn().mockResolvedValue([
'0-0',
[
const sendCommand = jest
.fn()
.mockResolvedValue([
'0-0',
[
'1700000000000-0',
['job', '{"kind":"poll-tournament-result"}', 'source', 'test'],
[
'1700000000000-0',
['job', '{"kind":"poll-tournament-result"}', 'source', 'test'],
],
],
],
]);
]);
const service = createRedisService({ sendCommand });
await expect(
@@ -223,9 +223,7 @@ export class RedisService implements OnModuleDestroy {
])) as unknown;
const responseItems = Array.isArray(response) ? response : [];
const rawMessages = Array.isArray(responseItems[1])
? responseItems[1]
: [];
const rawMessages = Array.isArray(responseItems[1]) ? responseItems[1] : [];
return {
nextStartId: String(responseItems[0] ?? '0-0'),
@@ -258,7 +256,9 @@ export class RedisService implements OnModuleDestroy {
return this.client.publish(channel, message);
}
private normalizeClaimedStreamMessage(rawMessage: unknown): StreamEntry | null {
private normalizeClaimedStreamMessage(
rawMessage: unknown,
): StreamEntry | null {
if (Array.isArray(rawMessage)) {
const [id, fields] = rawMessage;
if (id === undefined) return null;