style(messaging): client and server config type definition
MODIFY
packages/messaging/src/client/messaging.client.interface.ts
packages/messaging/src/client/messaging.client.interface.ts
import { Observable } from 'rxjs';
-import { NatsStrategy } from '../transport/strategies/nats.strategy.interface';
-import { TcpStrategy } from '../transport/strategies/tcp.strategy.interface';
-import { AmqpStrategy } from '../transport/strategies/amqp.strategy.interface';
-import { TransportMessageTransformer } from '../transport/transport.interface';
+import { TransportMessageTransformer, TransportStrategy } from '../transport/transport.interface';
export interface MessagingClient {
emit: <T>(data: T) => Observable<boolean>;
@@ -15,7 +12,6 @@ type ConfigurationBase = {
}
export type MessagingClientConfig =
- | AmqpStrategy & ConfigurationBase
- | NatsStrategy & ConfigurationBase
- | TcpStrategy & ConfigurationBase
+ & TransportStrategy
+ & ConfigurationBase
;

MODIFY
packages/messaging/src/server/messaging.server.interface.ts
packages/messaging/src/server/messaging.server.interface.ts
import { BoundDependency } from '@marblejs/core';
-import { NatsStrategy } from '../transport/strategies/nats.strategy.interface';
-import { TcpStrategy } from '../transport/strategies/tcp.strategy.interface';
-import { AmqpStrategy } from '../transport/strategies/amqp.strategy.interface';
import { messagingListener } from './messaging.server.listener';
import { MsgServerEffect } from '../effects/messaging.effects.interface';
+import { TransportStrategy } from '../transport/transport.interface';
type ConfigurationBase = {
messagingListener: ReturnType<typeof messagingListener>;
@@ -12,7 +10,6 @@ type ConfigurationBase = {
}
export type CreateMicroserviceConfig =
- | AmqpStrategy & ConfigurationBase
- | NatsStrategy & ConfigurationBase
- | TcpStrategy & ConfigurationBase
+ & TransportStrategy
+ & ConfigurationBase
;

DELETE
packages/messaging/src/transport/strategies/nats.strategy.interface.ts
-import { Transport } from '../transport.interface';
-
-export interface NatsStrategy {
- transport: Transport.NATS;
- options: NatsStrategyOptions;
-}
-
-export interface NatsStrategyOptions {
- // @TODO
-}

ADD
packages/messaging/src/transport/strategies/redis.strategy.interface.ts
+import { Transport } from '../transport.interface';
+
+export interface RedisStrategy {
+ transport: Transport.REDIS;
+ options: RedisStrategyOptions;
+}
+
+export interface RedisStrategyOptions {
+ // @TODO
+}

RENAME
packages/messaging/src/transport/strategies/nats.strategy.ts
packages/messaging/src/transport/strategies/redis.strategy.ts
import { TransportLayer } from '../transport.interface';
/* istanbul ignore next */
-export const createNatsStrategy = (): TransportLayer => {
+export const createRedisStrategy = (): TransportLayer => {
// @TODO
return {} as any;
};

MODIFY
packages/messaging/src/transport/transport.interface.ts
packages/messaging/src/transport/transport.interface.ts
import { Observable } from 'rxjs';
import { Event } from '@marblejs/core';
+import { RedisStrategy } from './strategies/redis.strategy.interface';
+import { AmqpStrategy } from './strategies/amqp.strategy.interface';
+import { TcpStrategy } from './strategies/tcp.strategy.interface';
export enum Transport {
TCP,
@@ -10,6 +13,12 @@ export enum Transport {
GRPC,
}
+export type TransportStrategy =
+ | AmqpStrategy
+ | RedisStrategy
+ | TcpStrategy
+ ;
+
export interface TransportLayer {
connect: (opts: { isConsumer: boolean }) => Promise<TransportLayerConnection>;
config: TransportLayerConfig;

style(messaging): client and server config type definition