chore: add public api annotation on microservices

This commit is contained in:
Tony133
2024-05-05 15:18:04 +02:00
parent 1db72fd96a
commit 151806b621
18 changed files with 69 additions and 0 deletions

View File

@@ -1,3 +1,6 @@
/**
* @publicApi
*/
export class BaseRpcContext<T = unknown[]> {
constructor(protected readonly args: T) {}

View File

@@ -10,6 +10,9 @@ type KafkaContextArgs = [
producer: Producer,
];
/**
* @publicApi
*/
export class KafkaContext extends BaseRpcContext<KafkaContextArgs> {
constructor(args: KafkaContextArgs) {
super(args);

View File

@@ -2,6 +2,9 @@ import { BaseRpcContext } from './base-rpc.context';
type MqttContextArgs = [string, Record<string, any>];
/**
* @publicApi
*/
export class MqttContext extends BaseRpcContext<MqttContextArgs> {
constructor(args: MqttContextArgs) {
super(args);

View File

@@ -2,6 +2,9 @@ import { BaseRpcContext } from './base-rpc.context';
type NatsContextArgs = [string, any];
/**
* @publicApi
*/
export class NatsContext extends BaseRpcContext<NatsContextArgs> {
constructor(args: NatsContextArgs) {
super(args);

View File

@@ -2,6 +2,9 @@ import { BaseRpcContext } from './base-rpc.context';
type RedisContextArgs = [string];
/**
* @publicApi
*/
export class RedisContext extends BaseRpcContext<RedisContextArgs> {
constructor(args: RedisContextArgs) {
super(args);

View File

@@ -2,6 +2,9 @@ import { BaseRpcContext } from './base-rpc.context';
type RmqContextArgs = [Record<string, any>, any, string];
/**
* @publicApi
*/
export class RmqContext extends BaseRpcContext<RmqContextArgs> {
constructor(args: RmqContextArgs) {
super(args);

View File

@@ -3,6 +3,9 @@ import { BaseRpcContext } from './base-rpc.context';
type TcpContextArgs = [TcpSocket, string];
/**
* @publicApi
*/
export class TcpContext extends BaseRpcContext<TcpContextArgs> {
constructor(args: TcpContextArgs) {
super(args);

View File

@@ -1,3 +1,6 @@
/**
* @publicApi
*/
export interface MqttRecordOptions {
/**
* The QoS
@@ -26,6 +29,9 @@ export interface MqttRecordOptions {
};
}
/**
* @publicApi
*/
export class MqttRecord<TData = any> {
constructor(
public readonly data: TData,
@@ -33,6 +39,9 @@ export class MqttRecord<TData = any> {
) {}
}
/**
* @publicApi
*/
export class MqttRecordBuilder<TData> {
private options?: MqttRecordOptions;

View File

@@ -1,3 +1,6 @@
/**
* @publicApi
*/
export class NatsRecord<TData = any, THeaders = any> {
constructor(
public readonly data: TData,
@@ -5,6 +8,9 @@ export class NatsRecord<TData = any, THeaders = any> {
) {}
}
/**
* @publicApi
*/
export class NatsRecordBuilder<TData> {
private headers?: any;

View File

@@ -1,3 +1,6 @@
/**
* @publicApi
*/
export interface RmqRecordOptions {
expiration?: string | number;
userId?: string;
@@ -16,6 +19,9 @@ export interface RmqRecordOptions {
appId?: string;
}
/**
* @publicApi
*/
export class RmqRecord<TData = any> {
constructor(
public readonly data: TData,
@@ -23,6 +29,9 @@ export class RmqRecord<TData = any> {
) {}
}
/**
* @publicApi
*/
export class RmqRecordBuilder<TData> {
private options?: RmqRecordOptions;

View File

@@ -42,6 +42,9 @@ interface GrpcCall<TRequest = any, TMetadata = any> {
emit: Function;
}
/**
* @publicApi
*/
export class ServerGrpc extends Server implements CustomTransportStrategy {
public readonly transportId = Transport.GRPC;

View File

@@ -36,6 +36,9 @@ import { Server } from './server';
let kafkaPackage: any = {};
/**
* @publicApi
*/
export class ServerKafka extends Server implements CustomTransportStrategy {
public readonly transportId = Transport.KAFKA;

View File

@@ -26,6 +26,9 @@ import { Server } from './server';
let mqttPackage: any = {};
/**
* @publicApi
*/
export class ServerMqtt extends Server implements CustomTransportStrategy {
public readonly transportId = Transport.MQTT;

View File

@@ -13,6 +13,9 @@ import { Server } from './server';
let natsPackage = {} as any;
/**
* @publicApi
*/
export class ServerNats extends Server implements CustomTransportStrategy {
public readonly transportId = Transport.NATS;

View File

@@ -19,6 +19,9 @@ type Redis = any;
let redisPackage = {} as any;
/**
* @publicApi
*/
export class ServerRedis extends Server implements CustomTransportStrategy {
public readonly transportId = Transport.REDIS;

View File

@@ -36,6 +36,9 @@ let rmqPackage: any = {};
const INFINITE_CONNECTION_ATTEMPTS = -1;
/**
* @publicApi
*/
export class ServerRMQ extends Server implements CustomTransportStrategy {
public readonly transportId = Transport.RMQ;

View File

@@ -26,6 +26,9 @@ import {
import { TcpOptions } from '../interfaces/microservice-configuration.interface';
import { Server } from './server';
/**
* @publicApi
*/
export class ServerTCP extends Server implements CustomTransportStrategy {
public readonly transportId = Transport.TCP;

View File

@@ -34,6 +34,9 @@ import { ConsumerSerializer } from '../interfaces/serializer.interface';
import { IdentitySerializer } from '../serializers/identity.serializer';
import { transformPatternToRoute } from '../utils';
/**
* @publicApi
*/
export abstract class Server {
protected readonly messageHandlers = new Map<string, MessageHandler>();
protected readonly logger: LoggerService = new Logger(Server.name);