mirror of
https://github.com/dadosfera/maestro.git
synced 2026-09-29 16:04:48 +00:00
42 lines
1.1 KiB
TypeScript
42 lines
1.1 KiB
TypeScript
import { credentials } from '@grpc/grpc-js';
|
|
import {
|
|
ClientsProviderAsyncOptions,
|
|
GrpcOptions,
|
|
Transport,
|
|
} from '@nestjs/microservices';
|
|
import {
|
|
ProtoPackages,
|
|
ProtoPaths,
|
|
} from '@dadosfera/protospack-v2/dist/lib/Duc';
|
|
|
|
const isLocalConnection =
|
|
process.env.DUC_URL.startsWith('duc:') ||
|
|
process.env.DUC_URL.includes('0.0.0.0');
|
|
|
|
export class DucClient {
|
|
public name = 'DucClient';
|
|
|
|
private config: GrpcOptions = {
|
|
transport: Transport.GRPC,
|
|
options: {
|
|
url: process.env.DUC_URL,
|
|
package: [ProtoPackages.WritePackage, ProtoPackages.ReadPackage],
|
|
credentials: isLocalConnection ? undefined : credentials.createSsl(),
|
|
protoPath: [ProtoPaths.WriteFilePath, ProtoPaths.ReadFilePath],
|
|
loader: {
|
|
keepCase: true,
|
|
enums: String,
|
|
objects: true,
|
|
arrays: true,
|
|
},
|
|
maxSendMessageLength: 15 * 1024 * 1024, // 15 MB por mensagem
|
|
maxReceiveMessageLength: 15 * 1024 * 1024,
|
|
},
|
|
};
|
|
|
|
providerOptions: ClientsProviderAsyncOptions = {
|
|
name: this.name,
|
|
...this.config,
|
|
};
|
|
}
|