MCPcopy
hub / github.com/nestjs/nest / startServer

Function startServer

integration/microservices/e2e/concurrent-kafka.spec.ts:25–62  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

23 this.timeout(30000);
24
25 const startServer = async () => {
26 const module = await Test.createTestingModule({
27 controllers: [
28 KafkaConcurrentController,
29 KafkaConcurrentMessagesController,
30 ],
31 }).compile();
32
33 // use our own logger for a little
34 // Logger.overrideLogger(new Logger());
35
36 const app = module.createNestApplication();
37
38 const server = app.getHttpAdapter().getInstance();
39
40 app.connectMicroservice<MicroserviceOptions>({
41 transport: Transport.KAFKA,
42 options: {
43 client: {
44 brokers: ['localhost:9092'],
45 },
46 run: {
47 partitionsConsumedConcurrently: numbersOfServers,
48 },
49 },
50 });
51
52 // enable these for clean shutdown
53 app.enableShutdownHooks();
54
55 // push to the collection
56 servers.push(server);
57 apps.push(app);
58
59 // await the start
60 await app.startAllMicroservices();
61 await app.init();
62 };
63
64 it(`Create kafka topics/partitions`, async () => {
65 const kafka = new Kafka({

Callers 1

Calls 9

createTestingModuleMethod · 0.80
createNestApplicationMethod · 0.80
getInstanceMethod · 0.65
getHttpAdapterMethod · 0.65
connectMicroserviceMethod · 0.65
enableShutdownHooksMethod · 0.65
startAllMicroservicesMethod · 0.65
initMethod · 0.65
compileMethod · 0.45

Tested by

no test coverage detected