Remove unused service registry
This commit is contained in:
1 parent
837c4598ff
commit
4b1e8fb002
6 files changed
+333
-77
No files matched your search
@@ -22,7 +22,6 @@ export { default as StatusService } from "@/services/infrastructure/StatusServic
|
||||
export { default as JobQueue } from "@/services/infrastructure/JobQueue.js";
|
||||
export { default as JobGenerator } from "@/services/infrastructure/JobGenerator.js";
|
||||
|
||||
export { default as ServiceRegistry } from "@/services/system/ServiceRegistry.js";
|
||||
export { default as SettingsService } from "@/services/system/SettingsService.js";
|
||||
export { default as BillingService } from "@/services/system/BillingService.js";
|
||||
export { default as StripeService } from "@/services/system/StripeService.js";
|
||||
|
||||
@@ -1,69 +0,0 @@
|
||||
const SERVICE_NAME = "ServiceRegistry";
|
||||
|
||||
export interface IServiceRegistry {
|
||||
register: (name: string, service: any) => void;
|
||||
get: (name: string) => any;
|
||||
listServices: () => string[];
|
||||
}
|
||||
|
||||
class ServiceRegistry implements IServiceRegistry {
|
||||
public SERVICE_NAME: string;
|
||||
private static _instance: ServiceRegistry;
|
||||
|
||||
private services: { [key: string]: any };
|
||||
|
||||
private constructor() {
|
||||
this.SERVICE_NAME = SERVICE_NAME;
|
||||
this.services = {};
|
||||
}
|
||||
|
||||
static get instance(): ServiceRegistry {
|
||||
if (!this._instance) {
|
||||
this._instance = new ServiceRegistry();
|
||||
}
|
||||
return this._instance;
|
||||
}
|
||||
|
||||
get serviceName() {
|
||||
return this.SERVICE_NAME;
|
||||
}
|
||||
|
||||
// Instance methods
|
||||
register(name: string, service: any) {
|
||||
this.services[name] = service;
|
||||
}
|
||||
|
||||
get(name: string) {
|
||||
if (!this.services[name]) {
|
||||
throw new Error(`Service ${name} is not registered`);
|
||||
}
|
||||
return this.services[name];
|
||||
}
|
||||
|
||||
listServices() {
|
||||
return Object.keys(this.services);
|
||||
}
|
||||
|
||||
static get(name: string) {
|
||||
if (!ServiceRegistry.instance) {
|
||||
throw new Error("ServiceRegistry not initialized");
|
||||
}
|
||||
return ServiceRegistry.instance.get(name);
|
||||
}
|
||||
|
||||
static register(name: string, service: any) {
|
||||
if (!ServiceRegistry.instance) {
|
||||
throw new Error("ServiceRegistry not initialized");
|
||||
}
|
||||
return ServiceRegistry.instance.register(name, service);
|
||||
}
|
||||
|
||||
static listServices() {
|
||||
if (!ServiceRegistry.instance) {
|
||||
throw new Error("ServiceRegistry not initialized");
|
||||
}
|
||||
return ServiceRegistry.instance.listServices();
|
||||
}
|
||||
}
|
||||
|
||||
export default ServiceRegistry;
|
||||
Reference in new issue
Block a user