Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions .env.default
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,6 @@ SCHEDULER_REDIS_PORT=6379
SCHEDULER_REDIS_PASSWORD=sOmE_sEcUrE_pAsS
SCHEDULER_REDIS_USE_TLS=false

# AMQP
AMQP_HOSTNAME=localhost
AMQP_PORT=5672
AMQP_USERNAME=guest
AMQP_PASSWORD=guest
AMQP_USE_TLS=false

# jobs
DELETE_OLD_USERS_JOB_PERIOD_IN_SECS=60000
Expand Down
1 change: 0 additions & 1 deletion .env.docker-test
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ APP_ENV=production
DATABASE_URL=postgresql://serviceuser:pass@postgres:5432/service_db?application_name=new_service
REDIS_HOST=redis
SCHEDULER_REDIS_HOST=redis
AMQP_HOSTNAME=rabbitmq
AWS_ENDPOINT=http://fauxqs:4566
AWS_SNS_ENDPOINT=http://fauxqs:4566
AWS_SQS_ENDPOINT=http://fauxqs:4566
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ are relevant for the technological stack of your organization, and replace `@lok
docker compose up -d
```

This starts PostgreSQL, Redis, RabbitMQ, and [fauxqs](https://github.com/kibertoad/fauxqs) (local SQS/SNS emulator).
This starts PostgreSQL, Redis, and [fauxqs](https://github.com/kibertoad/fauxqs) (local SQS/SNS emulator).

- Database is initialized via [scripts/db/init-dbs.sh](./scripts/db/init-dbs.sh).
- SQS/SNS queues, topics, and subscriptions are initialized via [scripts/fauxqs-init.json](./scripts/fauxqs-init.json).
Expand Down
16 changes: 0 additions & 16 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,6 @@ services:
volumes:
- redis_data:/redis/data:cached

rabbitmq:
image: rabbitmq:3.13.7-management
ports:
- ${DOCKER_RABBITMQ_CLIENT_PORT:-5672}:5672
- ${DOCKER_RABBITMQ_MANAGEMENT_PORT:-15672}:15672
healthcheck:
test: ["CMD-SHELL", "rabbitmq-diagnostics check_port_connectivity || exit 1"]
interval: 5s
timeout: 10s
retries: 15
start_period: 15s
volumes:
- rabbit_data:/var/lib/rabbitmq

# Built-in healthcheck is defined in the fauxqs Docker image
fauxqs:
image: kibertoad/fauxqs:latest
Expand All @@ -57,5 +43,3 @@ services:
volumes:
redis_data:
driver: local
rabbit_data:
driver: local
30 changes: 0 additions & 30 deletions docs/environment-variables.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,36 +145,6 @@
Description: Scheduler initial connection timeout in milliseconds
Min value: `0`

## Amqp

- `AMQP_HOSTNAME` (required)
Type: `string`
Description: AMQP broker hostname

- `AMQP_PORT` (required)
Type: `integer`
Description: AMQP broker port
Min value: `1`
Max value: `65535`

- `AMQP_USERNAME` (required)
Type: `string`
Description: AMQP broker username

- `AMQP_PASSWORD` (required)
Type: `string`
Description: AMQP broker password

- `AMQP_VHOST` (optional)
Type: `string`
Description: AMQP broker virtual host
Default: ``

- `AMQP_USE_TLS` (optional)
Type: `boolean`
Description: Whether to use TLS/SSL for AMQP connection
Default: `true`

## Aws

- `AWS_REGION` (required)
Expand Down
2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@
"@lokalise/opentelemetry-fastify-bootstrap": "^3.0.0",
"@lokalise/universal-ts-utils": "^4.10.0",
"@lokalise/zod-extras": "^3.0.2",
"@message-queue-toolkit/amqp": "^24.1.0",
"@message-queue-toolkit/core": "^26.1.0",
"@message-queue-toolkit/metrics": "^4.4.2",
"@message-queue-toolkit/schemas": "^7.2.0",
Expand All @@ -77,7 +76,6 @@
"@opentelemetry/exporter-trace-otlp-grpc": "0.218.0",
"@opentelemetry/instrumentation": "^0.218.0",
"@scalar/fastify-api-reference": "^1.59.3",
"amqplib": "^2.0.1",
"awilix": "^13.0.3",
"awilix-manager": "^7.0.0",
"bullmq": "^5.78.0",
Expand Down
29 changes: 0 additions & 29 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

75 changes: 0 additions & 75 deletions src/infrastructure/AbstractRabbitMQTopicConsumer.ts

This file was deleted.

59 changes: 1 addition & 58 deletions src/infrastructure/CommonModule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,8 @@ import {
HealthcheckResultsStore,
} from '@lokalise/healthcheck-utils'
import type { CommonLogger, ErrorReporter } from '@lokalise/node-core'
import {
type AmqpAwareEventDefinition,
AmqpConnectionManager,
AmqpConsumerErrorResolver,
type AmqpTopicPublisherManager,
type CommonAmqpTopicPublisher,
} from '@message-queue-toolkit/amqp'
import { EventRegistry } from '@message-queue-toolkit/core'
import { SnsConsumerErrorResolver } from '@message-queue-toolkit/sns'
import type { Connection } from 'amqplib'
import { Lifetime, type NameAndRegistrationPair, type Resolver } from 'awilix'
import type { NameAndRegistrationPair, Resolver } from 'awilix'
import { drizzle, type PostgresJsDatabase } from 'drizzle-orm/postgres-js'
import { Redis } from 'ioredis'
import {
Expand All @@ -33,26 +24,21 @@ import {
type DependencyInjectionOptions,
type InferModuleDependencies,
type InferPublicModuleDependencies,
isAnyMessageQueueConsumerEnabled,
isPeriodicJobEnabled,
resolveJobQueuesEnabled,
} from 'opinionated-machine'
import { ToadScheduler } from 'toad-scheduler'
import type { z } from 'zod/v4'
import type { AppInstance } from '../app.ts'
import { FakeStoreApiClient } from '../integrations/FakeStoreApiClient.ts'
import { PermissionsMessages } from '../modules/users/consumers/permissionsMessageSchemas.ts'
import { type UsersModuleDependencies, userBullmqQueues } from '../modules/users/UserModule.ts'
import { type Config, getConfig, nodeEnv, SERVICE_NAME } from './config.ts'
import { FakeAmplitude } from './fakes/FakeAmplitude.ts'
import { DbHealthcheck, RedisHealthcheck } from './healthchecks/healthchecks.ts'
import { MessageProcessingMetricsManager } from './metrics/MessageProcessingMetricsManager.ts'
import { PublisherManagerAdapter } from './PublisherManagerAdapter.ts'

export type ExternalDependencies = {
app?: AppInstance
logger: CommonLogger
amqpConnection?: Connection
}
export type DependencyOverrides = Partial<DiConfig>
export type Dependencies = CommonDependencies & UsersModuleDependencies
Expand All @@ -63,18 +49,6 @@ declare module '@fastify/awilix' {
interface RequestCradle extends Dependencies {}
}

const amqpSupportedMessages = [
...Object.values(PermissionsMessages),
] as const satisfies AmqpAwareEventDefinition[]
export type AmqpSupportedMessages = typeof amqpSupportedMessages

export type MessagesPublishPayloadsType = z.infer<AmqpSupportedMessages[number]['publisherSchema']>

export type PublisherManager = AmqpTopicPublisherManager<
CommonAmqpTopicPublisher<MessagesPublishPayloadsType>,
AmqpSupportedMessages
>

const bullmqSupportedQueues = [
...userBullmqQueues,
] as const satisfies ModuleAwareQueueConfiguration[]
Expand Down Expand Up @@ -228,28 +202,6 @@ export class CommonModule extends AbstractModule<unknown, ExternalDependencies>
},
),

amqpConnectionManager: asSingletonFunction(
({ config }: { config: CommonDependencies['config'] }): AmqpConnectionManager => {
return new AmqpConnectionManager(config.amqp, externalDependencies.logger)
},
{
public: true,
lifetime: Lifetime.SINGLETON,
asyncInit: 'init',
asyncDispose: 'close',
asyncInitPriority: 1,
asyncDisposePriority: 1,
enabled: isAnyMessageQueueConsumerEnabled(diOptions),
},
),

consumerErrorResolver: asSingletonFunction(
() => {
return new AmqpConsumerErrorResolver()
},
{ public: true },
),

sqsClient: asSingletonFunction(
({ config }: { config: Config }) => {
return new SQSClient({
Expand Down Expand Up @@ -305,15 +257,6 @@ export class CommonModule extends AbstractModule<unknown, ExternalDependencies>
{ public: true },
),

eventRegistry: asSingletonFunction(
() => {
return new EventRegistry(amqpSupportedMessages)
},
{ public: true },
),

publisherManager: asSingletonClass(PublisherManagerAdapter, { public: true }),

config: asSingletonFunction(() => getConfig(), { public: true }),

// vendor-specific dependencies
Expand Down
Loading
Loading