Add support for jobs & queueables, migrations
- Create migration directives & migrators - Modify Cache classes to support array manipulation - Create Redis unit and RedisCache implementation - Create Queueable base class and Queue class that uses Cache backend
This commit is contained in:
61
src/support/CanonicalReceiver.ts
Normal file
61
src/support/CanonicalReceiver.ts
Normal file
@@ -0,0 +1,61 @@
|
||||
import {AppClass} from '../lifecycle/AppClass'
|
||||
|
||||
/**
|
||||
* Interface for a class that receives its canonical resolver names upon load.
|
||||
*/
|
||||
export interface CanonicalReceiver {
|
||||
setCanonicalResolver(fullyQualifiedResolver: string, unqualifiedResolver: string): void
|
||||
getCanonicalResolver(): string | undefined
|
||||
getFullyQualifiedCanonicalResolver(): string | undefined
|
||||
}
|
||||
|
||||
/**
|
||||
* Function that checks whether a given value satisfies the CanonicalReceiver interface.
|
||||
* @param something
|
||||
*/
|
||||
export function isCanonicalReceiver(something: unknown): something is CanonicalReceiver {
|
||||
return (
|
||||
typeof something === 'function'
|
||||
&& typeof (something as any).setCanonicalResolver === 'function'
|
||||
&& (something as any).setCanonicalResolver.length >= 1
|
||||
&& typeof (something as any).getCanonicalResolver === 'function'
|
||||
&& (something as any).getCanonicalResolver.length === 0
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Base class for canonical items that implements the CanonicalReceiver interface.
|
||||
* That is, `isCanonicalReceiver(CanonicalItemClass) === true`.
|
||||
*/
|
||||
export class CanonicalItemClass extends AppClass {
|
||||
/** The type-prefixed canonical resolver of this class, set by the startup unit. */
|
||||
private static canonFullyQualifiedResolver?: string
|
||||
|
||||
/** The unqualified canonical resolver of this class, set by the startup unit. */
|
||||
private static canonUnqualifiedResolver?: string
|
||||
|
||||
/**
|
||||
* Sets the fully- and un-qualified canonical resolver strings. Intended for use
|
||||
* by the Canonical unit.
|
||||
* @param fullyQualifiedResolver
|
||||
* @param unqualifiedResolver
|
||||
*/
|
||||
public static setCanonicalResolver(fullyQualifiedResolver: string, unqualifiedResolver: string): void {
|
||||
this.canonFullyQualifiedResolver = fullyQualifiedResolver
|
||||
this.canonUnqualifiedResolver = unqualifiedResolver
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the fully-qualified canonical resolver of this class, if one has been set.
|
||||
*/
|
||||
public static getFullyQualifiedCanonicalResolver(): string | undefined {
|
||||
return this.canonFullyQualifiedResolver
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the unqualified canonical resolver of this class, if one has been set.
|
||||
*/
|
||||
public static getCanonicalResolver(): string | undefined {
|
||||
return this.canonUnqualifiedResolver
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user