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
2 changes: 2 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ OPENAI_API_KEY=""
NEXT_PUBLIC_DISCORD_SUPPORT=""
NEXT_PUBLIC_POLOTNO=""
# NOT_SECURED=false

# POSTIZ_ACTIVE_PROVIDERS=
API_LIMIT=30 # The limit of the public API hour limit

# When connecting providers that take a self-hosted URL (WordPress, Mastodon,
Expand Down
20 changes: 19 additions & 1 deletion libraries/nestjs-libraries/src/temporal/temporal.module.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
import { TemporalModule } from 'nestjs-temporal-core';
import { socialIntegrationList } from '@gitroom/nestjs-libraries/integrations/integration.manager';

function parseActiveProviders(): Set<string> | null {
const raw = process.env.POSTIZ_ACTIVE_PROVIDERS;
if (!raw || !raw.trim()) return null;
return new Set(
raw.split(',').map((p) => p.trim().toLowerCase()).filter(Boolean)
);
}

export const getTemporalModule = (
isWorkers: boolean,
path?: string,
Expand All @@ -23,6 +31,10 @@ export const getTemporalModule = (
Number(process.env.WORKER_CONCURRENCY_DIVIDER) || 1
);

// Providers this server should run workers for (comma-separated).
// Unset => all providers (backwards-compatible default).
const activeProviders = parseActiveProviders();

return TemporalModule.register({
isGlobal: true,
connection: {
Expand All @@ -46,7 +58,13 @@ export const getTemporalModule = (
integration,
taskQueue: integration.identifier.split('-')[0],
}))
.filter(({ taskQueue }) => !excludeQueues.includes(taskQueue))
.filter(
({ taskQueue }) =>
!excludeQueues.includes(taskQueue) &&
(taskQueue === 'main' ||
activeProviders === null ||
activeProviders.has(taskQueue))
)
.map(({ integration, taskQueue }) => {
// Split the per-provider cap across the servers sharing this
// queue. Floor (never below 1) so the global total never exceeds
Expand Down