* Creates an instance of Server. * * @param {BlobConfiguration} configuration * @memberof Server
(configuration?: QueueConfiguration)
| 51 | * @memberof Server |
| 52 | */ |
| 53 | constructor(configuration?: QueueConfiguration) { |
| 54 | if (configuration === undefined) { |
| 55 | configuration = new QueueConfiguration(); |
| 56 | } |
| 57 | |
| 58 | const host = configuration.host; |
| 59 | const port = configuration.port; |
| 60 | |
| 61 | // We can create a HTTP server or a HTTPS server here |
| 62 | let httpServer; |
| 63 | const certOption = configuration.hasCert(); |
| 64 | switch (certOption) { |
| 65 | case CertOptions.PEM: |
| 66 | case CertOptions.PFX: |
| 67 | httpServer = https.createServer(configuration.getCert(certOption)!); |
| 68 | break; |
| 69 | default: |
| 70 | httpServer = http.createServer(); |
| 71 | } |
| 72 | |
| 73 | if (configuration.keepAliveTimeout > 0) { |
| 74 | httpServer.keepAliveTimeout = configuration.keepAliveTimeout * 1000 |
| 75 | } |
| 76 | |
| 77 | // We can change the persistency layer implementation by |
| 78 | // creating a new XXXDataStore class implementing IBlobDataStore interface |
| 79 | // and replace the default LokiBlobDataStore |
| 80 | const metadataStore: IQueueMetadataStore = new LokiQueueMetadataStore( |
| 81 | configuration.metadataDBPath, |
| 82 | configuration.isMemoryPersistence |
| 83 | ); |
| 84 | |
| 85 | const extentMetadataStore = new LokiExtentMetadataStore( |
| 86 | configuration.extentDBPath, |
| 87 | configuration.isMemoryPersistence |
| 88 | ); |
| 89 | |
| 90 | const extentStore: IExtentStore = configuration.isMemoryPersistence ? new MemoryExtentStore( |
| 91 | "queue", |
| 92 | configuration.memoryStore ?? SharedChunkStore, |
| 93 | extentMetadataStore, |
| 94 | logger, |
| 95 | (sc, er, em, ri) => new StorageError(sc, er, em, ri) |
| 96 | ) : new FSExtentStore( |
| 97 | extentMetadataStore, |
| 98 | configuration.persistencePathArray, |
| 99 | logger |
| 100 | ); |
| 101 | |
| 102 | const accountDataStore: IAccountDataStore = new AccountDataStore(logger); |
| 103 | |
| 104 | // We can also change the HTTP framework here by |
| 105 | // creating a new XXXListenerFactory implementing IRequestListenerFactory interface |
| 106 | // and replace the default Express based request listener |
| 107 | const requestListenerFactory: IRequestListenerFactory = new QueueRequestListenerFactory( |
| 108 | metadataStore, |
| 109 | extentStore, |
| 110 | accountDataStore, |
nothing calls this directly
no test coverage detected