diff --git a/services/feed-requests/src/main.ts b/services/feed-requests/src/main.ts index c9a6ee3c7..bb6203044 100644 --- a/services/feed-requests/src/main.ts +++ b/services/feed-requests/src/main.ts @@ -13,8 +13,7 @@ import { import logger from './utils/logger'; import { MikroORM } from '@mikro-orm/core'; import { RequestContext } from '@mikro-orm/core'; -import { MicroserviceOptions, Transport } from '@nestjs/microservices'; -import { join } from 'path'; +import { MicroserviceOptions } from '@nestjs/microservices'; import compression from '@fastify/compress'; import pruneAndCreatePartitions from './utils/prune-and-create-partitions'; @@ -31,18 +30,18 @@ async function startApi() { const microservice = await NestFactory.createMicroservice( AppModule.forApi(), - { - transport: Transport.GRPC, - options: { - package: 'feedfetcher', - protoPath: join(__dirname, './feed-fetcher/feed-fetcher.proto'), - url: '0.0.0.0:4999', - channelOptions: { - 'grpc.default_compression_algorithm': 2, - 'grpc.default_compression_level': 2, - }, - }, - }, + // { + // transport: Transport.GRPC, + // options: { + // package: 'feedfetcher', + // protoPath: join(__dirname, './feed-fetcher/feed-fetcher.proto'), + // url: '0.0.0.0:4999', + // channelOptions: { + // 'grpc.default_compression_algorithm': 2, + // 'grpc.default_compression_level': 2, + // }, + // }, + // }, ); microservice.enableShutdownHooks(); diff --git a/services/user-feeds/src/feed-fetcher/feed-fetcher.module.ts b/services/user-feeds/src/feed-fetcher/feed-fetcher.module.ts index ed269972f..5be1150c8 100644 --- a/services/user-feeds/src/feed-fetcher/feed-fetcher.module.ts +++ b/services/user-feeds/src/feed-fetcher/feed-fetcher.module.ts @@ -13,35 +13,33 @@ import { FeedFetcherService } from "./feed-fetcher.service"; imports: [ ClientsModule.registerAsync({ clients: [ - { - name: "FEED_FETCHER_PACKAGE", - useFactory: (configService: ConfigService) => { - const url = configService.getOrThrow( - "USER_FEEDS_FEED_REQUESTS_GRPC_URL" - ); - const useTls = - configService.getOrThrow( - "USER_FEEDS_FEED_REQUESTS_GRPC_USE_TLS" - ) === "true"; - - return { - transport: Transport.GRPC, - options: { - url, - package: "feedfetcher", - protoPath: join(__dirname, "feed-fetcher.proto"), - // https://github.com/grpc/grpc-node/issues/2093#issuecomment-1117969843 - credentials: useTls ? credentials.createSsl() : undefined, - channelOptions: { - "grpc.max_receive_message_length": 1024 * 1024 * 100, - "grpc.use_local_subchannel_pool": 1, - }, - }, - }; - }, - - inject: [ConfigService], - }, + // { + // name: "FEED_FETCHER_PACKAGE", + // useFactory: (configService: ConfigService) => { + // const url = configService.getOrThrow( + // "USER_FEEDS_FEED_REQUESTS_GRPC_URL" + // ); + // const useTls = + // configService.getOrThrow( + // "USER_FEEDS_FEED_REQUESTS_GRPC_USE_TLS" + // ) === "true"; + // return { + // transport: Transport.GRPC, + // options: { + // url, + // package: "feedfetcher", + // protoPath: join(__dirname, "feed-fetcher.proto"), + // // https://github.com/grpc/grpc-node/issues/2093#issuecomment-1117969843 + // credentials: useTls ? credentials.createSsl() : undefined, + // channelOptions: { + // "grpc.max_receive_message_length": 1024 * 1024 * 100, + // "grpc.use_local_subchannel_pool": 1, + // }, + // }, + // }; + // }, + // inject: [ConfigService], + // }, ], }), ], diff --git a/services/user-feeds/src/feed-fetcher/feed-fetcher.service.ts b/services/user-feeds/src/feed-fetcher/feed-fetcher.service.ts index 04eb7be69..1d3e9bee3 100644 --- a/services/user-feeds/src/feed-fetcher/feed-fetcher.service.ts +++ b/services/user-feeds/src/feed-fetcher/feed-fetcher.service.ts @@ -1,4 +1,4 @@ -import { Inject, Injectable, OnModuleInit } from "@nestjs/common"; +import { Injectable, OnModuleInit } from "@nestjs/common"; import { ConfigService } from "@nestjs/config"; import { Dispatcher, request } from "undici"; import BodyReadable from "undici/types/readable"; @@ -15,7 +15,6 @@ import { } from "./exceptions"; import { FeedResponse } from "./types"; import pRetry from "p-retry"; -import { ClientGrpc } from "@nestjs/microservices/interfaces"; import { lastValueFrom, Observable } from "rxjs"; import logger from "../shared/utils/logger"; import { Metadata } from "@grpc/grpc-js"; @@ -28,10 +27,7 @@ export class FeedFetcherService implements OnModuleInit { // eslint-disable-next-line @typescript-eslint/no-explicit-any feedFetcherGrpcPackage: any; - constructor( - private readonly configService: ConfigService, - @Inject("FEED_FETCHER_PACKAGE") private client: ClientGrpc - ) { + constructor(private readonly configService: ConfigService) { this.SERVICE_HOST = configService.getOrThrow( "USER_FEEDS_FEED_REQUESTS_API_URL" ); @@ -39,7 +35,7 @@ export class FeedFetcherService implements OnModuleInit { } onModuleInit() { - this.feedFetcherGrpcPackage = this.client.getService("FeedFetcherGrpc"); + // this.feedFetcherGrpcPackage = this.client.getService("FeedFetcherGrpc"); } async fetch(