-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9009cce
commit 81eca0f
Showing
6 changed files
with
55 additions
and
2 deletions.
There are no files selected for viewing
24 changes: 24 additions & 0 deletions
24
...http-repository/src/lib/configuration/context/http-offline-queue-context.configuration.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
export interface HttpOfflineQueueContext { | ||
|
||
/** | ||
* @description | ||
* The time to live of the queued request in milliseconds. | ||
* @default 3600000 | ||
*/ | ||
timeToLive?: number; | ||
|
||
/** | ||
* @description | ||
* The maximum number of requests that can be queued. | ||
* @default 100 | ||
*/ | ||
maxQueueSize?: number; | ||
|
||
/** | ||
* @description | ||
* The maximum number of times a queued request can be retried. | ||
* @default 0 | ||
*/ | ||
maxRetryCount?: number; | ||
|
||
} |
15 changes: 15 additions & 0 deletions
15
projects/ngx-http-repository/src/lib/decorator/http-offline-queue.decorator.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { HttpOfflineQueueContext } from '../configuration/context/http-offline-queue-context.configuration'; | ||
import { HTTP_OFFLINE_QUEUE_METADATA_KEY, HttpOfflineQueue } from './http-offline-queue.decorator'; | ||
|
||
describe('HttpOfflineQueueDecorator', () => { | ||
|
||
it('should place http offline queue context in metadata', () => { | ||
const obj: unknown = {}; | ||
const context: HttpOfflineQueueContext = { | ||
timeToLive: 6000 | ||
}; | ||
|
||
HttpOfflineQueue(context)(obj); | ||
expect(Reflect.getMetadata(HTTP_OFFLINE_QUEUE_METADATA_KEY, obj)).toEqual(context); | ||
}); | ||
}); |
12 changes: 12 additions & 0 deletions
12
projects/ngx-http-repository/src/lib/decorator/http-offline-queue.decorator.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { HttpOfflineQueueContext } from '../configuration/context/http-offline-queue-context.configuration'; | ||
|
||
/** | ||
* @ignore | ||
*/ | ||
export const HTTP_OFFLINE_QUEUE_METADATA_KEY: string = 'ngx-http-repository:http-offline-queue'; | ||
|
||
export function HttpOfflineQueue(params: HttpOfflineQueueContext): (target: unknown) => void { | ||
return (target: unknown): void => { | ||
Reflect.defineMetadata(HTTP_OFFLINE_QUEUE_METADATA_KEY, params, target); | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters