-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: create constants, queue types and methods
- Loading branch information
Showing
8 changed files
with
146 additions
and
2 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,3 +7,4 @@ | |
|
||
export * from './builder'; | ||
export * from './core'; | ||
export * from './master-images'; |
36 changes: 36 additions & 0 deletions
36
packages/server-analysis-manager-kit/src/components/master-images/constants.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,36 @@ | ||
/* | ||
* Copyright (c) 2023-2024. | ||
* Author Peter Placzek (tada5hi) | ||
* For the full copyright and license information, | ||
* view the LICENSE file that was distributed with this source code. | ||
*/ | ||
|
||
import { QueueRouterRoutingType } from '@privateaim/server-kit'; | ||
|
||
export enum MasterImagesEvent { | ||
SYNCHRONISING = 'synchronizing', | ||
SYNCHRONIZED = 'synchronized', | ||
SYNCHRONIZATION_FAILED = 'synchronizationFailed', | ||
|
||
BUILDING = 'building', | ||
BUILT = 'built', | ||
BUILD_FAILED = 'buildFailed', | ||
|
||
PUSHING = 'pushing', | ||
PUSHED = 'pushed', | ||
PUSH_FAILED = 'pushFailed', | ||
} | ||
|
||
export enum MasterImagesCommand { | ||
SYNCHRONIZE = 'synchronize', | ||
} | ||
|
||
export const MasterImagesEventQueueRouterRouting = { | ||
type: QueueRouterRoutingType.PUB_SUB, | ||
key: 'analysisMasterImagesEvents', | ||
}; | ||
|
||
export const MasterImagesTaskQueueRouterRouting = { | ||
type: QueueRouterRoutingType.WORK, | ||
key: 'analysisMasterImagesCommands', | ||
}; |
10 changes: 10 additions & 0 deletions
10
packages/server-analysis-manager-kit/src/components/master-images/index.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,10 @@ | ||
/* | ||
* Copyright (c) 2024. | ||
* Author Peter Placzek (tada5hi) | ||
* For the full copyright and license information, | ||
* view the LICENSE file that was distributed with this source code. | ||
*/ | ||
|
||
export * from './constants'; | ||
export * from './queue'; | ||
export * from './types'; |
36 changes: 36 additions & 0 deletions
36
packages/server-analysis-manager-kit/src/components/master-images/queue.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,36 @@ | ||
/* | ||
* Copyright (c) 2023-2024. | ||
* Author Peter Placzek (tada5hi) | ||
* For the full copyright and license information, | ||
* view the LICENSE file that was distributed with this source code. | ||
*/ | ||
|
||
import type { QueueRouterPayload } from '@privateaim/server-kit'; | ||
import { buildQueueRouterPublishPayload } from '@privateaim/server-kit'; | ||
import { cleanupPayload } from '../../utils'; | ||
import { MasterImagesEventQueueRouterRouting, MasterImagesTaskQueueRouterRouting } from './constants'; | ||
import type { MasterImagesCommandContext, MasterImagesEventContext } from './types'; | ||
|
||
export function buildMasterImagesTaskQueueRouterPayload( | ||
context: MasterImagesCommandContext, | ||
) : QueueRouterPayload { | ||
return buildQueueRouterPublishPayload({ | ||
type: context.command, | ||
data: cleanupPayload(context.data), | ||
metadata: { | ||
routing: MasterImagesTaskQueueRouterRouting, | ||
}, | ||
}); | ||
} | ||
|
||
export function buildMasterImagesEventQueueRouterPayload( | ||
context: MasterImagesEventContext, | ||
) : QueueRouterPayload { | ||
return buildQueueRouterPublishPayload({ | ||
type: context.event, | ||
data: cleanupPayload(context.data), | ||
metadata: { | ||
routing: MasterImagesEventQueueRouterRouting, | ||
}, | ||
}); | ||
} |
56 changes: 56 additions & 0 deletions
56
packages/server-analysis-manager-kit/src/components/master-images/types.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,56 @@ | ||
/* | ||
* Copyright (c) 2023-2024. | ||
* Author Peter Placzek (tada5hi) | ||
* For the full copyright and license information, | ||
* view the LICENSE file that was distributed with this source code. | ||
*/ | ||
|
||
import type { Group, Image } from 'docker-scan'; | ||
import type { MasterImagesCommand, MasterImagesEvent } from './constants'; | ||
|
||
export type MasterImagesBasePayload = { | ||
error?: Error | ||
}; | ||
|
||
export type MasterImagesSynchronizeCommandContext = { | ||
command: `${MasterImagesCommand.SYNCHRONIZE}`, | ||
data: MasterImagesBasePayload, | ||
}; | ||
|
||
export type MaterImagesSynchronizedPayload = MasterImagesBasePayload & { | ||
images: Image[], | ||
groups: Group[] | ||
}; | ||
export type MasterImagesSynchronizedEventContext = { | ||
data: MaterImagesSynchronizedPayload, | ||
event: `${MasterImagesEvent.SYNCHRONIZED}`; | ||
}; | ||
export type MasterImagesSynchronizingEventContext = { | ||
data: MasterImagesBasePayload, | ||
event: `${MasterImagesEvent.SYNCHRONISING}`; | ||
}; | ||
export type MasterImagesSynchronizationFailedEventContext = { | ||
data: MasterImagesBasePayload, | ||
event: `${MasterImagesEvent.SYNCHRONIZATION_FAILED}`; | ||
}; | ||
|
||
export type MasterImagesBuildEventContext = { | ||
data: MasterImagesBasePayload, | ||
event: `${MasterImagesEvent.BUILD_FAILED}` | | ||
`${MasterImagesEvent.BUILDING}` | | ||
`${MasterImagesEvent.BUILT}`; | ||
}; | ||
|
||
export type MasterImagesPushEventContext = { | ||
data: MasterImagesBasePayload, | ||
event: `${MasterImagesEvent.PUSH_FAILED}` | | ||
`${MasterImagesEvent.PUSHING}` | | ||
`${MasterImagesEvent.PUSHED}`; | ||
}; | ||
|
||
export type MasterImagesCommandContext = MasterImagesSynchronizeCommandContext; | ||
export type MasterImagesEventContext = MasterImagesSynchronizedEventContext | | ||
MasterImagesSynchronizingEventContext | | ||
MasterImagesSynchronizationFailedEventContext | | ||
MasterImagesBuildEventContext | | ||
MasterImagesPushEventContext; |
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