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
chore remove experiment service (#1221)
Will Hutchinson756981a29984
diff --git a/.github/services-config.json b/.github/services-config.jsonindex 196140a097..98fdf1a50a 100644--- a/.github/services-config.json+++ b/.github/services-config.json@@ -79,12 +79,6 @@],"stack_path": "infra/stacks/email-service/**"},- "experiment-service": {- "source_paths": [- "rust/cloud-storage/experiment_service/**"- ],- "stack_path": "infra/stacks/experiment-service/**"- },"notification-service": {"source_paths": ["rust/cloud-storage/notification_service/**"diff --git a/.github/workflows/deploy-service-generic.yml b/.github/workflows/deploy-service-generic.ymlindex caee983578..3275ed5e8c 100644--- a/.github/workflows/deploy-service-generic.yml+++ b/.github/workflows/deploy-service-generic.yml@@ -23,7 +23,6 @@ on:- document-text-extractor- email-service- email-suppression- - experiment-service- lambda-aggregate-frecency- link-sharing- notification-servicediff --git a/docker-compose.yml b/docker-compose.ymlindex cdb22a25e9..cd2e4c5765 100644--- a/docker-compose.yml+++ b/docker-compose.yml@@ -212,28 +212,6 @@ services:retries: 3start_period: 10s- # ============================================================================- # experiment_service (Port 8088)- # Feature flags and experiments- # ============================================================================- experiment_service:- <<: *common-env- build:- context: ./rust/cloud-storage- dockerfile: Dockerfile.dev- target: experiment_service- ports:- - "8088:8080"- networks:- - databases- - services- healthcheck:- test: ["CMD", "curl", "-f", "http://localhost:8080/health"]- interval: 30s- timeout: 10s- retries: 3- start_period: 10s-# ============================================================================# notification_service (Port 8089)# User notifications - NotificationDBdiff --git a/infra/bun.lock b/infra/bun.lockindex 1ca0d41ad4..ebd196a9da 100644--- a/infra/bun.lock+++ b/infra/bun.lock@@ -115,10 +115,6 @@"name": "email-suppression-stack","version": "0.0.0",},- "stacks/experiment-service": {- "name": "experiment-service-stack",- "version": "0.0.0",- },"stacks/fusion-auth": {"name": "fusion-auth","version": "0.0.0",@@ -654,8 +650,6 @@"execa": ["[email protected]", "", { "dependencies": { "cross-spawn": "^7.0.3", "get-stream": "^6.0.0", "human-signals": "^2.1.0", "is-stream": "^2.0.0", "merge-stream": "^2.0.0", "npm-run-path": "^4.0.1", "onetime": "^5.1.2", "signal-exit": "^3.0.3", "strip-final-newline": "^2.0.0" } }, "sha512-8uSpZZocAZRBAPIEINJj3Lo9HyGitllczc27Eh5YYojjMFMn8yHMDMaUHE2Jqfq05D/wucwI4JGURyXt1vchyg=="],- "experiment-service-stack": ["experiment-service-stack@workspace:stacks/experiment-service"],-"exponential-backoff": ["[email protected]", "", {}, "sha512-dX7e/LHVJ6W3DE1MHWi9S1EYzDESENfLrYohG2G++ovZrYOkm4Knwa0mc1cn84xJOR4KEU0WSchhLbd0UklbHw=="],"fast-xml-parser": ["[email protected]", "", { "dependencies": { "strnum": "^1.0.5" }, "bin": { "fxparser": "src/cli/cli.js" } }, "sha512-xkjOecfnKGkSsOwtZ5Pz7Us/T6mrbPQrq0nh+aCO5V9nk5NLWmasAHumTKjiPJPWANe+kAZ84Jc8ooJkzZ88Sw=="],diff --git a/infra/stacks/experiment-service/Pulumi.dev.yaml b/infra/stacks/experiment-service/Pulumi.dev.yamldeleted file mode 100644index 46ffc0394c..0000000000--- a/infra/stacks/experiment-service/Pulumi.dev.yaml+++ /dev/null@@ -1,8 +0,0 @@-config:- aws-native:region: us-east-1- aws:region: us-east-1- experiment-service:macro_db_secret_key: macro-db-dev- experiment-service:fusionauth_client_id: fusionauth-api-key-dev- experiment-service:fusionauth_issuer: fusionauth-dev.macro.com- experiment-service:jwt_secret_key: fusionauth-jwt-secret-dev- experiment-service:internal_api_key: document-storage-service-auth-key-devdiff --git a/infra/stacks/experiment-service/Pulumi.prod.yaml b/infra/stacks/experiment-service/Pulumi.prod.yamldeleted file mode 100644index edd1199b65..0000000000--- a/infra/stacks/experiment-service/Pulumi.prod.yaml+++ /dev/null@@ -1,8 +0,0 @@-config:- aws-native:region: us-east-1- aws:region: us-east-1- experiment-service:macro_db_secret_key: macro-db-prod- experiment-service:fusionauth_client_id: fusionauth-client-id-key-prod- experiment-service:fusionauth_issuer: auth.macro.com- experiment-service:jwt_secret_key: fusionauth-jwt-secret-prod- experiment-service:internal_api_key: document-storage-service-auth-key-proddiff --git a/infra/stacks/experiment-service/Pulumi.yaml b/infra/stacks/experiment-service/Pulumi.yamldeleted file mode 100644index 9f8a61f02b..0000000000--- a/infra/stacks/experiment-service/Pulumi.yaml+++ /dev/null@@ -1,3 +0,0 @@-name: experiment-service-runtime: nodejs-description: Macro Experiment Servicediff --git a/infra/stacks/experiment-service/index.ts b/infra/stacks/experiment-service/index.tsdeleted file mode 100644index c99e5c8e6d..0000000000--- a/infra/stacks/experiment-service/index.ts+++ /dev/null@@ -1,112 +0,0 @@-import * as aws from '@pulumi/aws';-import * as pulumi from '@pulumi/pulumi';-import { config, getMacroApiToken, stack } from '../../packages/shared';-import { get_coparse_api_vpc } from '../../packages/vpc';-import { ExperimentService } from './service';--const tags = {- environment: stack,- tech_lead: 'hutch',- project: 'experiments',-};--export const coparse_api_vpc = get_coparse_api_vpc();--const DATABASE_URL = aws.secretsmanager- .getSecretVersionOutput({- secretId: config.require(`macro_db_secret_key`),- })- .apply((secret) => secret.secretString);-const JWT_SECRET_KEY = config.require(`jwt_secret_key`);-const jwtSecretKeyArn: pulumi.Output<string> = aws.secretsmanager- .getSecretVersionOutput({ secretId: JWT_SECRET_KEY })- .apply((secret) => secret.arn);--const fusionauthClientIdSecretKey = config.require(`fusionauth_client_id`);--const AUDIENCE = aws.secretsmanager- .getSecretVersionOutput({- secretId: fusionauthClientIdSecretKey,- })- .apply((secret) => secret.secretString);-const ISSUER = config.require(`fusionauth_issuer`);-const INTERNAL_API_SECRET_KEY = config.require(`internal_api_key`);-const internalApiKeyArn: pulumi.Output<string> = aws.secretsmanager- .getSecretVersionOutput({ secretId: INTERNAL_API_SECRET_KEY })- .apply((secret) => secret.arn);--const MACRO_API_TOKENS = getMacroApiToken();--const secretKeyArns = [- pulumi.interpolate`${jwtSecretKeyArn}`,- pulumi.interpolate`${internalApiKeyArn}`,- MACRO_API_TOKENS.macroApiTokenPublicKeyArn,-];--const logLevel = stack === 'prod' ? 'info' : 'debug';--let containerEnvVars = [- {- name: 'RUST_LOG',- value: `experiment_service=${logLevel},macro_middleware=${logLevel},macro_db_client=${logLevel},tower_http=info`,- },- {- name: 'ENVIRONMENT',- value: stack,- },- {- name: 'DATABASE_URL',- value: pulumi.interpolate`${DATABASE_URL}`,- },- {- name: 'JWT_SECRET_KEY',- value: pulumi.interpolate`${JWT_SECRET_KEY}`,- },- {- name: 'AUDIENCE',- value: pulumi.interpolate`${AUDIENCE}`,- },- {- name: 'ISSUER',- value: pulumi.interpolate`${ISSUER}`,- },- {- name: 'INTERNAL_API_SECRET_KEY',- value: pulumi.interpolate`${INTERNAL_API_SECRET_KEY}`,- },- {- name: 'MACRO_API_TOKEN_ISSUER',- value: pulumi.interpolate`${MACRO_API_TOKENS.macroApiTokenIssuer}`,- },- {- name: 'MACRO_API_TOKEN_PUBLIC_KEY',- value: pulumi.interpolate`${MACRO_API_TOKENS.macroApiTokenPublicKey}`,- },-];--const cloudStorageStack = new pulumi.StackReference('cloud-storage-stack', {- name: `macro-inc/document-storage/${stack}`,-});--const cloudStorageClusterArn: pulumi.Output<string> = cloudStorageStack- .getOutput('cloudStorageClusterArn')- .apply((arn) => arn as string);--const cloudStorageClusterName: pulumi.Output<string> = cloudStorageStack- .getOutput('cloudStorageClusterName')- .apply((arn) => arn as string);--const experimentService = new ExperimentService('experiment-service', {- vpc: coparse_api_vpc,- tags,- containerEnvVars,- platform: { family: 'linux', architecture: 'amd64' },- serviceContainerPort: 8080,- healthCheckPath: '/health',- isPrivate: false,- ecsClusterArn: cloudStorageClusterArn,- cloudStorageClusterName,- secretKeyArns,-});--export const experimentServiceUrl = pulumi.interpolate`${experimentService.domain}`;diff --git a/infra/stacks/experiment-service/package.json b/infra/stacks/experiment-service/package.jsondeleted file mode 100644index 2be49743e8..0000000000--- a/infra/stacks/experiment-service/package.json+++ /dev/null@@ -1,6 +0,0 @@-{- "name": "experiment-service-stack",- "version": "0.0.0",- "private": true,- "license": "MIT"-}diff --git a/infra/stacks/experiment-service/service.ts b/infra/stacks/experiment-service/service.tsdeleted file mode 100644index f6cf7e6849..0000000000--- a/infra/stacks/experiment-service/service.ts+++ /dev/null@@ -1,514 +0,0 @@-import * as aws from '@pulumi/aws';-import * as awsx from '@pulumi/awsx';-import * as pulumi from '@pulumi/pulumi';-import {- DATADOG_API_KEY,- datadogAgentContainer,- fargateLogRouterSidecarContainer,- serviceLoadBalancer,-} from '../../packages/resources';-import { EcrImage } from '../../packages/service';-import {- BASE_DOMAIN,- CLOUD_TRAIL_SNS_TOPIC_ARN,- stack,-} from '../../packages/shared';--const BASE_NAME = 'experiment-service';-const BASE_PATH = '../../../rust/cloud-storage';-export const SERVICE_DOMAIN_NAME = `experiments-service${- stack === 'prod' ? '' : `-${stack}`-}.${BASE_DOMAIN}`;--type CreatExperimentServiceArgs = {- vpc: {- vpcId: pulumi.Output<string> | string;- publicSubnetIds: pulumi.Output<string[]> | string[];- privateSubnetIds: pulumi.Output<string[]> | string[];- };- tags: { [key: string]: string };- containerEnvVars: { name: string; value: pulumi.Output<string> | string }[];- platform: { family: string; architecture: 'amd64' | 'arm64' };- serviceContainerPort: number;- healthCheckPath: string;- isPrivate?: boolean;- ecsClusterArn: pulumi.Output<string> | string;- cloudStorageClusterName: pulumi.Output<string> | string;- secretKeyArns: (pulumi.Output<string> | string)[];-};--export class ExperimentService extends pulumi.ComponentResource {- public role: aws.iam.Role;- public ecr: awsx.ecr.Repository;- public serviceAlbSg: aws.ec2.SecurityGroup;- public serviceSg: aws.ec2.SecurityGroup;- public domain: string;- public tags: { [key: string]: string };- public targetGroup: aws.lb.TargetGroup;- public lb: aws.lb.LoadBalancer;- public listener: aws.lb.Listener;- public service: awsx.ecs.FargateService;- public cloudStorageClusterName: pulumi.Output<string> | string;-- constructor(- name: string,- {- vpc,- tags,- platform,- serviceContainerPort,- healthCheckPath,- isPrivate,- ecsClusterArn,- containerEnvVars,- cloudStorageClusterName,- secretKeyArns,- }: CreatExperimentServiceArgs,- opts?: pulumi.ComponentResourceOptions- ) {- super('my:components:CloudStorageService', name, {}, opts);- this.domain = `https://${SERVICE_DOMAIN_NAME}`;- this.tags = tags;- this.cloudStorageClusterName = cloudStorageClusterName;-- const secretsManagerPolicy = new aws.iam.Policy(- `${BASE_NAME}-secrets-manager-policy`,- {- name: `${BASE_NAME}-secrets-manager-policy-${stack}`,- policy: {- Version: '2012-10-17',- Statement: [- {- Action: [- 'secretsmanager:GetSecretValue',- 'secretsmanager:DescribeSecret',- ],- Resource: [...secretKeyArns],- Effect: 'Allow',- },- ],- },- tags: this.tags,- },- { parent: this }- );-- this.role = new aws.iam.Role(- `${BASE_NAME}-role`,- {- name: `${BASE_NAME}-role-${stack}`,- assumeRolePolicy: {- Version: '2012-10-17',- Statement: [- {- Action: 'sts:AssumeRole',- Principal: {- Service: 'ecs-tasks.amazonaws.com',- },- Effect: 'Allow',- Sid: '',- },- ],- },- tags: this.tags,- managedPolicyArns: [secretsManagerPolicy.arn],- },- { parent: this }- );-- // ecr image- const image = new EcrImage(- `${BASE_NAME}-ecr-image-${stack}`,- {- repositoryId: `${BASE_NAME}-ecr-${stack}`,- repositoryName: `${BASE_NAME}-${stack}`,- imageId: `${BASE_NAME}-image-${stack}`,- imagePath: BASE_PATH,- dockerfile: 'Dockerfile',- platform,- buildArgs: {- SERVICE_NAME: 'experiment_service',- },- tags: this.tags,- },- { parent: this }- );- this.ecr = image.ecr;-- // Security groups- const sg = this.initializeSecurityGroups({- vpcId: vpc.vpcId,- serviceContainerPort,- });- this.serviceAlbSg = sg.serviceAlbSg;- this.serviceSg = sg.serviceSg;-- // Load balancer- const { targetGroup, lb, listener } = serviceLoadBalancer(this, {- serviceName: BASE_NAME, // service name- serviceContainerPort,- healthCheckPath,- vpc,- albSecurityGroupId: this.serviceAlbSg.id,- isPrivate,- tags,- });- this.targetGroup = targetGroup;- this.lb = lb;- this.listener = listener;-- // Fargate Service- const service = new awsx.ecs.FargateService(- `${BASE_NAME}`,- {- tags,- cluster: ecsClusterArn,- networkConfiguration: {- subnets: vpc.privateSubnetIds,- securityGroups: [this.serviceSg.id],- },- taskDefinitionArgs: {- taskRole: {- roleArn: this.role.arn,- },- containers: {- log_router: fargateLogRouterSidecarContainer,- datadog_agent: datadogAgentContainer,- service: {- name: BASE_NAME,- image: image.image.imageUri,- stopTimeout: 10, // 10 seconds to force kill the task- cpu: 256,- memory: 512,- environment: [- ...containerEnvVars,- {- name: 'BASE_URL',- value: this.domain,- },- ],- logConfiguration: {- logDriver: 'awsfirelens',- options: {- Name: 'datadog',- Host: 'http-intake.logs.us5.datadoghq.com',- apikey: DATADOG_API_KEY,- dd_service: `experiment-service-${stack}`,- dd_source: 'fargate',- dd_tags: `project:cloudstorage, env:${stack}`,- provider: 'ecs',- },- },- portMappings: [- {- appProtocol: 'http',- name: `${BASE_NAME}-tcp-${stack}`,- hostPort: serviceContainerPort,- containerPort: serviceContainerPort,- targetGroup,- },- ],- },- },- runtimePlatform: {- operatingSystemFamily: `${platform.family.toUpperCase()}`,- cpuArchitecture: `${- platform.architecture === 'amd64'- ? 'X86_64'- : platform.architecture.toUpperCase()- }`,- },- },- desiredCount: 1,- },- { parent: this }- );- this.service = service;-- // auto-scaling and alarm notifications- this.setupAutoScaling();- this.setupServiceAlarms();-- // DNS- const zone = aws.route53.getZoneOutput({ name: BASE_DOMAIN });-- new aws.route53.Record(- `${BASE_NAME}-domain-record`,- {- name: SERVICE_DOMAIN_NAME,- type: 'A',- zoneId: zone.zoneId,- aliases: [- {- evaluateTargetHealth: false,- name: this.lb.dnsName,- zoneId: this.lb.zoneId,- },- ],- },- { parent: this }- );- }-- initializeSecurityGroups({- vpcId,- serviceContainerPort,- }: {- vpcId: pulumi.Output<string> | string;- serviceContainerPort: number;- }) {- const serviceAlbSg = new aws.ec2.SecurityGroup(- `${BASE_NAME}-alb-sg-${stack}`,- {- name: `${BASE_NAME}-alb-sg-${stack}`,- description: `${BASE_NAME} application load balancer security group`,- vpcId,- tags: this.tags,- },- { parent: this }- );-- const serviceSg = new aws.ec2.SecurityGroup(- `${BASE_NAME}-sg-${stack}`,- {- name: `${BASE_NAME}-sg-${stack}`,- vpcId,- description: `${BASE_NAME} security group that is attached directly to the service`,- tags: this.tags,- },- { parent: this }- );-- new aws.vpc.SecurityGroupIngressRule(- `${BASE_NAME}-alb-in`,- {- securityGroupId: serviceSg.id,- description: 'Allow inbound traffic from the services ALB',- referencedSecurityGroupId: serviceAlbSg.id,- fromPort: serviceContainerPort,- toPort: serviceContainerPort,- ipProtocol: 'tcp',- tags: this.tags,- },- { parent: this }- );-- new aws.vpc.SecurityGroupEgressRule(- `${BASE_NAME}-all-out`,- {- securityGroupId: serviceSg.id,- description: 'Allow all outbound',- cidrIpv4: '0.0.0.0/0',- ipProtocol: '-1',- tags: this.tags,- },- { parent: this }- );-- // ALB SG rules- new aws.vpc.SecurityGroupIngressRule(- `${BASE_NAME}-http`,- {- securityGroupId: serviceAlbSg.id,- description: 'Allow inbound HTTP traffic',- cidrIpv4: '0.0.0.0/0',- fromPort: 80,- ipProtocol: 'tcp',- toPort: 80,- tags: this.tags,- },- { parent: this }- );-- new aws.vpc.SecurityGroupIngressRule(- `${BASE_NAME}-https`,- {- securityGroupId: serviceAlbSg.id,- description: 'Allow inbound HTTPS traffic',- cidrIpv4: '0.0.0.0/0',- fromPort: 443,- ipProtocol: 'tcp',- toPort: 443,- tags: this.tags,- },- { parent: this }- );-- new aws.vpc.SecurityGroupEgressRule(- `${BASE_NAME}-out-service`,- {- description: 'Allow traffic to the service security group',- securityGroupId: serviceAlbSg.id,- referencedSecurityGroupId: serviceSg.id,- fromPort: serviceContainerPort,- ipProtocol: 'tcp',- toPort: serviceContainerPort,- tags: this.tags,- },- { parent: this }- );-- return { serviceAlbSg, serviceSg };- }-- setupAutoScaling() {- if (!this.service) return;-- const serviceScalableTarget = new aws.appautoscaling.Target(- `${BASE_NAME}-service-scalable-target-${stack}`,- {- maxCapacity: stack === 'prod' ? 10 : 3,- minCapacity: 1,- resourceId: pulumi.interpolate`service/${this.cloudStorageClusterName}/${this.service.service.name}`,- scalableDimension: 'ecs:service:DesiredCount',- serviceNamespace: 'ecs',- tags: this.tags,- },- { parent: this }- );-- const lbPortion: pulumi.Output<string> = this.lb.arn.apply((arn) => {- const parts = arn.split(':loadbalancer/');- return parts[1];- });-- const tgPortion: pulumi.Output<string> = this.targetGroup.arn.apply(- (arn) => {- const parts = arn.split(':');- return parts[parts.length - 1];- }- );-- const resourceLabel = pulumi.interpolate`${lbPortion}/${tgPortion}`;-- // Create an Auto Scaling policy for request count.- new aws.appautoscaling.Policy(- `${BASE_NAME}-scaling-policy-request-count-${stack}`,- {- policyType: 'TargetTrackingScaling',- resourceId: serviceScalableTarget.resourceId,- scalableDimension: serviceScalableTarget.scalableDimension,- serviceNamespace: serviceScalableTarget.serviceNamespace,- targetTrackingScalingPolicyConfiguration: {- targetValue: 1000, // TODO: play with this- predefinedMetricSpecification: {- predefinedMetricType: 'ALBRequestCountPerTarget',- resourceLabel,- },- scaleInCooldown: 60,- scaleOutCooldown: 120,- },- },- { parent: this }- );-- // Create an Auto Scaling policy for CPU utilization.- new aws.appautoscaling.Policy(- `${BASE_NAME}-scaling-policy-cpu-${stack}`,- {- policyType: 'TargetTrackingScaling',- resourceId: serviceScalableTarget.resourceId,- scalableDimension: serviceScalableTarget.scalableDimension,- serviceNamespace: serviceScalableTarget.serviceNamespace,- targetTrackingScalingPolicyConfiguration: {- targetValue: 70.0,- predefinedMetricSpecification: {- predefinedMetricType: 'ECSServiceAverageCPUUtilization',- },- scaleInCooldown: 100,- scaleOutCooldown: 300,- },- },- { parent: this }- );-- new aws.appautoscaling.Policy(- `${BASE_NAME}-scaling-policy-memory-${stack}`,- {- policyType: 'TargetTrackingScaling',- resourceId: serviceScalableTarget.resourceId,- scalableDimension: serviceScalableTarget.scalableDimension,- serviceNamespace: serviceScalableTarget.serviceNamespace,- targetTrackingScalingPolicyConfiguration: {- targetValue: 70.0,- predefinedMetricSpecification: {- predefinedMetricType: 'ECSServiceAverageMemoryUtilization',- },- scaleInCooldown: 100,- scaleOutCooldown: 300,- },- },- { parent: this }- );- }-- setupServiceAlarms() {- new aws.cloudwatch.MetricAlarm(- `${BASE_NAME}-high-cpu-alarm`,- {- name: `${BASE_NAME}-high-cpu-alarm-${stack}`,- metricName: 'CPUUtilization',- namespace: 'AWS/ECS',- statistic: 'Average',- period: 180,- evaluationPeriods: 1,- threshold: 80,- comparisonOperator: 'GreaterThanThreshold',- dimensions: {- ClusterName: this.cloudStorageClusterName,- ServiceName: this.service.service.name,- },- alarmDescription: `High CPU usage alarm for ${BASE_NAME} service.`,- actionsEnabled: true,- alarmActions: [CLOUD_TRAIL_SNS_TOPIC_ARN],- tags: this.tags,- },- { parent: this }- );-- new aws.cloudwatch.MetricAlarm(- `${BASE_NAME}-high-mem-alarm`,- {- name: `${BASE_NAME}-high-mem-alarm-${stack}`,- metricName: 'MemoryUtilization',- namespace: 'AWS/ECS',- statistic: 'Average',- period: 180,- evaluationPeriods: 1,- threshold: 80,- comparisonOperator: 'GreaterThanThreshold',- dimensions: {- ClusterName: this.cloudStorageClusterName,- ServiceName: this.service.service.name,- },- alarmDescription: `High Memory usage alarm for ${BASE_NAME} service.`,- actionsEnabled: true,- alarmActions: [CLOUD_TRAIL_SNS_TOPIC_ARN],- tags: this.tags,- },- { parent: this }- );-- new aws.cloudwatch.MetricAlarm(- `${BASE_NAME}-http-5xx-alarm`,- {- name: `${BASE_NAME}-http-5xx-${stack}`,- metricName: 'HTTPCode_ELB_5XX_Count',- namespace: 'AWS/ApplicationELB',- statistic: 'Sum',- period: 180,- evaluationPeriods: 1,- threshold: 25,- comparisonOperator: 'GreaterThanOrEqualToThreshold',- dimensions: {- LoadBalancer: this.lb.arn,- },- alarmDescription: `High HTTP 5XX count alarm for ${BASE_NAME} Load Balancer.`,- actionsEnabled: true,- alarmActions: [CLOUD_TRAIL_SNS_TOPIC_ARN],- tags: this.tags,- },- { parent: this }- );- }-}diff --git a/infra/stacks/experiment-service/tsconfig.json b/infra/stacks/experiment-service/tsconfig.jsondeleted file mode 100644index 6f83eb665f..0000000000--- a/infra/stacks/experiment-service/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 18972bafbb..e7e09e9ac8 100644--- a/rust/cloud-storage/Cargo.lock+++ b/rust/cloud-storage/Cargo.lock@@ -3409,41 +3409,6 @@ dependencies = ["pin-project-lite",]-[[package]]-name = "experiment_service"-version = "0.1.0"-dependencies = [- "anyhow",- "aws-config",- "aws-sdk-secretsmanager",- "axum",- "futures",- "http-body-util",- "jsonwebtoken",- "macro_auth",- "macro_cors",- "macro_db_client",- "macro_entrypoint",- "macro_env",- "macro_middleware",- "mockall",- "model",- "rand 0.9.0",- "reqwest",- "secretsmanager_client",- "serde",- "serde_json",- "sqlx",- "time",- "tokio",- "tower 0.5.2",- "tower-http",- "tracing",- "urlencoding",- "utoipa",- "utoipa-swagger-ui",-]-[[package]]name = "exr"version = "1.74.0"diff --git a/rust/cloud-storage/Cargo.toml b/rust/cloud-storage/Cargo.tomlindex 9db82a2942..66fcbdd079 100644--- a/rust/cloud-storage/Cargo.toml+++ b/rust/cloud-storage/Cargo.toml@@ -39,7 +39,6 @@ members = ["email_utils","email_validator","entity_access",- "experiment_service","frecency","gmail_client","integration_tests/*",diff --git a/rust/cloud-storage/Dockerfile.dev b/rust/cloud-storage/Dockerfile.devindex 675bea7708..502c67968e 100644--- a/rust/cloud-storage/Dockerfile.dev+++ b/rust/cloud-storage/Dockerfile.dev@@ -15,7 +15,6 @@ RUN cargo build --release \--bin document_cognition_service \--bin document_storage_service \--bin email_service \- --bin experiment_service \--bin notification_service \--bin organization_service \--bin properties_service \@@ -69,11 +68,6 @@ COPY --from=builder /app/target/release/email_service /app/svcRUN chmod +x /app/svcENTRYPOINT ["dumb-init", "./svc"]-FROM base AS experiment_service-COPY --from=builder /app/target/release/experiment_service /app/svc-RUN chmod +x /app/svc-ENTRYPOINT ["dumb-init", "./svc"]-FROM base AS notification_serviceCOPY --from=builder /app/target/release/notification_service /app/svcRUN chmod +x /app/svcdiff --git a/rust/cloud-storage/experiment_service/.gitignore b/rust/cloud-storage/experiment_service/.gitignoredeleted file mode 100644index 2f7896d1d1..0000000000--- a/rust/cloud-storage/experiment_service/.gitignore+++ /dev/null@@ -1 +0,0 @@-target/diff --git a/rust/cloud-storage/experiment_service/Cargo.toml b/rust/cloud-storage/experiment_service/Cargo.tomldeleted file mode 100644index bb452e288f..0000000000--- a/rust/cloud-storage/experiment_service/Cargo.toml+++ /dev/null@@ -1,38 +0,0 @@-[package]-edition = "2024"-name = "experiment_service"-publish = false-version = "0.1.0"--[dependencies]-anyhow = { workspace = true }-aws-config = { workspace = true }-aws-sdk-secretsmanager = { workspace = true }-axum = { workspace = true }-futures = { workspace = true }-http-body-util = { workspace = true }-jsonwebtoken = { workspace = true }-macro_auth = { path = "../macro_auth" }-macro_cors = { path = "../macro_cors" }-macro_db_client = { path = "../macro_db_client" }-macro_entrypoint = { path = "../macro_entrypoint" }-macro_env = { path = "../macro_env" }-macro_middleware = { path = "../macro_middleware", default-features = false, features = [- "auth",-] }-mockall = { workspace = true }-model = { path = "../model" }-rand = { workspace = true }-reqwest = { workspace = true }-secretsmanager_client = { path = "../secretsmanager_client" }-serde = { workspace = true }-serde_json = { workspace = true }-sqlx = { workspace = true }-time = { workspace = true }-tokio = { workspace = true }-tower = { workspace = true }-tower-http = { workspace = true }-tracing = { workspace = true }-urlencoding = { workspace = true }-utoipa = { workspace = true }-utoipa-swagger-ui = { workspace = true }diff --git a/rust/cloud-storage/experiment_service/justfile b/rust/cloud-storage/experiment_service/justfiledeleted file mode 100644index b13fbb52db..0000000000--- a/rust/cloud-storage/experiment_service/justfile+++ /dev/null@@ -1,9 +0,0 @@-set dotenv-load := true--mod ci '../ci.just'--deploy-dev:- just ci::deploy-dev experiment-service--run:- cargo rundiff --git a/rust/cloud-storage/experiment_service/src/api/context.rs b/rust/cloud-storage/experiment_service/src/api/context.rsdeleted file mode 100644index fedf7090ca..0000000000--- a/rust/cloud-storage/experiment_service/src/api/context.rs+++ /dev/null@@ -1,17 +0,0 @@-use std::sync::Arc;--use axum::extract::FromRef;-use macro_auth::middleware::decode_jwt::JwtValidationArgs;-use macro_middleware::auth::internal_access::InternalApiSecretKey;-use secretsmanager_client::LocalOrRemoteSecret;-use sqlx::PgPool;--use crate::config::Config;--#[derive(Clone, FromRef)]-pub(crate) struct AppState {- pub db: PgPool,- pub jwt_args: JwtValidationArgs,- pub internal_secret_key: LocalOrRemoteSecret<InternalApiSecretKey>,- pub config: Arc<Config>,-}diff --git a/rust/cloud-storage/experiment_service/src/api/experiment/create.rs b/rust/cloud-storage/experiment_service/src/api/experiment/create.rsdeleted file mode 100644index 54578fb2b9..0000000000--- a/rust/cloud-storage/experiment_service/src/api/experiment/create.rs+++ /dev/null@@ -1,46 +0,0 @@-use axum::{- Json,- extract::{self, State},- http::StatusCode,- response::{IntoResponse, Response},-};-use model::{experiment::Experiment, response::ErrorResponse};-use serde::{Deserialize, Serialize};-use sqlx::PgPool;-use utoipa::ToSchema;--#[derive(Serialize, Deserialize, Debug, ToSchema)]-pub struct CreateExperimentRequest {- pub id: String,-}--/// Creates a new experiment-#[utoipa::path(- post,- operation_id = "create_experiment",- path = "/experiment",- responses(- (status = 200, body = Experiment),- (status = 401, body=ErrorResponse),- (status = 500, body=ErrorResponse),- )- )]-#[tracing::instrument(skip(db, req))]-pub async fn handler(- State(db): State<PgPool>,- extract::Json(req): extract::Json<CreateExperimentRequest>,-) -> Result<Response, Response> {- let experiment = macro_db_client::experiment::create_experiment(&db, &req.id)- .await- .map_err(|e| {- tracing::error!(error=?e, "unable to create experiment");- (- StatusCode::INTERNAL_SERVER_ERROR,- Json(ErrorResponse {- message: "unable to create experiment. an experiment with that name may already exist",- }),- ).into_response()- })?;-- Ok((StatusCode::OK, Json(experiment)).into_response())-}diff --git a/rust/cloud-storage/experiment_service/src/api/experiment/initialize_user_experiments.rs b/rust/cloud-storage/experiment_service/src/api/experiment/initialize_user_experiments.rsdeleted file mode 100644index acbcc0cdc0..0000000000--- a/rust/cloud-storage/experiment_service/src/api/experiment/initialize_user_experiments.rs+++ /dev/null@@ -1,77 +0,0 @@-use axum::{- extract::{self, State},- http::StatusCode,- response::{IntoResponse, Json, Response},-};-use model::response::{EmptyResponse, ErrorResponse};-use rand::Rng;-use serde::{Deserialize, Serialize};-use sqlx::PgPool;-use utoipa::ToSchema;--#[derive(Serialize, Deserialize, Debug, ToSchema)]-pub struct InitializeUserExperimentsRequest {- pub user_id: String,-}--/// Initializes the experiments for a provided user-#[utoipa::path(- post,- operation_id = "initialize_user_experiments",- path = "/experiment/initialize",- responses(- (status = 200, body = EmptyResponse),- (status = 401, body=ErrorResponse),- (status = 500, body=ErrorResponse),- )- )]-#[tracing::instrument(skip(db))]-pub async fn handler(- State(db): State<PgPool>,- extract::Json(req): extract::Json<InitializeUserExperimentsRequest>,-) -> Result<Response, Response> {- let active_experiments = macro_db_client::experiment::get_active_experiments(&db)- .await- .map_err(|e| {- tracing::error!(error=?e, "failed to get active experiments");- (- StatusCode::INTERNAL_SERVER_ERROR,- Json(ErrorResponse {- message: "failed to get active experiments",- }),- )- .into_response()- })?;-- let active_experiments = active_experiments- .into_iter()- .map(|e| {- let mut rng = rand::rng();- let random_bool = rng.random_bool(0.5);- if random_bool {- (e.id, "A".to_string())- } else {- (e.id, "B".to_string())- }- })- .collect::<Vec<(String, String)>>();-- if let Err(e) = macro_db_client::experiment_log::bulk_create_experiment_logs(- &db,- &req.user_id,- &active_experiments,- )- .await- {- tracing::error!(error=?e, "failed to bulk create experiment logs");- return Err((- StatusCode::INTERNAL_SERVER_ERROR,- Json(ErrorResponse {- message: "failed to bulk create experiment logs",- }),- )- .into_response());- }-- Ok((StatusCode::OK, Json(EmptyResponse::default())).into_response())-}diff --git a/rust/cloud-storage/experiment_service/src/api/experiment/mod.rs b/rust/cloud-storage/experiment_service/src/api/experiment/mod.rsdeleted file mode 100644index 9a2c7af461..0000000000--- a/rust/cloud-storage/experiment_service/src/api/experiment/mod.rs+++ /dev/null@@ -1,17 +0,0 @@-use axum::{- Router,- routing::{patch, post},-};--use crate::api::context::AppState;--pub(in crate::api) mod create;-pub(in crate::api) mod initialize_user_experiments;-pub(in crate::api) mod patch;--pub fn router() -> Router<AppState> {- Router::new()- .route("/initialize", post(initialize_user_experiments::handler))- .route("/", post(create::handler))- .route("/", patch(patch::handler))-}diff --git a/rust/cloud-storage/experiment_service/src/api/experiment/patch.rs b/rust/cloud-storage/experiment_service/src/api/experiment/patch.rsdeleted file mode 100644index 82a77d10f7..0000000000--- a/rust/cloud-storage/experiment_service/src/api/experiment/patch.rs+++ /dev/null@@ -1,51 +0,0 @@-use axum::{- Json,- extract::{self, State},- http::StatusCode,- response::{IntoResponse, Response},-};-use model::{- experiment::ExperimentOperation,- response::{EmptyResponse, ErrorResponse},-};-use serde::{Deserialize, Serialize};-use sqlx::PgPool;-use utoipa::ToSchema;--#[derive(Serialize, Deserialize, Debug, ToSchema)]-pub struct PatchExperimentRequest {- pub experiment_id: String,- pub operation: ExperimentOperation,-}--/// Updates an experiment-#[utoipa::path(- patch,- operation_id = "patch_experiment",- path = "/experiment",- responses(- (status = 200, body =EmptyResponse),- (status = 401, body=ErrorResponse),- (status = 500, body=ErrorResponse),- )- )]-#[tracing::instrument(skip(db, req))]-pub async fn handler(- State(db): State<PgPool>,- extract::Json(req): extract::Json<PatchExperimentRequest>,-) -> Result<Response, Response> {- macro_db_client::experiment::patch_experiment(&db, &req.experiment_id, req.operation)- .await- .map_err(|e| {- tracing::error!(error=?e, "unable to patch experiment");- (- StatusCode::INTERNAL_SERVER_ERROR,- Json(ErrorResponse {- message: "unable to patch experiment",- }),- )- .into_response()- })?;-- Ok((StatusCode::OK, Json(EmptyResponse::default())).into_response())-}diff --git a/rust/cloud-storage/experiment_service/src/api/health.rs b/rust/cloud-storage/experiment_service/src/api/health.rsdeleted file mode 100644index d346cc13f2..0000000000--- a/rust/cloud-storage/experiment_service/src/api/health.rs+++ /dev/null@@ -1,18 +0,0 @@-use axum::{Json, Router, http::StatusCode, response::IntoResponse, routing::get};-use model::response::EmptyResponse;--/// Health check-#[utoipa::path(- get,- path = "/health",- responses(- (status = 200, description = "health", body = EmptyResponse),- )- )]-pub async fn health_handler() -> impl IntoResponse {- (StatusCode::OK, Json(EmptyResponse::default()))-}--pub fn router() -> Router {- Router::new().route("/health", get(health_handler))-}diff --git a/rust/cloud-storage/experiment_service/src/api/mod.rs b/rust/cloud-storage/experiment_service/src/api/mod.rsdeleted file mode 100644index aa14e15527..0000000000--- a/rust/cloud-storage/experiment_service/src/api/mod.rs+++ /dev/null@@ -1,64 +0,0 @@-use crate::api::context::AppState;-use anyhow::Context;-use axum::Router;-use tower::ServiceBuilder;-use tower_http::trace::TraceLayer;-use utoipa::OpenApi;-use utoipa_swagger_ui::SwaggerUi;--// Utilities-pub(crate) mod context;--// Routes-mod experiment;-mod health;-mod user;--// Misc-mod swagger;--pub async fn setup_and_serve(state: AppState) -> anyhow::Result<()> {- let cors = macro_cors::cors_layer();-- let port = state.config.port;- let env = state.config.environment;- let app = api_router(state.clone())- .with_state(state)- .layer(cors.clone())- .layer(ServiceBuilder::new().layer(TraceLayer::new_for_http()))- // The health router is attached here so we don't attach the logging middleware to it- .merge(health::router().layer(cors))- .merge(SwaggerUi::new("/docs").url("/api-doc/openapi.json", swagger::ApiDoc::openapi()));-- let listener = tokio::net::TcpListener::bind(format!("0.0.0.0:{}", port))- .await- .unwrap();- tracing::info!(- "service is up and running with environment {:?} on port {}",- env,- port- );- axum::serve(listener, app.into_make_service())- .await- .context("error starting service")-}--fn api_router(state: AppState) -> Router<AppState> {- Router::new()- .nest(- "/user",- user::router().layer(axum::middleware::from_fn_with_state(- state.jwt_args,- macro_middleware::auth::decode_jwt::handler,- )),- )- .nest(- "/experiment",- experiment::router().layer(ServiceBuilder::new().layer(- axum::middleware::from_fn_with_state(- state.internal_secret_key,- macro_middleware::auth::internal_access::handler,- ),- )),- )-}diff --git a/rust/cloud-storage/experiment_service/src/api/swagger.rs b/rust/cloud-storage/experiment_service/src/api/swagger.rsdeleted file mode 100644index f878cb4aec..0000000000--- a/rust/cloud-storage/experiment_service/src/api/swagger.rs+++ /dev/null@@ -1,56 +0,0 @@-use utoipa::OpenApi;--use crate::api::{- experiment::{- self, create::CreateExperimentRequest,- initialize_user_experiments::InitializeUserExperimentsRequest,- patch::PatchExperimentRequest,- },- health,- user::{- self, set_experiment::SetUserExperimentRequest,- update_experiment::UpdateUserExperimentRequest,- },-};-use model::{- experiment::{Experiment, ExperimentOperation},- response::{EmptyResponse, ErrorResponse},-};--#[derive(OpenApi)]-#[openapi(- info(- terms_of_service = "https://macro.com/terms",- ),- paths(- /// /health- health::health_handler,-- /// /experiment- experiment::create::handler,- experiment::initialize_user_experiments::handler,- experiment::patch::handler,-- /// /user- user::set_experiment::handler,- user::update_experiment::handler,- user::get_active_experiments::handler,- ),- components(- schemas(- EmptyResponse,- ErrorResponse,- Experiment,- ExperimentOperation,- CreateExperimentRequest,- PatchExperimentRequest,- InitializeUserExperimentsRequest,- SetUserExperimentRequest,- UpdateUserExperimentRequest,- ),- ),- tags(- (name = "experiment service", description = "Macro Experiment Service")- )- )]-pub struct ApiDoc;diff --git a/rust/cloud-storage/experiment_service/src/api/user/get_active_experiments.rs b/rust/cloud-storage/experiment_service/src/api/user/get_active_experiments.rsdeleted file mode 100644index 315c9aea23..0000000000--- a/rust/cloud-storage/experiment_service/src/api/user/get_active_experiments.rs+++ /dev/null@@ -1,41 +0,0 @@-use axum::{- Extension, Json,- extract::State,- http::StatusCode,- response::{IntoResponse, Response},-};-use model::{experiment::Experiment, response::ErrorResponse, user::UserContext};-use sqlx::PgPool;--/// Sets an experiment for the user-#[utoipa::path(- get,- operation_id = "get_user_experiments",- path = "/user",- responses(- (status = 200, body = Vec<Experiment>),- (status = 401, body=ErrorResponse),- (status = 500, body=ErrorResponse),- )- )]-#[tracing::instrument(skip(db, user_context), fields(user_id=?user_context.user_id))]-pub async fn handler(- State(db): State<PgPool>,- user_context: Extension<UserContext>,-) -> Result<Response, Response> {- let experiments =- macro_db_client::experiment::get_active_experiments_for_user(&db, &user_context.user_id)- .await- .map_err(|e| {- tracing::error!(error=?e, "failed to get active experiments");- (- StatusCode::INTERNAL_SERVER_ERROR,- Json(ErrorResponse {- message: "failed to get active experiments",- }),- )- .into_response()- })?;-- Ok((StatusCode::OK, Json(experiments)).into_response())-}diff --git a/rust/cloud-storage/experiment_service/src/api/user/mod.rs b/rust/cloud-storage/experiment_service/src/api/user/mod.rsdeleted file mode 100644index def9263375..0000000000--- a/rust/cloud-storage/experiment_service/src/api/user/mod.rs+++ /dev/null@@ -1,17 +0,0 @@-use axum::{- Router,- routing::{get, patch, post},-};--use crate::api::context::AppState;--pub(in crate::api) mod get_active_experiments;-pub(in crate::api) mod set_experiment;-pub(in crate::api) mod update_experiment;--pub fn router() -> Router<AppState> {- Router::new()- .route("/", post(set_experiment::handler))- .route("/", patch(update_experiment::handler))- .route("/", get(get_active_experiments::handler))-}diff --git a/rust/cloud-storage/experiment_service/src/api/user/set_experiment.rs b/rust/cloud-storage/experiment_service/src/api/user/set_experiment.rsdeleted file mode 100644index cbd5be7aee..0000000000--- a/rust/cloud-storage/experiment_service/src/api/user/set_experiment.rs+++ /dev/null@@ -1,60 +0,0 @@-use axum::{- Extension, Json,- extract::{self, State},- http::StatusCode,- response::{IntoResponse, Response},-};-use serde::{Deserialize, Serialize};-use sqlx::PgPool;-use utoipa::ToSchema;--use model::{- response::{EmptyResponse, ErrorResponse},- user::UserContext,-};--#[derive(Serialize, Deserialize, Debug, ToSchema)]-pub struct SetUserExperimentRequest {- /// The id of the experiment- pub experiment_id: String,- /// The group the experiment belongs to, can either be 'A' or 'B'- pub group: String,-}--/// Sets an experiment for the user-#[utoipa::path(- post,- operation_id = "set_user_experiment",- path = "/user",- responses(- (status = 200, body = EmptyResponse),- (status = 401, body=ErrorResponse),- (status = 500, body=ErrorResponse),- )- )]-#[tracing::instrument(skip(db, req, user_context), fields(user_id=?user_context.user_id))]-pub async fn handler(- State(db): State<PgPool>,- user_context: Extension<UserContext>,- extract::Json(req): extract::Json<SetUserExperimentRequest>,-) -> Result<Response, Response> {- macro_db_client::experiment_log::create_experiment_log(- &db,- &user_context.user_id,- &req.experiment_id,- &req.group,- )- .await- .map_err(|e| {- tracing::error!(error=?e, "failed to create experiment log");- (- StatusCode::INTERNAL_SERVER_ERROR,- Json(ErrorResponse {- message: "failed to create experiment log",- }),- )- .into_response()- })?;-- Ok((StatusCode::OK, Json(EmptyResponse::default())).into_response())-}diff --git a/rust/cloud-storage/experiment_service/src/api/user/update_experiment.rs b/rust/cloud-storage/experiment_service/src/api/user/update_experiment.rsdeleted file mode 100644index 3ab87d761d..0000000000--- a/rust/cloud-storage/experiment_service/src/api/user/update_experiment.rs+++ /dev/null@@ -1,56 +0,0 @@-use axum::{- Extension, Json,- extract::{self, State},- http::StatusCode,- response::{IntoResponse, Response},-};-use model::{- response::{EmptyResponse, ErrorResponse},- user::UserContext,-};-use serde::{Deserialize, Serialize};-use sqlx::PgPool;-use utoipa::ToSchema;--#[derive(Serialize, Deserialize, Debug, ToSchema)]-pub struct UpdateUserExperimentRequest {- /// The id of the experiment- pub experiment_id: String,-}--/// Updates an experiment for the user-#[utoipa::path(- patch,- operation_id = "update_user_experiment",- path = "/user",- responses(- (status = 200, body = EmptyResponse),- (status = 401, body=ErrorResponse),- (status = 500, body=ErrorResponse),- )- )]-#[tracing::instrument(skip(db, req, user_context), fields(user_id=?user_context.user_id))]-pub async fn handler(- State(db): State<PgPool>,- user_context: Extension<UserContext>,- extract::Json(req): extract::Json<UpdateUserExperimentRequest>,-) -> Result<Response, Response> {- macro_db_client::experiment_log::complete_experiment_log(- &db,- &user_context.user_id,- &req.experiment_id,- )- .await- .map_err(|e| {- tracing::error!(error=?e, "failed to update experiment log");- (- StatusCode::INTERNAL_SERVER_ERROR,- Json(ErrorResponse {- message: "failed to update experiment log",- }),- )- .into_response()- })?;-- Ok((StatusCode::OK, Json(EmptyResponse::default())).into_response())-}diff --git a/rust/cloud-storage/experiment_service/src/config.rs b/rust/cloud-storage/experiment_service/src/config.rsdeleted file mode 100644index 0fe3990f65..0000000000--- a/rust/cloud-storage/experiment_service/src/config.rs+++ /dev/null@@ -1,38 +0,0 @@-use anyhow::Context;-pub use macro_env::Environment;--/// The configuration parameters for the application.-///-/// These can either be passed on the command line, or pulled from environment variables.-/// The latter is preferred as environment variables are one of the recommended ways to-/// populate the Docker container-///-/// See `.env.sample` in document-storage-service root for details.-pub struct Config {- /// The connection URL for the Postgres database this application should use.- pub database_url: String,-- /// The port to listen for HTTP requests on.- pub port: usize,-- /// The environment we are in- pub environment: Environment,-}--impl Config {- pub fn from_env() -> anyhow::Result<Self> {- let database_url =- std::env::var("DATABASE_URL").context("DATABASE_URL must be provided")?;-- let port: usize = std::env::var("PORT")- .unwrap_or("8080".to_string())- .parse::<usize>()- .context("should be valid port number")?;-- Ok(Config {- database_url,- port,- environment: Environment::new_or_prod(),- })- }-}diff --git a/rust/cloud-storage/experiment_service/src/main.rs b/rust/cloud-storage/experiment_service/src/main.rsdeleted file mode 100644index 3e323e1282..0000000000--- a/rust/cloud-storage/experiment_service/src/main.rs+++ /dev/null@@ -1,69 +0,0 @@-use std::sync::Arc;--use crate::api::context::AppState;-use anyhow::Context;-use config::{Config, Environment};-use macro_auth::middleware::decode_jwt::JwtValidationArgs;-use macro_entrypoint::MacroEntrypoint;-use macro_middleware::auth::internal_access::InternalApiSecretKey;-use secretsmanager_client::SecretManager;-use sqlx::postgres::PgPoolOptions;--mod api;-mod config;--#[tokio::main]-async fn main() -> anyhow::Result<()> {- let env = Environment::new_or_prod();- MacroEntrypoint::new(env).init();-- let secretsmanager_client =- secretsmanager_client::SecretsManager::new(aws_sdk_secretsmanager::Client::new(- &aws_config::defaults(aws_config::BehaviorVersion::latest())- .region("us-east-1")- .load()- .await,- ));-- let internal_secret_key = secretsmanager_client- .get_maybe_secret_value(env, InternalApiSecretKey::new()?)- .await?;-- // Parse our configuration from the environment.- let config = Config::from_env().context("expected to be able to generate config")?;-- tracing::trace!("initialized config");-- let (min_connections, max_connections): (u32, u32) = match config.environment {- Environment::Production => (5, 25),- Environment::Develop => (1, 25),- Environment::Local => (1, 10),- };-- let db = PgPoolOptions::new()- .min_connections(min_connections)- .max_connections(max_connections)- .connect(&config.database_url)- .await- .context("could not connect to db")?;-- tracing::trace!(- min_connections,- max_connections,- "initialized db connection"- );-- let jwt_args =- JwtValidationArgs::new_with_secret_manager(config.environment, &secretsmanager_client)- .await?;-- api::setup_and_serve(AppState {- db,- jwt_args,- internal_secret_key,- config: Arc::new(config),- })- .await?;-- Ok(())-}