Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.
TypeScript agentaiai-agentsall-in-onecrmcrm-systememaillinearmcpmessagingnotesnotionofficerustslackslack-alternativestartupstartup-toolstypescriptworkspace
refactor remove redis cluster (#1263)
Will Hutchinson90b0404328be
diff --git a/infra/bun.lock b/infra/bun.lockindex b1ceb4234c..5e9ec0ad5e 100644--- a/infra/bun.lock+++ b/infra/bun.lock@@ -166,10 +166,6 @@"name": "cloud-storage-sha-cleanup-stack","version": "0.0.0",},- "stacks/sha-ref-count-resetter": {- "name": "sha-ref-count-resetter-stack",- "version": "0.0.0",- },"stacks/static-file-service": {"name": "static-file-service-stack","version": "0.0.0",@@ -902,8 +898,6 @@"service": ["service@workspace:packages/service"],- "sha-ref-count-resetter-stack": ["sha-ref-count-resetter-stack@workspace:stacks/sha-ref-count-resetter"],-"shared": ["shared@workspace:packages/shared"],"shebang-command": ["[email protected]", "", { "dependencies": { "shebang-regex": "^3.0.0" } }, "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA=="],diff --git a/infra/stacks/cloud-storage-service/Pulumi.dev.yaml b/infra/stacks/cloud-storage-service/Pulumi.dev.yamlindex 914b8974e1..a93aeeaf1a 100644--- a/infra/stacks/cloud-storage-service/Pulumi.dev.yaml+++ b/infra/stacks/cloud-storage-service/Pulumi.dev.yaml@@ -12,3 +12,4 @@ config:cloud-storage-service:sync_service_auth_key: sync-service-key-devcloud-storage-service:authentication_service_secret_key: authentication-service-internal-api-key-devcloud-storage-service:opensearch_password_key: macro-opensearch-password-dev+ cloud-storage-service:macro_cache_secret_key: macro-cache-devdiff --git a/infra/stacks/cloud-storage-service/Pulumi.prod.yaml b/infra/stacks/cloud-storage-service/Pulumi.prod.yamlindex 11aedc99d6..a2cc7ae655 100644--- a/infra/stacks/cloud-storage-service/Pulumi.prod.yaml+++ b/infra/stacks/cloud-storage-service/Pulumi.prod.yaml@@ -12,3 +12,4 @@ config:cloud-storage-service:sync_service_auth_key: sync-service-key-prodcloud-storage-service:authentication_service_secret_key: authentication-service-internal-api-key-prodcloud-storage-service:opensearch_password_key: macro-opensearch-password-prod+ cloud-storage-service:macro_cache_secret_key: macro-cache-proddiff --git a/infra/stacks/cloud-storage-service/index.ts b/infra/stacks/cloud-storage-service/index.tsindex eb8fda2461..7d9bcfa19f 100644--- a/infra/stacks/cloud-storage-service/index.ts+++ b/infra/stacks/cloud-storage-service/index.ts@@ -30,6 +30,12 @@ const DATABASE_URL = aws.secretsmanager}).apply((secret) => secret.secretString);+const MACRO_CACHE = aws.secretsmanager+ .getSecretVersionOutput({+ secretId: config.require(`macro_cache_secret_key`),+ })+ .apply((secret) => secret.secretString);+const DATABASE_URL_PROXY = aws.secretsmanager.getSecretVersionOutput({secretId: config.require(`macro_db_proxy_secret_key`),@@ -132,10 +138,6 @@ const documentStorageBucketId: pulumi.Output<string> = cloudStorageStack.getOutput('documentStorageBucketId').apply((id) => id as string);-const cloudStorageCacheEndpoint: pulumi.Output<string> = cloudStorageStack- .getOutput('cloudStorageCacheEndpoint')- .apply((arn) => arn as string);-const cloudStorageClusterArn: pulumi.Output<string> = cloudStorageStack.getOutput('cloudStorageClusterArn').apply((arn) => arn as string);@@ -271,7 +273,7 @@ const cloudStorageService = new CloudStorageService(},{name: 'REDIS_URI',- value: pulumi.interpolate`rediss://${cloudStorageCacheEndpoint}`,+ value: pulumi.interpolate`redis://${MACRO_CACHE}`,},{name: 'ENVIRONMENT',@@ -424,7 +426,7 @@ const convertQueueArn: pulumi.Output<string> = convertServiceStack// ------------------------------------------- DOCX Unzip -------------------------------------------const docxUnzipHandlerEnvVars: DocxUnzipLambdaEnvVars = {DATABASE_URL: pulumi.interpolate`${DATABASE_URL_PROXY}`,- REDIS_URI: pulumi.interpolate`rediss://${cloudStorageCacheEndpoint}`,+ REDIS_URI: pulumi.interpolate`redis://${MACRO_CACHE}`,ENVIRONMENT: stack,RUST_LOG: 'docx_unzip_handler=info',DOCUMENT_STORAGE_BUCKET: pulumi.interpolate`${documentStorageBucketId}`,diff --git a/infra/stacks/delete-document-worker/Pulumi.dev.yaml b/infra/stacks/delete-document-worker/Pulumi.dev.yamlindex 1bca4a1dac..d977d547ba 100644--- a/infra/stacks/delete-document-worker/Pulumi.dev.yaml+++ b/infra/stacks/delete-document-worker/Pulumi.dev.yaml@@ -2,6 +2,7 @@ config:aws-native:region: us-east-1aws:region: us-east-1delete-document-worker:macro_db_secret_key: macro-db-dev+ delete-document-worker:macro_cache_secret_key: macro-cache-devdelete-document-worker:sync_service_auth_key: sync-service-key-devdelete-document-worker:comms_service_auth_key: document-storage-service-auth-key-devdelete-document-worker:properties_service_auth_key: document-storage-service-auth-key-devdiff --git a/infra/stacks/delete-document-worker/Pulumi.prod.yaml b/infra/stacks/delete-document-worker/Pulumi.prod.yamlindex ff805fc084..22e97f929f 100644--- a/infra/stacks/delete-document-worker/Pulumi.prod.yaml+++ b/infra/stacks/delete-document-worker/Pulumi.prod.yaml@@ -2,6 +2,7 @@ config:aws-native:region: us-east-1aws:region: us-east-1delete-document-worker:macro_db_secret_key: macro-db-prod+ delete-document-worker:macro_cache_secret_key: macro-cache-proddelete-document-worker:sync_service_auth_key: sync-service-key-proddelete-document-worker:comms_service_auth_key: document-storage-service-auth-key-proddelete-document-worker:properties_service_auth_key: document-storage-service-auth-key-proddiff --git a/infra/stacks/delete-document-worker/index.ts b/infra/stacks/delete-document-worker/index.tsindex 1bdc83f00b..c207066411 100644--- a/infra/stacks/delete-document-worker/index.ts+++ b/infra/stacks/delete-document-worker/index.ts@@ -31,9 +31,11 @@ const documentStorageBucketId: pulumi.Output<string> = cloudStorageStack.getOutput('documentStorageBucketId').apply((id) => id as string);-const cloudStorageCacheEndpoint: pulumi.Output<string> = cloudStorageStack- .getOutput('cloudStorageCacheEndpoint')- .apply((arn) => arn as string);+const MACRO_CACHE = aws.secretsmanager+ .getSecretVersionOutput({+ secretId: config.require(`macro_cache_secret_key`),+ })+ .apply((secret) => secret.secretString);const cloudStorageClusterArn: pulumi.Output<string> = cloudStorageStack.getOutput('cloudStorageClusterArn')@@ -103,7 +105,7 @@ const deleteDocumentWorker = new Worker(`delete-document-worker-${stack}`, {},{name: 'REDIS_URI',- value: pulumi.interpolate`rediss://${cloudStorageCacheEndpoint}`,+ value: pulumi.interpolate`redis://${MACRO_CACHE}`,},{name: 'DOCUMENT_STORAGE_BUCKET',diff --git a/infra/stacks/sha-cleanup/Pulumi.dev.yaml b/infra/stacks/sha-cleanup/Pulumi.dev.yamlindex bf453671f3..cbe7190aa2 100644--- a/infra/stacks/sha-cleanup/Pulumi.dev.yaml+++ b/infra/stacks/sha-cleanup/Pulumi.dev.yaml@@ -2,3 +2,4 @@ config:aws-native:region: us-east-1aws:region: us-east-1cloud-storage-sha-cleanup:macro_db_secret_key: macro-db-dev+ cloud-storage-sha-cleanup:macro_cache_secret_key: macro-cache-devdiff --git a/infra/stacks/sha-cleanup/Pulumi.prod.yaml b/infra/stacks/sha-cleanup/Pulumi.prod.yamlindex ed0d048516..a9a550d7e9 100644--- a/infra/stacks/sha-cleanup/Pulumi.prod.yaml+++ b/infra/stacks/sha-cleanup/Pulumi.prod.yaml@@ -2,3 +2,4 @@ config:aws-native:region: us-east-1aws:region: us-east-1cloud-storage-sha-cleanup:macro_db_secret_key: macro-db-prod+ cloud-storage-sha-cleanup:macro_cache_secret_key: macro-cache-proddiff --git a/infra/stacks/sha-cleanup/index.ts b/infra/stacks/sha-cleanup/index.tsindex c60380967c..35b3436cc8 100644--- a/infra/stacks/sha-cleanup/index.ts+++ b/infra/stacks/sha-cleanup/index.ts@@ -28,9 +28,11 @@ const documentStorageBucketId: pulumi.Output<string> = cloudStorageStack.getOutput('documentStorageBucketId').apply((id) => id as string);-const cloudStorageCacheEndpoint: pulumi.Output<string> = cloudStorageStack- .getOutput('cloudStorageCacheEndpoint')- .apply((arn) => arn as string);+const MACRO_CACHE = aws.secretsmanager+ .getSecretVersionOutput({+ secretId: config.require(`macro_cache_secret_key`),+ })+ .apply((secret) => secret.secretString);const cloudStorageClusterArn: pulumi.Output<string> = cloudStorageStack.getOutput('cloudStorageClusterArn')@@ -40,7 +42,7 @@ const shaCleanupWorker = new ShaWorker('sha-cleanup-worker', {containerEnvVars: [{name: 'REDIS_URI',- value: pulumi.interpolate`rediss://${cloudStorageCacheEndpoint}`,+ value: pulumi.interpolate`redis://${MACRO_CACHE}`,},{name: 'DATABASE_URL',diff --git a/infra/stacks/sha-ref-count-resetter/Pulumi.dev.yaml b/infra/stacks/sha-ref-count-resetter/Pulumi.dev.yamldeleted file mode 100644index 2ed66b0585..0000000000--- a/infra/stacks/sha-ref-count-resetter/Pulumi.dev.yaml+++ /dev/null@@ -1,4 +0,0 @@-config:- aws-native:region: us-east-1- aws:region: us-east-1- sha-ref-count-resetter:macro_db_secret_key: macro-db-devdiff --git a/infra/stacks/sha-ref-count-resetter/Pulumi.prod.yaml b/infra/stacks/sha-ref-count-resetter/Pulumi.prod.yamldeleted file mode 100644index ddfa605bac..0000000000--- a/infra/stacks/sha-ref-count-resetter/Pulumi.prod.yaml+++ /dev/null@@ -1,4 +0,0 @@-config:- aws-native:region: us-east-1- aws:region: us-east-1- sha-ref-count-resetter:macro_db_secret_key: macro-db-proddiff --git a/infra/stacks/sha-ref-count-resetter/Pulumi.yaml b/infra/stacks/sha-ref-count-resetter/Pulumi.yamldeleted file mode 100644index ba7db7e39e..0000000000--- a/infra/stacks/sha-ref-count-resetter/Pulumi.yaml+++ /dev/null@@ -1,3 +0,0 @@-name: sha-ref-count-resetter-runtime: nodejs-description: Sha Ref Count Resetterdiff --git a/infra/stacks/sha-ref-count-resetter/index.ts b/infra/stacks/sha-ref-count-resetter/index.tsdeleted file mode 100644index 85ffb91f28..0000000000--- a/infra/stacks/sha-ref-count-resetter/index.ts+++ /dev/null@@ -1,79 +0,0 @@-import * as aws from '@pulumi/aws';-import * as pulumi from '@pulumi/pulumi';-import { WorkerTrigger } from '../../packages/lambda';-import { config, stack } from '../../packages/shared';-import { ShaRefCountResetterWorker } from './sha-ref-count-resetter-worker';--const tags = {- environment: stack,- tech_lead: 'hutch',- project: 'sha-ref-count-resetter',-};--const cloudStorageStack = new pulumi.StackReference('cloud-storage-stack', {- name: `macro-inc/document-storage/${stack}`,-});--const cloudStorageCacheEndpoint: pulumi.Output<string> = cloudStorageStack- .getOutput('cloudStorageCacheEndpoint')- .apply((arn) => arn as string);--const DATABASE_URL = aws.secretsmanager- .getSecretVersionOutput({- secretId: config.require(`macro_db_secret_key`),- })- .apply((secret) => secret.secretString);--const cloudStorageClusterArn: pulumi.Output<string> = cloudStorageStack- .getOutput('cloudStorageClusterArn')- .apply((arn) => arn as string);--const shaRefCountResetterWorker = new ShaRefCountResetterWorker(- 'sha-ref-count-resetter-worker',- {- containerEnvVars: [- {- name: 'REDIS_URI',- value: pulumi.interpolate`rediss://${cloudStorageCacheEndpoint}`,- },- {- name: 'DATABASE_URL',- value: pulumi.interpolate`${DATABASE_URL}`,- },- {- name: 'ENVIRONMENT',- value: stack,- },- {- name: 'RUST_LOG',- value: 'sha_ref_count_resetter=info',- },- ],- platform: {- family: 'linux',- architecture: 'amd64',- },- tags,- }-);--export const shaRefCountResetterWorkerTaskDefinitionArn =- shaRefCountResetterWorker.taskDefinition.taskDefinition.arn;--export const shaRefCountResetterWorkerImageUri =- shaRefCountResetterWorker.image.imageUri;-export const shaRefCountResetterWorkerRoleArn =- shaRefCountResetterWorker.role.arn;-export const shaRefCountResetterWorkerTaskArn =- shaRefCountResetterWorker.taskDefinition.taskDefinition.arn;--const shaCleanupTriggerLambda = new WorkerTrigger(- 'sha-ref-count-resetter-trigger',- {- clusterArn: cloudStorageClusterArn,- taskDefinitionArn: shaRefCountResetterWorkerTaskArn,- tags,- }-);--export const shaCleanupTriggerLambdaName = shaCleanupTriggerLambda.lambda.name;diff --git a/infra/stacks/sha-ref-count-resetter/package.json b/infra/stacks/sha-ref-count-resetter/package.jsondeleted file mode 100644index e7230e0a5d..0000000000--- a/infra/stacks/sha-ref-count-resetter/package.json+++ /dev/null@@ -1,7 +0,0 @@-{- "name": "sha-ref-count-resetter-stack",- "version": "0.0.0",- "private": true,- "license": "MIT",- "main": "index.ts"-}diff --git a/infra/stacks/sha-ref-count-resetter/sha-ref-count-resetter-worker.ts b/infra/stacks/sha-ref-count-resetter/sha-ref-count-resetter-worker.tsdeleted file mode 100644index 7dc2786eba..0000000000--- a/infra/stacks/sha-ref-count-resetter/sha-ref-count-resetter-worker.ts+++ /dev/null@@ -1,104 +0,0 @@-import * as aws from '@pulumi/aws';-import * as awsx from '@pulumi/awsx';-import type { Output } from '@pulumi/pulumi';-import * as pulumi from '@pulumi/pulumi';-import { stack } from '../../packages/shared';--const BASE_NAME = `sha-ref-count-resetter-worker`;-const WORKER_NAME = `${BASE_NAME}-${stack}`;-const BASE_PATH = '../../../rust/cloud-storage';--type CreateShaRefCountResetterWorkerArgs = {- containerEnvVars?: { name: string; value: Output<string> | string }[];- platform: { family: string; architecture: 'amd64' | 'arm64' };- tags: { [name: string]: string };-};--export class ShaRefCountResetterWorker extends pulumi.ComponentResource {- public ecr: awsx.ecr.Repository;- public image: awsx.ecr.Image;- public taskDefinition: awsx.ecs.FargateTaskDefinition;- public role: aws.iam.Role;- constructor(- name: string,- { platform, containerEnvVars, tags }: CreateShaRefCountResetterWorkerArgs,- opts?: pulumi.ComponentResourceOptions- ) {- super('my:components:ShaRefCountResetterWorker', name, {}, opts);- this.ecr = new awsx.ecr.Repository(- `${BASE_NAME}-ecr-${stack}`,- {- name: `${BASE_NAME}-${stack}`,- imageTagMutability: 'MUTABLE',- forceDelete: true,- lifecyclePolicy: {- // We do not want a lifecycle policy for the repositories- skip: true,- },- tags,- },- { parent: this }- );- this.image = new awsx.ecr.Image(- `${BASE_NAME}-image-${stack}`,- {- imageTag: 'latest',- context: BASE_PATH,- platform: `${platform.family}/${platform.architecture}`,- dockerfile: `${BASE_PATH}/Dockerfile.sha-ref-count-resetter`,- repositoryUrl: this.ecr.url,- },- { parent: this }- );-- this.role = new aws.iam.Role(- `${BASE_NAME}-role-${stack}`,- {- name: `${BASE_NAME}-role-${stack}`,- assumeRolePolicy: {- Version: '2012-10-17',- Statement: [- {- Action: 'sts:AssumeRole',- Principal: {- Service: 'ecs-tasks.amazonaws.com',- },- Effect: 'Allow',- Sid: '',- },- ],- },- tags,- },- { parent: this }- );-- this.taskDefinition = new awsx.ecs.FargateTaskDefinition(- `${BASE_NAME}-task-def-${stack}`,- {- cpu: '1024',- memory: '2048',- taskRole: {- roleArn: pulumi.interpolate`${this.role.arn}`,- },- container: {- name: WORKER_NAME,- image: pulumi.interpolate`${this.ecr.repository.repositoryUrl}:latest`,- cpu: 1024, // Specify CPU units- memory: 2048, // Specify memory in MB- environment: containerEnvVars,- },- runtimePlatform: {- operatingSystemFamily: `${platform.family.toUpperCase()}`,- cpuArchitecture: `${- platform.architecture === 'amd64'- ? 'X86_64'- : platform.architecture.toUpperCase()- }`,- },- tags,- },- { parent: this }- );- }-}diff --git a/infra/stacks/sha-ref-count-resetter/tsconfig.json b/infra/stacks/sha-ref-count-resetter/tsconfig.jsondeleted file mode 100644index 6f83eb665f..0000000000--- a/infra/stacks/sha-ref-count-resetter/tsconfig.json+++ /dev/null@@ -1,3 +0,0 @@-{- "extends": "../../tsconfig.json",-}diff --git a/rust/cloud-storage/Cargo.lock b/rust/cloud-storage/Cargo.lockindex b51ccca823..80125e674a 100644--- a/rust/cloud-storage/Cargo.lock+++ b/rust/cloud-storage/Cargo.lock@@ -2498,7 +2498,7 @@ dependencies = ["macro_db_client","macro_entrypoint","macro_env",- "macro_redis_cluster_client",+ "macro_sha_count_client","model","models_properties","openssl",@@ -2780,7 +2780,7 @@ dependencies = ["macro_middleware","macro_notify","macro_project_utils",- "macro_redis_cluster_client",+ "macro_sha_count_client","macro_share_permissions","macro_user_id","macro_uuid",@@ -2897,7 +2897,7 @@ dependencies = ["macro_db_client","macro_entrypoint","macro_env",- "macro_redis_cluster_client",+ "macro_sha_count_client","macro_uuid","model","openssl",@@ -5153,21 +5153,21 @@ dependencies = [][[package]]-name = "macro_redis_cluster_client"+name = "macro_service_client"version = "0.1.0"dependencies = ["anyhow",- "model",- "redis",- "tokio",- "tracing",][[package]]-name = "macro_service_client"+name = "macro_sha_count_client"version = "0.1.0"dependencies = ["anyhow",+ "model",+ "redis",+ "tokio",+ "tracing",][[package]]@@ -8057,19 +8057,6 @@ dependencies = ["tracing",]-[[package]]-name = "sha_ref_count_resetter"-version = "0.1.0"-dependencies = [- "anyhow",- "macro_entrypoint",- "macro_env",- "redis",- "sqlx",- "tokio",- "tracing",-]-[[package]]name = "sharded-slab"version = "0.1.7"diff --git a/rust/cloud-storage/Cargo.toml b/rust/cloud-storage/Cargo.tomlindex d6159491c9..5d43c3d38f 100644--- a/rust/cloud-storage/Cargo.toml+++ b/rust/cloud-storage/Cargo.toml@@ -57,7 +57,7 @@ members = ["macro_notify","macro_project_utils","macro_redis",- "macro_redis_cluster_client",+ "macro_sha_count_client","macro_service_client","macro_share_permissions","macro_uuid",@@ -102,7 +102,6 @@ members = ["secretsmanager_client","ses_client","sha_cleanup_worker",- "sha_ref_count_resetter","sns_client","soup","sqs_client",diff --git a/rust/cloud-storage/Dockerfile.sha-ref-count-resetter b/rust/cloud-storage/Dockerfile.sha-ref-count-resetterdeleted file mode 100644index 704463c8ff..0000000000--- a/rust/cloud-storage/Dockerfile.sha-ref-count-resetter+++ /dev/null@@ -1,20 +0,0 @@-FROM rust:latest AS builder--WORKDIR /app--ENV SQLX_OFFLINE=true--COPY ./Cargo.lock Cargo.lock-COPY ./Cargo.toml Cargo.toml-COPY . .--RUN --mount=type=cache,id=cargo_build,target=/usr/local/cargo/registry cargo build --release --bin sha_ref_count_resetter--FROM debian:trixie-slim AS runner--# Install ssl certs so we can connect to the DB with ssl true-RUN apt-get update && apt install -y ca-certificates openssl--COPY --from=builder /app/target/release/sha_ref_count_resetter .--CMD ["./sha_ref_count_resetter"]diff --git a/rust/cloud-storage/delete_document_worker/Cargo.toml b/rust/cloud-storage/delete_document_worker/Cargo.tomlindex 8520fb8c45..6c584211bc 100644--- a/rust/cloud-storage/delete_document_worker/Cargo.toml+++ b/rust/cloud-storage/delete_document_worker/Cargo.toml@@ -22,12 +22,11 @@ macro_cors = { path = "../macro_cors" }macro_db_client = { path = "../macro_db_client" }macro_entrypoint = { path = "../macro_entrypoint" }macro_env = { path = "../macro_env" }-macro_redis_cluster_client = { path = "../macro_redis_cluster_client" }+macro_sha_count_client = { path = "../macro_sha_count_client" }model = { path = "../model" }openssl = { workspace = true }redis = { workspace = true, features = ["aio",- "cluster-async","tokio-native-tls-comp",] }s3_client = { path = "../s3_client" }diff --git a/rust/cloud-storage/delete_document_worker/src/context.rs b/rust/cloud-storage/delete_document_worker/src/context.rsindex 02c31f2b15..9a697b1ccb 100644--- a/rust/cloud-storage/delete_document_worker/src/context.rs+++ b/rust/cloud-storage/delete_document_worker/src/context.rs@@ -1,6 +1,6 @@use std::sync::Arc;-use macro_redis_cluster_client::Redis;+use macro_sha_count_client::Redis;use crate::config::Config;diff --git a/rust/cloud-storage/delete_document_worker/src/main.rs b/rust/cloud-storage/delete_document_worker/src/main.rsindex ea709d4c01..b2a0773047 100644--- a/rust/cloud-storage/delete_document_worker/src/main.rs+++ b/rust/cloud-storage/delete_document_worker/src/main.rs@@ -1,7 +1,7 @@use anyhow::Context;use config::{Config, Environment};use macro_entrypoint::MacroEntrypoint;-use macro_redis_cluster_client::Redis;+use macro_sha_count_client::Redis;use secretsmanager_client::SecretManager;use sqlx::postgres::PgPoolOptions;use std::sync::Arc;@@ -51,7 +51,7 @@ pub async fn main() -> anyhow::Result<()> {config.queue_wait_time_seconds,);- let redis_client = redis::cluster::ClusterClient::new(vec![config.redis_uri.clone()])+ let redis_client = redis::Client::open(config.redis_uri.clone()).map_err(|e| anyhow::Error::msg(format!("unable to connect to redis {:?}", e))).context("could not connect to redis client")?;if let Err(e) = redis_client.get_connection() {diff --git a/rust/cloud-storage/document_storage_service/Cargo.toml b/rust/cloud-storage/document_storage_service/Cargo.tomlindex 102364caee..5fda649004 100644--- a/rust/cloud-storage/document_storage_service/Cargo.toml+++ b/rust/cloud-storage/document_storage_service/Cargo.toml@@ -70,7 +70,7 @@ macro_middleware = { path = "../macro_middleware", default-features = false, fea] }macro_notify = { path = "../macro_notify" }macro_project_utils = { path = "../macro_project_utils" }-macro_redis_cluster_client = { path = "../macro_redis_cluster_client" }+macro_sha_count_client = { path = "../macro_sha_count_client" }macro_share_permissions = { path = "../macro_share_permissions" }macro_user_id = { path = "../macro_user_id" }macro_uuid = { path = "../macro_uuid" }diff --git a/rust/cloud-storage/document_storage_service/src/api/context.rs b/rust/cloud-storage/document_storage_service/src/api/context.rsindex f094abbc5c..dcf2aebdec 100644--- a/rust/cloud-storage/document_storage_service/src/api/context.rs+++ b/rust/cloud-storage/document_storage_service/src/api/context.rs@@ -10,7 +10,7 @@ use email::{domain::service::EmailServiceImpl, outbound::EmailPgRepo};use frecency::{domain::services::FrecencyQueryServiceImpl, outbound::postgres::FrecencyPgStorage};use macro_auth::middleware::decode_jwt::JwtValidationArgs;use macro_env_var::env_var;-use macro_redis_cluster_client::Redis;+use macro_sha_count_client::Redis;use opensearch_client::OpensearchClient;use properties::{NotificationServiceImpl, PermissionServiceImpl, PropertiesPgRepo, PropertiesServiceImpl,diff --git a/rust/cloud-storage/document_storage_service/src/api/documents/save_document/save.rs b/rust/cloud-storage/document_storage_service/src/api/documents/save_document/save.rsindex c401650839..f8eabf2b10 100644--- a/rust/cloud-storage/document_storage_service/src/api/documents/save_document/save.rs+++ b/rust/cloud-storage/document_storage_service/src/api/documents/save_document/save.rs@@ -1,6 +1,6 @@use anyhow::Context;use axum::http::StatusCode;-use macro_redis_cluster_client::Redis;+use macro_sha_count_client::Redis;use sqlx::{Pool, Postgres};use tracing::instrument;diff --git a/rust/cloud-storage/document_storage_service/src/main.rs b/rust/cloud-storage/document_storage_service/src/main.rsindex 1b64179ed8..1e38c75500 100644--- a/rust/cloud-storage/document_storage_service/src/main.rs+++ b/rust/cloud-storage/document_storage_service/src/main.rs@@ -18,7 +18,7 @@ use frecency::{domain::services::FrecencyQueryServiceImpl, outbound::postgres::Fuse macro_auth::middleware::decode_jwt::JwtValidationArgs;use macro_entrypoint::MacroEntrypoint;use macro_middleware::auth::internal_access::InternalApiSecretKey;-use macro_redis_cluster_client::Redis;+use macro_sha_count_client::Redis;use opensearch_client::OpensearchClient;use properties::{NotificationServiceImpl, PermissionServiceImpl, PropertiesPgRepo, PropertiesServiceImpl,@@ -108,7 +108,7 @@ async fn main() -> anyhow::Result<()> {// Redis handles it own connection pool internally. Each time we use redis// we should be using redis_client.get_connection() to grab a specific connection- let redis_client = redis::cluster::ClusterClient::new(vec![config.vars.redis_uri.as_ref()])+ let redis_client = redis::Client::open(config.vars.redis_uri.as_ref()).expect("could not connect to redis client");match redis_client.get_connection().is_err() {diff --git a/rust/cloud-storage/docx_unzip_handler/Cargo.toml b/rust/cloud-storage/docx_unzip_handler/Cargo.tomlindex 421c0614af..ced30fd6c7 100644--- a/rust/cloud-storage/docx_unzip_handler/Cargo.toml+++ b/rust/cloud-storage/docx_unzip_handler/Cargo.toml@@ -22,13 +22,12 @@ lambda_runtime = { workspace = true }macro_db_client = { path = "../macro_db_client" }macro_entrypoint = { path = "../macro_entrypoint" }macro_env = { path = "../macro_env" }-macro_redis_cluster_client = { path = "../macro_redis_cluster_client" }+macro_sha_count_client = { path = "../macro_sha_count_client" }macro_uuid = { path = "../macro_uuid" }model = { path = "../model" }openssl = { workspace = true }redis = { workspace = true, features = ["aio",- "cluster-async","tokio-native-tls-comp",] }s3_client = { path = "../s3_client" }diff --git a/rust/cloud-storage/docx_unzip_handler/src/context.rs b/rust/cloud-storage/docx_unzip_handler/src/context.rsindex d4377b8171..2a0ce90555 100644--- a/rust/cloud-storage/docx_unzip_handler/src/context.rs+++ b/rust/cloud-storage/docx_unzip_handler/src/context.rs@@ -1,6 +1,6 @@use std::sync::Arc;-use macro_redis_cluster_client::Redis;+use macro_sha_count_client::Redis;use crate::config::Config;diff --git a/rust/cloud-storage/docx_unzip_handler/src/main.rs b/rust/cloud-storage/docx_unzip_handler/src/main.rsindex 521d3621aa..e5e431e2aa 100644--- a/rust/cloud-storage/docx_unzip_handler/src/main.rs+++ b/rust/cloud-storage/docx_unzip_handler/src/main.rs@@ -18,7 +18,7 @@ use lambda_runtime::{tracing::{self},};use macro_entrypoint::MacroEntrypoint;-use macro_redis_cluster_client::Redis;+use macro_sha_count_client::Redis;use sqlx::postgres::PgPoolOptions;#[tokio::main]@@ -52,7 +52,7 @@ async fn main() -> Result<(), Error> {.convert_queue(&config.convert_queue);tracing::trace!("initialized sqs client");- let redis_client = redis::cluster::ClusterClient::new(vec![config.redis_uri.clone()])+ let redis_client = redis::Client::open(config.redis_uri.clone()).map_err(|e| anyhow::Error::msg(format!("unable to connect to redis {:?}", e))).context("could not connect to redis client")?;if let Err(e) = redis_client.get_connection() {diff --git a/rust/cloud-storage/justfile b/rust/cloud-storage/justfileindex e4c3d4da2b..e39ad73f26 100644--- a/rust/cloud-storage/justfile+++ b/rust/cloud-storage/justfile@@ -69,7 +69,6 @@ setup_test_envs:echo "DATABASE_URL={{ MACRODB }}" >> ./organization_retention_trigger/.envecho "DATABASE_URL={{ MACRODB }}" >> ./organization_retention_handler/.envecho "DATABASE_URL={{ MACRODB }}" >> ./sha_cleanup_worker/.env- echo "DATABASE_URL={{ MACRODB }}" >> ./sha_ref_count_resetter/.envecho "DATABASE_URL={{ MACRODB }}" >> ./roles_and_permissions/.envecho "DATABASE_URL={{ MACRODB }}" >> ./teams/.envecho "DATABASE_URL={{ MACRODB }}" >> ./frecency/.envdiff --git a/rust/cloud-storage/macro_redis_cluster_client/Cargo.toml b/rust/cloud-storage/macro_sha_count_client/Cargo.tomlsimilarity index 78%rename from rust/cloud-storage/macro_redis_cluster_client/Cargo.tomlrename to rust/cloud-storage/macro_sha_count_client/Cargo.tomlindex 0d4c2d4bfd..12b6487770 100644--- a/rust/cloud-storage/macro_redis_cluster_client/Cargo.toml+++ b/rust/cloud-storage/macro_sha_count_client/Cargo.toml@@ -1,18 +1,17 @@[package]edition = "2024"-name = "macro_redis_cluster_client"+name = "macro_sha_count_client"publish = falseversion = "0.1.0"[features]-redis_cluster_test = []+redis_test = [][dependencies]anyhow = { workspace = true }model = { path = "../model" }redis = { workspace = true, features = ["aio",- "cluster-async","tokio-native-tls-comp",] }tokio = { workspace = true }diff --git a/rust/cloud-storage/macro_redis_cluster_client/src/decrement_count.rs b/rust/cloud-storage/macro_sha_count_client/src/decrement_count.rssimilarity index 93%rename from rust/cloud-storage/macro_redis_cluster_client/src/decrement_count.rsrename to rust/cloud-storage/macro_sha_count_client/src/decrement_count.rsindex f3b2d22192..48777dd1b1 100644--- a/rust/cloud-storage/macro_redis_cluster_client/src/decrement_count.rs+++ b/rust/cloud-storage/macro_sha_count_client/src/decrement_count.rs@@ -6,12 +6,12 @@ use super::SHA_COUNT_KEY_PREFIX;/// Decrements the count of given shas/// If the count of a sha hits 0 it will also place the sha into a shas-to-delete setpub(crate) async fn decrement_counts(- client: &redis::cluster::ClusterClient,+ client: &redis::Client,delete_bucket: &str,shas: &Vec<(String, i64)>,) -> anyhow::Result<()> {let mut redis_connection = client- .get_async_connection()+ .get_multiplexed_async_connection().await.context("unable to connect to redis")?;@@ -49,15 +49,15 @@ pub(crate) async fn decrement_counts(}#[cfg(test)]-#[cfg(feature = "redis_cluster_test")]+#[cfg(feature = "redis_test")]mod tests {use super::*;use redis::Commands;#[tokio::test]- #[ignore = "Redis cluster doesn't exist in CI"]+ #[ignore = "Redis doesn't exist in CI"]async fn test_decrement_counts() {- let redis_client = redis::cluster::ClusterClient::new(vec!["redis://localhost:6369"])+ let redis_client = redis::Client::open("redis://localhost:6379").expect("could not connect to redis client");let mut conn = redis_clientdiff --git a/rust/cloud-storage/macro_redis_cluster_client/src/exists.rs b/rust/cloud-storage/macro_sha_count_client/src/exists.rssimilarity index 85%rename from rust/cloud-storage/macro_redis_cluster_client/src/exists.rsrename to rust/cloud-storage/macro_sha_count_client/src/exists.rsindex 6877076f54..4e2c7d515a 100644--- a/rust/cloud-storage/macro_redis_cluster_client/src/exists.rs+++ b/rust/cloud-storage/macro_sha_count_client/src/exists.rs@@ -7,12 +7,9 @@ use super::SHA_COUNT_KEY_PREFIX;/// Checks if a given key exists#[tracing::instrument(skip(client))]-pub(crate) async fn exists(- client: &redis::cluster::ClusterClient,- key: &str,-) -> anyhow::Result<bool> {+pub(crate) async fn exists(client: &redis::Client, key: &str) -> anyhow::Result<bool> {let mut redis_connection = client- .get_async_connection()+ .get_multiplexed_async_connection().await.context("unable to connect to redis")?;@@ -23,11 +20,11 @@ pub(crate) async fn exists(#[tracing::instrument(skip(client))]pub(crate) async fn find_non_existing_shas(- client: &redis::cluster::ClusterClient,+ client: &redis::Client,bom_parts: &Vec<SaveBomPart>,) -> anyhow::Result<Vec<SaveBomPart>> {let mut redis_connection = client- .get_async_connection()+ .get_multiplexed_async_connection().await.context("unable to connect to redis")?;@@ -51,11 +48,11 @@ pub(crate) async fn find_non_existing_shas(/// Adds the sha to the result list if it is NOT present in the cache#[tracing::instrument(skip(client))]pub(crate) async fn find_non_existing_shas_string(- client: &redis::cluster::ClusterClient,+ client: &redis::Client,shas: Vec<String>,) -> anyhow::Result<Vec<String>> {let mut redis_connection = client- .get_async_connection()+ .get_multiplexed_async_connection().await.context("unable to connect to redis")?;@@ -77,15 +74,15 @@ pub(crate) async fn find_non_existing_shas_string(}#[cfg(test)]-#[cfg(feature = "redis_cluster_test")]+#[cfg(feature = "redis_test")]mod tests {use super::*;use redis::Commands;#[tokio::test]- #[ignore = "Redis cluster doesn't exist in CI"]+ #[ignore = "Redis doesn't exist in CI"]async fn test_exists() {- let redis_client = redis::cluster::ClusterClient::new(vec!["redis://localhost:6369"])+ let redis_client = redis::Client::open("redis://localhost:6379").expect("could not connect to redis client");let mut conn = redis_client@@ -107,9 +104,9 @@ mod tests {}#[tokio::test]- #[ignore = "Redis cluster doesn't exist in CI"]+ #[ignore = "Redis doesn't exist in CI"]async fn test_find_non_existing_shas() {- let redis_client = redis::cluster::ClusterClient::new(vec!["redis://localhost:6369"])+ let redis_client = redis::Client::open("redis://localhost:6379").expect("could not connect to redis client");let mut conn = redis_clientdiff --git a/rust/cloud-storage/macro_redis_cluster_client/src/increment_count.rs b/rust/cloud-storage/macro_sha_count_client/src/increment_count.rssimilarity index 87%rename from rust/cloud-storage/macro_redis_cluster_client/src/increment_count.rsrename to rust/cloud-storage/macro_sha_count_client/src/increment_count.rsindex 69df553620..4d88f4eb88 100644--- a/rust/cloud-storage/macro_redis_cluster_client/src/increment_count.rs+++ b/rust/cloud-storage/macro_sha_count_client/src/increment_count.rs@@ -3,11 +3,11 @@ use anyhow::Context;use redis::AsyncCommands;pub(crate) async fn increment_counts(- client: &redis::cluster::ClusterClient,+ client: &redis::Client,shas: Vec<String>,) -> anyhow::Result<()> {let mut redis_connection = client- .get_async_connection()+ .get_multiplexed_async_connection().await.context("unable to connect to redis")?;@@ -30,15 +30,15 @@ pub(crate) async fn increment_counts(}#[cfg(test)]-#[cfg(feature = "redis_cluster_test")]+#[cfg(feature = "redis_test")]mod tests {use super::*;use redis::Commands;#[tokio::test]- #[ignore = "Redis cluster doesn't exist in CI"]+ #[ignore = "Redis doesn't exist in CI"]async fn test_increment_counts() {- let redis_client = redis::cluster::ClusterClient::new(vec!["redis://localhost:6369"])+ let redis_client = redis::Client::open("redis://localhost:6379").expect("could not connect to redis client");let mut conn = redis_clientdiff --git a/rust/cloud-storage/macro_redis_cluster_client/src/lib.rs b/rust/cloud-storage/macro_sha_count_client/src/lib.rssimilarity index 92%rename from rust/cloud-storage/macro_redis_cluster_client/src/lib.rsrename to rust/cloud-storage/macro_sha_count_client/src/lib.rsindex a77054992d..3e08cf6615 100644--- a/rust/cloud-storage/macro_redis_cluster_client/src/lib.rs+++ b/rust/cloud-storage/macro_sha_count_client/src/lib.rs@@ -6,7 +6,7 @@ use model::document::SaveBomPart;#[derive(Clone)]pub struct Redis {- inner: redis::cluster::ClusterClient,+ inner: redis::Client,}// Key prefixes@@ -14,7 +14,7 @@ static SHA_COUNT_KEY_PREFIX: &str = "sha:";static SHA_DELETE_BUCKET: &str = "bucket:sha-delete";impl Redis {- pub fn new(inner: redis::cluster::ClusterClient) -> Self {+ pub fn new(inner: redis::Client) -> Self {Self { inner }}diff --git a/rust/cloud-storage/sha_cleanup_worker/Cargo.toml b/rust/cloud-storage/sha_cleanup_worker/Cargo.tomlindex 194bce10d2..8a4d6064d4 100644--- a/rust/cloud-storage/sha_cleanup_worker/Cargo.toml+++ b/rust/cloud-storage/sha_cleanup_worker/Cargo.toml@@ -17,7 +17,7 @@ macro_entrypoint = { path = "../macro_entrypoint" }macro_env = { path = "../macro_env" }mockall = { workspace = true }redis = { workspace = true, features = [- "cluster-async",+ "aio","tokio-native-tls-comp",] }sqlx = { workspace = true }diff --git a/rust/cloud-storage/sha_cleanup_worker/src/main.rs b/rust/cloud-storage/sha_cleanup_worker/src/main.rsindex 252d23e8fc..f29af96fdc 100644--- a/rust/cloud-storage/sha_cleanup_worker/src/main.rs+++ b/rust/cloud-storage/sha_cleanup_worker/src/main.rs@@ -19,8 +19,7 @@ async fn main() -> Result<(), anyhow::Error> {tracing::trace!("initialized s3 client");let redis_client = service::redis::Redis::new(- redis::cluster::ClusterClient::new(vec![config.redis_uri.as_str()])- .expect("could not connect to redis client"),+ redis::Client::open(config.redis_uri.as_str()).expect("could not connect to redis client"),);redis_client.ping().context("able to ping redis")?;diff --git a/rust/cloud-storage/sha_cleanup_worker/src/service/redis/get_shas.rs b/rust/cloud-storage/sha_cleanup_worker/src/service/redis/get_shas.rsindex 0717468a9a..ce0746f6df 100644--- a/rust/cloud-storage/sha_cleanup_worker/src/service/redis/get_shas.rs+++ b/rust/cloud-storage/sha_cleanup_worker/src/service/redis/get_shas.rs@@ -4,11 +4,11 @@ use tracing::instrument;#[instrument(skip(client))]pub(in crate::service::redis) async fn get_set_members(- client: &redis::cluster::ClusterClient,+ client: &redis::Client,set: &str,) -> anyhow::Result<Vec<String>> {let mut redis_connection = client- .get_async_connection()+ .get_multiplexed_async_connection().await.context("unable to connect to redis")?;@@ -25,9 +25,9 @@ mod tests {use redis::Commands;#[tokio::test]- #[ignore = "Redis cluster doesn't exist in CI"]+ #[ignore = "Redis doesn't exist in CI"]async fn test_get_set_members() -> Result<(), anyhow::Error> {- let redis_client = redis::cluster::ClusterClient::new(vec!["redis://localhost:6369"])+ let redis_client = redis::Client::open("redis://localhost:6379").expect("could not connect to redis client");let mut conn = redis_clientdiff --git a/rust/cloud-storage/sha_cleanup_worker/src/service/redis/increment.rs b/rust/cloud-storage/sha_cleanup_worker/src/service/redis/increment.rsindex 13502dfdbc..f2ea3dd355 100644--- a/rust/cloud-storage/sha_cleanup_worker/src/service/redis/increment.rs+++ b/rust/cloud-storage/sha_cleanup_worker/src/service/redis/increment.rs@@ -4,12 +4,12 @@ use redis::AsyncCommands;/// Increments the value of a key by the given amount#[tracing::instrument(skip(client))]pub(in crate::service::redis) async fn increment(- client: &redis::cluster::ClusterClient,+ client: &redis::Client,key: &str,value: i64,) -> anyhow::Result<()> {let mut redis_connection = client- .get_async_connection()+ .get_multiplexed_async_connection().await.context("unable to connect to redis")?;diff --git a/rust/cloud-storage/sha_cleanup_worker/src/service/redis/mod.rs b/rust/cloud-storage/sha_cleanup_worker/src/service/redis/mod.rsindex 144e41908c..7ba7930fd8 100644--- a/rust/cloud-storage/sha_cleanup_worker/src/service/redis/mod.rs+++ b/rust/cloud-storage/sha_cleanup_worker/src/service/redis/mod.rs@@ -12,7 +12,7 @@ pub use RedisClient as Redis;#[derive(Clone)]pub struct RedisClient {- inner: redis::cluster::ClusterClient,+ inner: redis::Client,}// Key prefixes@@ -21,7 +21,7 @@ static SHA_DELETE_BUCKET: &str = "bucket:sha-delete";#[cfg_attr(test, automock)]impl RedisClient {- pub fn new(inner: redis::cluster::ClusterClient) -> Self {+ pub fn new(inner: redis::Client) -> Self {Self { inner }}diff --git a/rust/cloud-storage/sha_cleanup_worker/src/service/redis/remove_set_member.rs b/rust/cloud-storage/sha_cleanup_worker/src/service/redis/remove_set_member.rsindex 0d99646d0a..f6a5d6b007 100644--- a/rust/cloud-storage/sha_cleanup_worker/src/service/redis/remove_set_member.rs+++ b/rust/cloud-storage/sha_cleanup_worker/src/service/redis/remove_set_member.rs@@ -4,12 +4,12 @@ use tracing::instrument;#[instrument(skip(client, set, key))]pub(in crate::service::redis) async fn remove_set_member(- client: &redis::cluster::ClusterClient,+ client: &redis::Client,set: &str,key: &str,) -> Result<(), anyhow::Error> {let mut redis_connection = client- .get_async_connection()+ .get_multiplexed_async_connection().await.context("unable to connect to redis")?;@@ -26,12 +26,12 @@ pub(in crate::service::redis) async fn remove_set_member(#[instrument(skip(client, set, keys))]pub(in crate::service::redis) async fn remove_set_members(- client: &redis::cluster::ClusterClient,+ client: &redis::Client,set: &str,keys: Vec<String>,) -> Result<(), anyhow::Error> {let mut redis_connection = client- .get_async_connection()+ .get_multiplexed_async_connection().await.context("unable to connect to redis")?;@@ -53,9 +53,9 @@ mod tests {use redis::Commands;#[tokio::test]- #[ignore = "Redis cluster doesn't exist in CI"]+ #[ignore = "Redis doesn't exist in CI"]async fn test_remove_set_member() -> Result<(), anyhow::Error> {- let redis_client = redis::cluster::ClusterClient::new(vec!["redis://localhost:6369"])+ let redis_client = redis::Client::open("redis://localhost:6379").expect("could not connect to redis client");let mut conn = redis_client@@ -91,9 +91,9 @@ mod tests {}#[tokio::test]- #[ignore = "Redis cluster doesn't exist in CI"]+ #[ignore = "Redis doesn't exist in CI"]async fn test_remove_set_members() -> Result<(), anyhow::Error> {- let redis_client = redis::cluster::ClusterClient::new(vec!["redis://localhost:6369"])+ let redis_client = redis::Client::open("redis://localhost:6379").expect("could not connect to redis client");let mut conn = redis_clientdiff --git a/rust/cloud-storage/sha_ref_count_resetter/.gitignore b/rust/cloud-storage/sha_ref_count_resetter/.gitignoredeleted file mode 100644index 5fe154d896..0000000000--- a/rust/cloud-storage/sha_ref_count_resetter/.gitignore+++ /dev/null@@ -1,2 +0,0 @@-.env*-target/diff --git a/rust/cloud-storage/sha_ref_count_resetter/.sqlx/query-f38905fa15948539c44b1cf005e1c53382851c595e29444e9470f321dd840979.json b/rust/cloud-storage/sha_ref_count_resetter/.sqlx/query-f38905fa15948539c44b1cf005e1c53382851c595e29444e9470f321dd840979.jsondeleted file mode 100644index b7cec799dc..0000000000--- a/rust/cloud-storage/sha_ref_count_resetter/.sqlx/query-f38905fa15948539c44b1cf005e1c53382851c595e29444e9470f321dd840979.json+++ /dev/null@@ -1,26 +0,0 @@-{- "db_name": "PostgreSQL",- "query": "\n SELECT sha, COUNT(*) as count\n FROM \"BomPart\"\n GROUP BY sha\n ",- "describe": {- "columns": [- {- "ordinal": 0,- "name": "sha",- "type_info": "Text"- },- {- "ordinal": 1,- "name": "count",- "type_info": "Int8"- }- ],- "parameters": {- "Left": []- },- "nullable": [- false,- null- ]- },- "hash": "f38905fa15948539c44b1cf005e1c53382851c595e29444e9470f321dd840979"-}diff --git a/rust/cloud-storage/sha_ref_count_resetter/Cargo.toml b/rust/cloud-storage/sha_ref_count_resetter/Cargo.tomldeleted file mode 100644index b6c62a56b7..0000000000--- a/rust/cloud-storage/sha_ref_count_resetter/Cargo.toml+++ /dev/null@@ -1,18 +0,0 @@-[package]-edition = "2024"-name = "sha_ref_count_resetter"-publish = false-version = "0.1.0"--[dependencies]-anyhow = { workspace = true }-macro_entrypoint = { path = "../macro_entrypoint" }-macro_env = { path = "../macro_env" }-redis = { workspace = true, features = [- "aio",- "cluster-async",- "tokio-native-tls-comp",-] }-sqlx = { workspace = true }-tokio = { workspace = true }-tracing = { workspace = true }diff --git a/rust/cloud-storage/sha_ref_count_resetter/Dockerfile b/rust/cloud-storage/sha_ref_count_resetter/Dockerfiledeleted file mode 100644index 6a7d7bbf50..0000000000--- a/rust/cloud-storage/sha_ref_count_resetter/Dockerfile+++ /dev/null@@ -1,25 +0,0 @@-FROM rust:latest AS builder--WORKDIR /app--COPY ./Cargo.lock Cargo.lock-COPY ./Cargo.toml Cargo.toml--COPY ./.sqlx .sqlx--COPY ./src src--ENV SQLX_OFFLINE=true--RUN --mount=type=cache,id=cargo_build,target=/usr/local/cargo/registry cargo build --release--RUN rm -rf ./src--FROM debian:bookworm-slim AS runner--# Install ssl certs so we can connect to the DB with ssl true-RUN apt-get update && apt install -y ca-certificates openssl--COPY --from=builder /app/target/release/sha_ref_count_resetter .--CMD ["./sha_ref_count_resetter"]diff --git a/rust/cloud-storage/sha_ref_count_resetter/Makefile b/rust/cloud-storage/sha_ref_count_resetter/Makefiledeleted file mode 100644index cd58853ade..0000000000--- a/rust/cloud-storage/sha_ref_count_resetter/Makefile+++ /dev/null@@ -1,2 +0,0 @@-prepare_db:- DATABASE_URL=postgres://user:password@localhost:5432/macrodb cargo sqlx preparediff --git a/rust/cloud-storage/sha_ref_count_resetter/README.md b/rust/cloud-storage/sha_ref_count_resetter/README.mddeleted file mode 100644index 6375ff1bd5..0000000000--- a/rust/cloud-storage/sha_ref_count_resetter/README.md+++ /dev/null@@ -1,5 +0,0 @@-# Sha Ref Count Resetter--This assumes that the redis cluster has been emptied of all sha data.--This is a simple program that will reset the sha ref count in redis cli should it ever get corrupted or out of sync.diff --git a/rust/cloud-storage/sha_ref_count_resetter/fixtures/shas.sql b/rust/cloud-storage/sha_ref_count_resetter/fixtures/shas.sqldeleted file mode 100644index 3ac4be0526..0000000000--- a/rust/cloud-storage/sha_ref_count_resetter/fixtures/shas.sql+++ /dev/null@@ -1,25 +0,0 @@-INSERT INTO public."User" ("id","email","stripeCustomerId")-(SELECT 'macro|[email protected]', '[email protected]','stripe_id');--INSERT INTO public."Document" ("id","name","fileType", "owner", "createdAt", "updatedAt")-(SELECT 'document-one', 'test_document_name','pdf', 'macro|[email protected]', '2019-10-16 00:00:00', '2019-10-16 00:00:00');--INSERT INTO public."DocumentBom" ("revisionName", "documentId", "createdAt", "updatedAt")-(SELECT 'test_document_name', 'document-one', '2019-10-16 00:00:00', '2019-10-16 00:00:00');--INSERT INTO public."DocumentBom" ("revisionName", "documentId", "createdAt", "updatedAt")-(SELECT 'test_document_name', 'document-one', '2019-10-16 01:00:00', '2019-10-16 01:00:00');--INSERT INTO public."BomPart" ("id", "sha", "path", "documentBomId")-(SELECT 'b1', 'sha-1', 'path', 1);-INSERT INTO public."BomPart" ("id", "sha", "path", "documentBomId")-(SELECT 'b2', 'sha-2', 'path', 1);-INSERT INTO public."BomPart" ("id", "sha", "path", "documentBomId")-(SELECT 'b3', 'sha-3', 'path', 1);--INSERT INTO public."BomPart" ("id", "sha", "path", "documentBomId")-(SELECT 'b4', 'sha-1', 'path', 2);-INSERT INTO public."BomPart" ("id", "sha", "path", "documentBomId")-(SELECT 'b5', 'sha-2', 'path', 2);-INSERT INTO public."BomPart" ("id", "sha", "path", "documentBomId")-(SELECT 'b6', 'sha-4', 'path', 2);diff --git a/rust/cloud-storage/sha_ref_count_resetter/migrations/20240325143515_basic_schema_for_testing.sql b/rust/cloud-storage/sha_ref_count_resetter/migrations/20240325143515_basic_schema_for_testing.sqldeleted file mode 100644index 42d8456e80..0000000000--- a/rust/cloud-storage/sha_ref_count_resetter/migrations/20240325143515_basic_schema_for_testing.sql+++ /dev/null@@ -1,132 +0,0 @@--- NOTE: This is used purely to setup the testing DB--- Changes from `database/prisma/schema.prisma` need to be converted into raw SQL--- Changes here WILL NOT ever make it into the dev/production db.-CREATE EXTENSION IF NOT EXISTS "uuid-ossp";--CREATE TABLE "User" (- "id" TEXT PRIMARY KEY,- "email" TEXT UNIQUE NOT NULL,- "name" TEXT,- "stripeCustomerId" TEXT UNIQUE-);--CREATE TABLE "DocumentFamily" (- "id" BIGSERIAL PRIMARY KEY,- "rootDocumentId" TEXT NOT NULL-);---- Document table-CREATE TABLE "Document" (- -- Setting to type text as UUID was causing tests to fail and I didn't want to debug it- "id" TEXT PRIMARY KEY DEFAULT uuid_generate_v4(),- "name" TEXT NOT NULL,- "owner" TEXT NOT NULL,- "fileType" TEXT NOT NULL,- -- Setting to type text as UUID was causing tests to fail and I didn't want to debug it- "branchedFromId" TEXT,- "branchedFromVersionId" BIGINT,- "documentFamilyId" BIGINT,- "createdAt" TIMESTAMPTZ NOT NULL DEFAULT NOW(),- "updatedAt" TIMESTAMPTZ NOT NULL DEFAULT NOW(),- FOREIGN KEY ("owner") REFERENCES "User"("id")-);---- DocumentInstance table-CREATE TABLE "DocumentInstance" (- "id" BIGSERIAL PRIMARY KEY,- "revisionName" TEXT ,- -- Setting to type text as UUID was causing tests to fail and I didn't want to debug it- "documentId" TEXT NOT NULL,- "createdAt" TIMESTAMPTZ NOT NULL DEFAULT NOW(),- "updatedAt" TIMESTAMPTZ NOT NULL DEFAULT NOW(),- "sha" TEXT NOT NULL,- FOREIGN KEY ("documentId") REFERENCES "Document"("id") ON DELETE CASCADE-);--CREATE TABLE "DocumentBom" (- "id" BIGSERIAL PRIMARY KEY,- "revisionName" TEXT ,- -- Setting to type text as UUID was causing tests to fail and I didn't want to debug it- "documentId" TEXT NOT NULL,- "createdAt" TIMESTAMPTZ NOT NULL DEFAULT NOW(),- "updatedAt" TIMESTAMPTZ NOT NULL DEFAULT NOW(),- FOREIGN KEY ("documentId") REFERENCES "Document"("id") ON DELETE CASCADE-);--CREATE TABLE "BomPart" (- "id" TEXT PRIMARY KEY DEFAULT uuid_generate_v4(),- "sha" TEXT NOT NULL,- "path" TEXT NOT NULL,- "documentBomId" BIGSERIAL NOT NULL,- "createdAt" TIMESTAMPTZ NOT NULL DEFAULT NOW(),- "updatedAt" TIMESTAMPTZ NOT NULL DEFAULT NOW(),- FOREIGN KEY ("documentBomId") REFERENCES "DocumentBom"("id") ON DELETE CASCADE-);--CREATE TABLE "DocumentProcessResult" (- "id" BIGSERIAL PRIMARY KEY,- "sha" TEXT NOT NULL,- "jobType" TEXT NOT NULL,- "content" TEXT NOT NULL-);--CREATE TABLE "JobToDocumentProcessResult" (- "jobId" TEXT NOT NULL,- "documentProcessResultId" BIGSERIAL NOT NULL,- FOREIGN KEY ("documentProcessResultId") REFERENCES "DocumentProcessResult"("id") ON DELETE CASCADE-);--CREATE TABLE "OpenedFileEvent" (- "userId" TEXT NOT NULL,- "documentId" TEXT NOT NULL,- "createdAt" TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP,- "updatedAt" TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP,- FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE,- FOREIGN KEY ("documentId") REFERENCES "Document"("id") ON DELETE CASCADE,- UNIQUE ("userId", "documentId")-);--CREATE TABLE "Pin" (- "userId" TEXT NOT NULL,- "pinnedItemId" TEXT NOT NULL,- "pinnedItemType" TEXT NOT NULL,- "pinIndex" INTEGER NOT NULL,- "createdAt" TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP,- "updatedAt" TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP,- FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE,- UNIQUE ("userId", "pinnedItemId", "pinnedItemType")-);--CREATE TABLE "DocxUploadJob" (- "id" BIGSERIAL PRIMARY KEY,- "jobId" TEXT NOT NULL,- "documentId" TEXT,- "createdAt" TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP-);--CREATE TABLE "Chat" (- "id" TEXT PRIMARY KEY DEFAULT uuid_generate_v4(),- "name" TEXT NOT NULL,- "userId" TEXT NOT NULL,- "createdAt" TIMESTAMPTZ NOT NULL DEFAULT NOW(),- "updatedAt" TIMESTAMPTZ NOT NULL DEFAULT NOW(),- FOREIGN KEY ("userId") REFERENCES "User"("id")-);--CREATE TABLE "ChatMessage" (- "id" BIGSERIAL PRIMARY KEY,- "content" TEXT NOT NULL,- "role" TEXT NOT NULL,- "chatId" TEXT NOT NULL,- FOREIGN KEY ("chatId") REFERENCES "Chat"("id") ON DELETE CASCADE-);--CREATE TABLE "ChatUpload" (- "id" TEXT PRIMARY KEY DEFAULT uuid_generate_v4(),- "name" TEXT NOT NULL,- "sha" TEXT NOT NULL,- "fileType" TEXT NOT NULL,- "chatMessageId" BIGSERIAL NOT NULL,- "createdAt" TIMESTAMPTZ NOT NULL DEFAULT NOW(),- FOREIGN KEY ("chatMessageId") REFERENCES "ChatMessage"("id") ON DELETE CASCADE-);diff --git a/rust/cloud-storage/sha_ref_count_resetter/src/lib.rs b/rust/cloud-storage/sha_ref_count_resetter/src/lib.rsdeleted file mode 100644index 1f278a4d51..0000000000--- a/rust/cloud-storage/sha_ref_count_resetter/src/lib.rs+++ /dev/null@@ -1 +0,0 @@-pub mod service;diff --git a/rust/cloud-storage/sha_ref_count_resetter/src/main.rs b/rust/cloud-storage/sha_ref_count_resetter/src/main.rsdeleted file mode 100644index 96ccf5f054..0000000000--- a/rust/cloud-storage/sha_ref_count_resetter/src/main.rs+++ /dev/null@@ -1,49 +0,0 @@-use anyhow::Context;-use macro_entrypoint::MacroEntrypoint;-use sha_ref_count_resetter::service;-use sqlx::postgres::PgPoolOptions;--#[tokio::main]-async fn main() -> anyhow::Result<()> {- MacroEntrypoint::default().init();-- let database_url =- std::env::var("DATABASE_URL").context("DATABASE_URL needs to be provided")?;-- let db = PgPoolOptions::new()- .min_connections(5)- .max_connections(25)- .connect(&database_url)- .await- .context("could not connect to db")?;-- tracing::trace!("initialized db connection");-- let redis_uri = std::env::var("REDIS_URI").context("REDIS_URI needs to be provided")?;-- // Redis handles it own connection pool internally. Each time we use redis- // we should be using redis_client.get_connection() to grab a specific connection- let redis_client = redis::cluster::ClusterClient::new(vec![redis_uri.as_str()])- .context("could not connect to redis")?;-- if let Err(e) = redis_client.get_connection() {- tracing::error!("unable to connect to redis");- return Err(e.into());- }-- let redis_client = service::redis::Redis::new(redis_client);- tracing::trace!("initialized redis connection");-- // Get shas- let shas = service::db::get_shas(db.clone()).await?;- tracing::info!(shas=?shas.len(), "shas retrieved");-- if let Err(e) = redis_client.set_shas(shas).await {- tracing::error!(error=?e, "unable to set shas");- return Err(e);- }-- tracing::info!("shas updated");-- Ok(())-}diff --git a/rust/cloud-storage/sha_ref_count_resetter/src/service/db/get_shas.rs b/rust/cloud-storage/sha_ref_count_resetter/src/service/db/get_shas.rsdeleted file mode 100644index 742e037e0c..0000000000--- a/rust/cloud-storage/sha_ref_count_resetter/src/service/db/get_shas.rs+++ /dev/null@@ -1,45 +0,0 @@-use anyhow::Context;-use sqlx::{Pool, Postgres};--/// Gets all shas and their counts from the database-#[tracing::instrument(skip(db))]-pub async fn get_shas(db: Pool<Postgres>) -> anyhow::Result<Vec<(String, i64)>> {- let result = sqlx::query!(- r#"- SELECT sha, COUNT(*) as count- FROM "BomPart"- GROUP BY sha- "#- )- .fetch_all(&db)- .await?;-- let result = result- .iter()- .map(|row| {- let count: i64 = row.count.context("expected count to be present").unwrap();- (row.sha.clone(), count)- })- .collect::<Vec<(String, i64)>>();-- Ok(result)-}--#[cfg(test)]-mod tests {- use super::*;-- #[sqlx::test(fixtures(path = "../../../fixtures", scripts("shas")))]- async fn test_get_shas(pool: Pool<Postgres>) {- let result = get_shas(pool).await.unwrap();- assert_eq!(result.len(), 4);- assert_eq!(result[0].0, "sha-4".to_string());- assert_eq!(result[0].1, 1);- assert_eq!(result[1].0, "sha-3".to_string());- assert_eq!(result[1].1, 1);- assert_eq!(result[2].0, "sha-2".to_string());- assert_eq!(result[2].1, 2);- assert_eq!(result[3].0, "sha-1".to_string());- assert_eq!(result[3].1, 2);- }-}diff --git a/rust/cloud-storage/sha_ref_count_resetter/src/service/db/mod.rs b/rust/cloud-storage/sha_ref_count_resetter/src/service/db/mod.rsdeleted file mode 100644index c60b149bdf..0000000000--- a/rust/cloud-storage/sha_ref_count_resetter/src/service/db/mod.rs+++ /dev/null@@ -1,3 +0,0 @@-mod get_shas;--pub use get_shas::*;diff --git a/rust/cloud-storage/sha_ref_count_resetter/src/service/mod.rs b/rust/cloud-storage/sha_ref_count_resetter/src/service/mod.rsdeleted file mode 100644index bb206d1ee2..0000000000--- a/rust/cloud-storage/sha_ref_count_resetter/src/service/mod.rs+++ /dev/null@@ -1,2 +0,0 @@-pub mod db;-pub mod redis;diff --git a/rust/cloud-storage/sha_ref_count_resetter/src/service/redis/mod.rs b/rust/cloud-storage/sha_ref_count_resetter/src/service/redis/mod.rsdeleted file mode 100644index 2451008b35..0000000000--- a/rust/cloud-storage/sha_ref_count_resetter/src/service/redis/mod.rs+++ /dev/null@@ -1,43 +0,0 @@-mod remove_set_member;-mod scan;-mod set;--pub use RedisClient as Redis;--#[derive(Clone)]-pub struct RedisClient {- inner: redis::cluster::ClusterClient,-}--// Key prefixes-static SHA_COUNT_KEY_PREFIX_PATTERN: &str = "sha:*";-static SHA_COUNT_KEY_PREFIX: &str = "sha:";-#[allow(dead_code)]-static SHA_DELETE_BUCKET: &str = "bucket:sha-delete";--impl RedisClient {- pub fn new(inner: redis::cluster::ClusterClient) -> Self {- Self { inner }- }-- pub fn ping(&self) -> anyhow::Result<()> {- match self.inner.get_connection().is_ok() {- true => Ok(()),- false => Err(anyhow::anyhow!("unable to connect to redis")),- }- }-- #[tracing::instrument(skip(self))]- pub async fn scan(&self) -> anyhow::Result<Vec<String>> {- scan::scan(&self.inner).await- }- #[tracing::instrument(skip(self, shas))]- pub async fn set_shas(&self, shas: Vec<(String, i64)>) -> anyhow::Result<()> {- set::set_shas(&self.inner, shas).await- }-- #[tracing::instrument(skip(self, shas))]- pub async fn remove_sha_from_delete_bucket(&self, shas: Vec<String>) -> anyhow::Result<()> {- remove_set_member::remove_shas_from_delete_bucket(&self.inner, shas).await- }-}diff --git a/rust/cloud-storage/sha_ref_count_resetter/src/service/redis/remove_set_member.rs b/rust/cloud-storage/sha_ref_count_resetter/src/service/redis/remove_set_member.rsdeleted file mode 100644index 376b43c87d..0000000000--- a/rust/cloud-storage/sha_ref_count_resetter/src/service/redis/remove_set_member.rs+++ /dev/null@@ -1,28 +0,0 @@-use anyhow::Context;-use redis::AsyncCommands;--use super::SHA_DELETE_BUCKET;--/// Removes shas from the delete bucket-#[tracing::instrument(skip(client))]-pub(in crate::service::redis) async fn remove_shas_from_delete_bucket(- client: &redis::cluster::ClusterClient,- shas: Vec<String>,-) -> anyhow::Result<()> {- let mut redis_connection = client- .get_async_connection()- .await- .context("unable to connect to redis")?;-- for sha in shas {- if let Err(e) = redis_connection- .srem::<&str, &str, bool>(SHA_DELETE_BUCKET, &sha)- .await- {- tracing::error!(error=?e, sha=?sha, "unable to remove from delete bucket");- return Err(e.into());- }- }-- Ok(())-}diff --git a/rust/cloud-storage/sha_ref_count_resetter/src/service/redis/scan.rs b/rust/cloud-storage/sha_ref_count_resetter/src/service/redis/scan.rsdeleted file mode 100644index 152cc99efb..0000000000--- a/rust/cloud-storage/sha_ref_count_resetter/src/service/redis/scan.rs+++ /dev/null@@ -1,18 +0,0 @@-use anyhow::Context;-use redis::AsyncCommands;--use crate::service::redis::SHA_COUNT_KEY_PREFIX_PATTERN;--/// Scans redis for all shas-/// At the time of writing this, there is a bug with scan for redis clusters that-/// causes them to only scan a single node. There is no workaround at this time.-#[tracing::instrument(skip(client))]-pub async fn scan(client: &redis::cluster::ClusterClient) -> anyhow::Result<Vec<String>> {- let mut redis_connection = client- .get_async_connection()- .await- .context("unable to connect to redis")?;-- let result = redis_connection.keys(SHA_COUNT_KEY_PREFIX_PATTERN).await?;- Ok(result)-}diff --git a/rust/cloud-storage/sha_ref_count_resetter/src/service/redis/set.rs b/rust/cloud-storage/sha_ref_count_resetter/src/service/redis/set.rsdeleted file mode 100644index beb24e034e..0000000000--- a/rust/cloud-storage/sha_ref_count_resetter/src/service/redis/set.rs+++ /dev/null@@ -1,28 +0,0 @@-use anyhow::Context;-use redis::AsyncCommands;--use super::SHA_COUNT_KEY_PREFIX;--/// Sets shas ref count in redis-#[tracing::instrument(skip(client, items))]-pub(in crate::service::redis) async fn set_shas(- client: &redis::cluster::ClusterClient,- items: Vec<(String, i64)>,-) -> anyhow::Result<()> {- let mut redis_connection = client- .get_async_connection()- .await- .context("unable to connect to redis")?;-- for (key, value) in items {- if let Err(e) = redis_connection- .set::<&str, i64, bool>(format!("{}{}", SHA_COUNT_KEY_PREFIX, key).as_str(), value)- .await- {- tracing::error!(error=?e, key=?key, value=?value, "unable to set");- return Err(e.into());- }- }-- Ok(())-}diff --git a/rust/cloud-storage/target/lambda/docx_unzip_handler/bootstrap.zip b/rust/cloud-storage/target/lambda/docx_unzip_handler/bootstrap.zipindex 3e096556da..cbab506c8d 100644Binary files a/rust/cloud-storage/target/lambda/docx_unzip_handler/bootstrap.zip and b/rust/cloud-storage/target/lambda/docx_unzip_handler/bootstrap.zip differ