@mamindom/common 1.0.121 → 1.0.122

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -6,6 +6,7 @@ export declare class GrpcClientFactory {
6
6
  protoPath: string | string[];
7
7
  url: string;
8
8
  channelOptions?: Record<string, any>;
9
+ defaultTimeout?: string;
9
10
  }): ClientGrpc;
10
11
  register(token: string, client: ClientGrpc): void;
11
12
  getClient<T extends ClientGrpc = ClientGrpc>(token: string): T;
@@ -55,14 +55,21 @@ let GrpcClientFactory = (() => {
55
55
  createClient(options) {
56
56
  const channelOptions = {
57
57
  'grpc.service_config': JSON.stringify({
58
- loadBalancingConfig: [{ round_robin: {} }]
58
+ loadBalancingConfig: [{ round_robin: {} }],
59
+ methodConfig: [
60
+ {
61
+ name: [{}],
62
+ timeout: options.defaultTimeout ?? '10s'
63
+ }
64
+ ]
59
65
  }),
60
66
  ...options.channelOptions
61
67
  };
68
+ const { defaultTimeout: _defaultTimeout, ...grpcOptions } = options;
62
69
  return microservices_1.ClientProxyFactory.create({
63
70
  transport: microservices_1.Transport.GRPC,
64
71
  options: {
65
- ...options,
72
+ ...grpcOptions,
66
73
  channelOptions,
67
74
  loader: {
68
75
  keepCase: false,
@@ -69,6 +69,7 @@ let GrpcModule = (() => {
69
69
  package: cfg.package,
70
70
  protoPath: cfg.protoPath,
71
71
  url,
72
+ defaultTimeout: cfg.timeout,
72
73
  channelOptions: {
73
74
  'grpc.max_receive_message_length': 1024 * 1024 * 50, // 50 MB
74
75
  'grpc.max_send_message_length': 1024 * 1024 * 50 // 50 MB
@@ -33,6 +33,7 @@ export declare const GRPC_CLIENTS: {
33
33
  readonly package: "media.v1";
34
34
  readonly protoPath: readonly [string];
35
35
  readonly env: "MEDIA_GRPC_URL";
36
+ readonly timeout: "60s";
36
37
  };
37
38
  readonly PROMO_PACKAGE: {
38
39
  readonly package: "promo.v1";
@@ -52,7 +52,8 @@ exports.GRPC_CLIENTS = {
52
52
  MEDIA_PACKAGE: {
53
53
  package: 'media.v1',
54
54
  protoPath: [contracts_1.PROTO_PATHS.MEDIA],
55
- env: 'MEDIA_GRPC_URL'
55
+ env: 'MEDIA_GRPC_URL',
56
+ timeout: '60s'
56
57
  },
57
58
  PROMO_PACKAGE: {
58
59
  package: 'promo.v1',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mamindom/common",
3
- "version": "1.0.121",
3
+ "version": "1.0.122",
4
4
  "type": "commonjs",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -23,7 +23,7 @@
23
23
  "typescript": "^5.9.3"
24
24
  },
25
25
  "dependencies": {
26
- "@mamindom/contracts": "^1.0.150",
26
+ "@mamindom/contracts": "^1.0.152",
27
27
  "@nestjs/common": "^11.1.16",
28
28
  "@nestjs/config": "^4.0.3",
29
29
  "@nestjs/microservices": "^11.1.16"