Skip to content

Commit

Permalink
Disable GRPC code
Browse files Browse the repository at this point in the history
It is currently unused
  • Loading branch information
synzen committed Feb 3, 2025
1 parent 32120d4 commit 6bc9969
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 50 deletions.
27 changes: 13 additions & 14 deletions services/feed-requests/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand All @@ -31,18 +30,18 @@ async function startApi() {
const microservice =
await NestFactory.createMicroservice<MicroserviceOptions>(
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();
Expand Down
56 changes: 27 additions & 29 deletions services/user-feeds/src/feed-fetcher/feed-fetcher.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string>(
"USER_FEEDS_FEED_REQUESTS_GRPC_URL"
);
const useTls =
configService.getOrThrow<string>(
"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<string>(
// "USER_FEEDS_FEED_REQUESTS_GRPC_URL"
// );
// const useTls =
// configService.getOrThrow<string>(
// "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],
// },
],
}),
],
Expand Down
10 changes: 3 additions & 7 deletions services/user-feeds/src/feed-fetcher/feed-fetcher.service.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand All @@ -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";
Expand All @@ -28,18 +27,15 @@ 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"
);
this.API_KEY = configService.getOrThrow("USER_FEEDS_FEED_REQUESTS_API_KEY");
}

onModuleInit() {
this.feedFetcherGrpcPackage = this.client.getService("FeedFetcherGrpc");
// this.feedFetcherGrpcPackage = this.client.getService("FeedFetcherGrpc");
}

async fetch(
Expand Down

0 comments on commit 6bc9969

Please sign in to comment.