Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion apps/ruststack-server/src/events_bridge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
use std::sync::Arc;

use async_trait::async_trait;

use ruststack_events_core::delivery::{DeliveryError, TargetDelivery};
use ruststack_sqs_core::provider::RustStackSqs;
use ruststack_sqs_model::input::SendMessageInput;
Expand Down
8 changes: 2 additions & 6 deletions apps/ruststack-server/src/gateway.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,9 @@
//! intercepted at the gateway level and return a combined status for all
//! registered services.

use std::convert::Infallible;
use std::future::Future;
use std::pin::Pin;
use std::sync::Arc;
use std::{convert::Infallible, future::Future, pin::Pin, sync::Arc};

use hyper::body::Incoming;
use hyper::service::Service;
use hyper::{body::Incoming, service::Service};

use crate::service::{GatewayBody, ServiceRouter, gateway_body_from_string};

Expand Down
36 changes: 16 additions & 20 deletions apps/ruststack-server/src/handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,20 @@
//! dispatched to the corresponding `handle_*` method on [`RustStackS3`], with request
//! deserialization via [`FromS3Request`] and response serialization via [`IntoS3Response`].

use std::collections::HashMap;
use std::future::Future;
use std::pin::Pin;
use std::{collections::HashMap, future::Future, pin::Pin};

use bytes::Bytes;
use ruststack_s3_core::RustStackS3;
use ruststack_s3_http::body::S3ResponseBody;
use ruststack_s3_http::dispatch::S3Handler;
use ruststack_s3_http::multipart;
use ruststack_s3_http::request::FromS3Request;
use ruststack_s3_http::response::IntoS3Response;
use ruststack_s3_http::router::RoutingContext;
use ruststack_s3_model::S3Operation;
use ruststack_s3_model::error::{S3Error, S3ErrorCode};
use ruststack_s3_model::input::PutObjectInput;
use ruststack_s3_model::request::StreamingBlob;
use ruststack_s3_http::{
body::S3ResponseBody, dispatch::S3Handler, multipart, request::FromS3Request,
response::IntoS3Response, router::RoutingContext,
};
use ruststack_s3_model::{
S3Operation,
error::{S3Error, S3ErrorCode},
input::PutObjectInput,
request::StreamingBlob,
};

/// Wrapper that implements [`S3Handler`] by delegating to [`RustStackS3`] handler methods.
#[derive(Debug, Clone)]
Expand Down Expand Up @@ -623,13 +621,11 @@ async fn dispatch_post_object(
let etag = output.e_tag.unwrap_or_default();
let location = format!("/{bucket_name}/{key}");
let xml = format!(
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n\
<PostResponse>\n\
<Location>{location}</Location>\n\
<Bucket>{bucket_name}</Bucket>\n\
<Key>{key}</Key>\n\
<ETag>{etag}</ETag>\n\
</PostResponse>"
"<?xml version=\"1.0\" \
encoding=\"UTF-8\"?>\n<PostResponse>\n<Location>{location}</Location>\\
\
n<Bucket>{bucket_name}</Bucket>\n<Key>{key}</Key>\n<ETag>{etag}</ETag>\n</\
PostResponse>"
);
http::Response::builder()
.status(success_status)
Expand Down
241 changes: 113 additions & 128 deletions apps/ruststack-server/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,29 @@ mod service;
#[cfg(feature = "sns")]
mod sns_bridge;

use std::net::SocketAddr;
use std::sync::Arc;
use std::{net::SocketAddr, sync::Arc};

use anyhow::{Context, Result};
use hyper_util::rt::{TokioExecutor, TokioIo};
use hyper_util::server::conn::auto::Builder as HttpConnBuilder;
use tokio::net::TcpListener;
use tracing::{info, warn};
use tracing_subscriber::EnvFilter;

use hyper_util::{
rt::{TokioExecutor, TokioIo},
server::conn::auto::Builder as HttpConnBuilder,
};
#[cfg(feature = "apigatewayv2")]
use ruststack_apigatewayv2_core::config::ApiGatewayV2Config;
#[cfg(feature = "apigatewayv2")]
use ruststack_apigatewayv2_core::handler::RustStackApiGatewayV2Handler;
#[cfg(feature = "apigatewayv2")]
use ruststack_apigatewayv2_core::provider::RustStackApiGatewayV2;
#[cfg(feature = "apigatewayv2")]
use ruststack_apigatewayv2_http::service::{ApiGatewayV2HttpConfig, ApiGatewayV2HttpService};
#[cfg(feature = "cloudwatch")]
use ruststack_cloudwatch_core::config::CloudWatchConfig;
#[cfg(feature = "cloudwatch")]
use ruststack_cloudwatch_core::handler::RustStackCloudWatchHandler;
#[cfg(feature = "cloudwatch")]
use ruststack_cloudwatch_core::provider::RustStackCloudWatch;
#[cfg(feature = "cloudwatch")]
use ruststack_cloudwatch_http::service::{CloudWatchHttpConfig, CloudWatchHttpService};
#[cfg(feature = "dynamodb")]
use ruststack_dynamodb_core::config::DynamoDBConfig;
#[cfg(feature = "dynamodb")]
Expand All @@ -48,47 +61,22 @@ use ruststack_dynamodb_core::handler::RustStackDynamoDBHandler;
use ruststack_dynamodb_core::provider::RustStackDynamoDB;
#[cfg(feature = "dynamodb")]
use ruststack_dynamodb_http::service::{DynamoDBHttpConfig, DynamoDBHttpService};

#[cfg(feature = "sqs")]
use ruststack_sqs_core::config::SqsConfig;
#[cfg(feature = "sqs")]
use ruststack_sqs_core::handler::RustStackSqsHandler;
#[cfg(feature = "sqs")]
use ruststack_sqs_core::provider::RustStackSqs;
#[cfg(feature = "sqs")]
use ruststack_sqs_http::service::{SqsHttpConfig, SqsHttpService};

#[cfg(feature = "ssm")]
use ruststack_ssm_core::config::SsmConfig;
#[cfg(feature = "ssm")]
use ruststack_ssm_core::handler::RustStackSsmHandler;
#[cfg(feature = "ssm")]
use ruststack_ssm_core::provider::RustStackSsm;
#[cfg(feature = "ssm")]
use ruststack_ssm_http::service::{SsmHttpConfig, SsmHttpService};

#[cfg(feature = "sns")]
use crate::sns_bridge::RustStackSqsPublisher;
#[cfg(feature = "sns")]
use ruststack_sns_core::config::SnsConfig;
#[cfg(feature = "sns")]
use ruststack_sns_core::handler::RustStackSnsHandler;
#[cfg(feature = "sns")]
use ruststack_sns_core::provider::RustStackSns;
#[cfg(feature = "sns")]
use ruststack_sns_http::service::{SnsHttpConfig, SnsHttpService};

#[cfg(feature = "lambda")]
use ruststack_lambda_core::config::LambdaConfig;
#[cfg(feature = "lambda")]
use ruststack_lambda_core::handler::RustStackLambdaHandler;
#[cfg(feature = "lambda")]
use ruststack_lambda_core::provider::RustStackLambda;
#[cfg(feature = "lambda")]
use ruststack_lambda_http::service::{LambdaHttpConfig, LambdaHttpService};

#[cfg(feature = "events")]
use crate::events_bridge::LocalTargetDelivery;
#[cfg(feature = "dynamodbstreams")]
use ruststack_dynamodbstreams_core::config::DynamoDBStreamsConfig;
#[cfg(feature = "dynamodbstreams")]
use ruststack_dynamodbstreams_core::emitter::{
DynamoDBStreamEmitter, DynamoDBStreamLifecycleManager,
};
#[cfg(feature = "dynamodbstreams")]
use ruststack_dynamodbstreams_core::handler::RustStackDynamoDBStreamsHandler;
#[cfg(feature = "dynamodbstreams")]
use ruststack_dynamodbstreams_core::provider::RustStackDynamoDBStreams;
#[cfg(feature = "dynamodbstreams")]
use ruststack_dynamodbstreams_core::storage::StreamStore;
#[cfg(feature = "dynamodbstreams")]
use ruststack_dynamodbstreams_http::service::{
DynamoDBStreamsHttpConfig, DynamoDBStreamsHttpService,
};
#[cfg(feature = "events")]
use ruststack_events_core::config::EventsConfig;
#[cfg(feature = "events")]
Expand All @@ -97,25 +85,16 @@ use ruststack_events_core::handler::RustStackEventsHandler;
use ruststack_events_core::provider::RustStackEvents;
#[cfg(feature = "events")]
use ruststack_events_http::service::{EventsHttpConfig, EventsHttpService};

#[cfg(feature = "logs")]
use ruststack_logs_core::config::LogsConfig;
#[cfg(feature = "logs")]
use ruststack_logs_core::handler::RustStackLogsHandler;
#[cfg(feature = "logs")]
use ruststack_logs_core::provider::RustStackLogs;
#[cfg(feature = "logs")]
use ruststack_logs_http::service::{LogsHttpConfig, LogsHttpService};

#[cfg(feature = "kms")]
use ruststack_kms_core::config::KmsConfig;
#[cfg(feature = "kms")]
use ruststack_kms_core::handler::RustStackKmsHandler;
#[cfg(feature = "kms")]
use ruststack_kms_core::provider::RustStackKms;
#[cfg(feature = "kms")]
use ruststack_kms_http::service::{KmsHttpConfig, KmsHttpService};

#[cfg(feature = "iam")]
use ruststack_iam_core::config::IamConfig;
#[cfg(feature = "iam")]
use ruststack_iam_core::handler::RustStackIamHandler;
#[cfg(feature = "iam")]
use ruststack_iam_core::provider::RustStackIam;
#[cfg(feature = "iam")]
use ruststack_iam_core::store::IamStore;
#[cfg(feature = "iam")]
use ruststack_iam_http::service::{IamHttpConfig, IamHttpService};
#[cfg(feature = "kinesis")]
use ruststack_kinesis_core::config::KinesisConfig;
#[cfg(feature = "kinesis")]
Expand All @@ -124,7 +103,34 @@ use ruststack_kinesis_core::handler::RustStackKinesisHandler;
use ruststack_kinesis_core::provider::RustStackKinesis;
#[cfg(feature = "kinesis")]
use ruststack_kinesis_http::service::{KinesisHttpConfig, KinesisHttpService};

#[cfg(feature = "kms")]
use ruststack_kms_core::config::KmsConfig;
#[cfg(feature = "kms")]
use ruststack_kms_core::handler::RustStackKmsHandler;
#[cfg(feature = "kms")]
use ruststack_kms_core::provider::RustStackKms;
#[cfg(feature = "kms")]
use ruststack_kms_http::service::{KmsHttpConfig, KmsHttpService};
#[cfg(feature = "lambda")]
use ruststack_lambda_core::config::LambdaConfig;
#[cfg(feature = "lambda")]
use ruststack_lambda_core::handler::RustStackLambdaHandler;
#[cfg(feature = "lambda")]
use ruststack_lambda_core::provider::RustStackLambda;
#[cfg(feature = "lambda")]
use ruststack_lambda_http::service::{LambdaHttpConfig, LambdaHttpService};
#[cfg(feature = "logs")]
use ruststack_logs_core::config::LogsConfig;
#[cfg(feature = "logs")]
use ruststack_logs_core::handler::RustStackLogsHandler;
#[cfg(feature = "logs")]
use ruststack_logs_core::provider::RustStackLogs;
#[cfg(feature = "logs")]
use ruststack_logs_http::service::{LogsHttpConfig, LogsHttpService};
#[cfg(feature = "s3")]
use ruststack_s3_core::{RustStackS3, S3Config};
#[cfg(feature = "s3")]
use ruststack_s3_http::service::{S3HttpConfig, S3HttpService};
#[cfg(feature = "secretsmanager")]
use ruststack_secretsmanager_core::config::SecretsManagerConfig;
#[cfg(feature = "secretsmanager")]
Expand All @@ -133,7 +139,6 @@ use ruststack_secretsmanager_core::handler::RustStackSecretsManagerHandler;
use ruststack_secretsmanager_core::provider::RustStackSecretsManager;
#[cfg(feature = "secretsmanager")]
use ruststack_secretsmanager_http::service::{SecretsManagerHttpConfig, SecretsManagerHttpService};

#[cfg(feature = "ses")]
use ruststack_ses_core::config::SesConfig;
#[cfg(feature = "ses")]
Expand All @@ -144,53 +149,30 @@ use ruststack_ses_core::provider::RustStackSes;
use ruststack_ses_http::service::{SesHttpConfig, SesHttpService};
#[cfg(feature = "ses")]
use ruststack_ses_http::v2::SesV2HttpService;

#[cfg(feature = "apigatewayv2")]
use ruststack_apigatewayv2_core::config::ApiGatewayV2Config;
#[cfg(feature = "apigatewayv2")]
use ruststack_apigatewayv2_core::handler::RustStackApiGatewayV2Handler;
#[cfg(feature = "apigatewayv2")]
use ruststack_apigatewayv2_core::provider::RustStackApiGatewayV2;
#[cfg(feature = "apigatewayv2")]
use ruststack_apigatewayv2_http::service::{ApiGatewayV2HttpConfig, ApiGatewayV2HttpService};

#[cfg(feature = "dynamodbstreams")]
use ruststack_dynamodbstreams_core::config::DynamoDBStreamsConfig;
#[cfg(feature = "dynamodbstreams")]
use ruststack_dynamodbstreams_core::emitter::{
DynamoDBStreamEmitter, DynamoDBStreamLifecycleManager,
};
#[cfg(feature = "dynamodbstreams")]
use ruststack_dynamodbstreams_core::handler::RustStackDynamoDBStreamsHandler;
#[cfg(feature = "dynamodbstreams")]
use ruststack_dynamodbstreams_core::provider::RustStackDynamoDBStreams;
#[cfg(feature = "dynamodbstreams")]
use ruststack_dynamodbstreams_core::storage::StreamStore;
#[cfg(feature = "dynamodbstreams")]
use ruststack_dynamodbstreams_http::service::{
DynamoDBStreamsHttpConfig, DynamoDBStreamsHttpService,
};

#[cfg(feature = "cloudwatch")]
use ruststack_cloudwatch_core::config::CloudWatchConfig;
#[cfg(feature = "cloudwatch")]
use ruststack_cloudwatch_core::handler::RustStackCloudWatchHandler;
#[cfg(feature = "cloudwatch")]
use ruststack_cloudwatch_core::provider::RustStackCloudWatch;
#[cfg(feature = "cloudwatch")]
use ruststack_cloudwatch_http::service::{CloudWatchHttpConfig, CloudWatchHttpService};

#[cfg(feature = "iam")]
use ruststack_iam_core::config::IamConfig;
#[cfg(feature = "iam")]
use ruststack_iam_core::handler::RustStackIamHandler;
#[cfg(feature = "iam")]
use ruststack_iam_core::provider::RustStackIam;
#[cfg(feature = "iam")]
use ruststack_iam_core::store::IamStore;
#[cfg(feature = "iam")]
use ruststack_iam_http::service::{IamHttpConfig, IamHttpService};

#[cfg(feature = "sns")]
use ruststack_sns_core::config::SnsConfig;
#[cfg(feature = "sns")]
use ruststack_sns_core::handler::RustStackSnsHandler;
#[cfg(feature = "sns")]
use ruststack_sns_core::provider::RustStackSns;
#[cfg(feature = "sns")]
use ruststack_sns_http::service::{SnsHttpConfig, SnsHttpService};
#[cfg(feature = "sqs")]
use ruststack_sqs_core::config::SqsConfig;
#[cfg(feature = "sqs")]
use ruststack_sqs_core::handler::RustStackSqsHandler;
#[cfg(feature = "sqs")]
use ruststack_sqs_core::provider::RustStackSqs;
#[cfg(feature = "sqs")]
use ruststack_sqs_http::service::{SqsHttpConfig, SqsHttpService};
#[cfg(feature = "ssm")]
use ruststack_ssm_core::config::SsmConfig;
#[cfg(feature = "ssm")]
use ruststack_ssm_core::handler::RustStackSsmHandler;
#[cfg(feature = "ssm")]
use ruststack_ssm_core::provider::RustStackSsm;
#[cfg(feature = "ssm")]
use ruststack_ssm_http::service::{SsmHttpConfig, SsmHttpService};
#[cfg(feature = "sts")]
use ruststack_sts_core::config::StsConfig;
#[cfg(feature = "sts")]
Expand All @@ -199,14 +181,15 @@ use ruststack_sts_core::handler::RustStackStsHandler;
use ruststack_sts_core::provider::RustStackSts;
#[cfg(feature = "sts")]
use ruststack_sts_http::service::{StsHttpConfig, StsHttpService};
use tokio::net::TcpListener;
use tracing::{info, warn};
use tracing_subscriber::EnvFilter;

#[cfg(feature = "s3")]
use ruststack_s3_core::{RustStackS3, S3Config};
#[cfg(feature = "s3")]
use ruststack_s3_http::service::{S3HttpConfig, S3HttpService};

use crate::gateway::GatewayService;
use crate::service::ServiceRouter;
#[cfg(feature = "events")]
use crate::events_bridge::LocalTargetDelivery;
#[cfg(feature = "sns")]
use crate::sns_bridge::RustStackSqsPublisher;
use crate::{gateway::GatewayService, service::ServiceRouter};

/// Server version reported in health check responses.
const VERSION: &str = env!("CARGO_PKG_VERSION");
Expand Down Expand Up @@ -630,8 +613,10 @@ fn parse_services_value(raw: &str) -> Vec<String> {
/// Exits with code 0 if the response is 200 OK and contains at least one
/// running service, 1 otherwise.
async fn run_health_check(addr: &str) -> Result<()> {
use tokio::io::{AsyncReadExt, AsyncWriteExt};
use tokio::net::TcpStream;
use tokio::{
io::{AsyncReadExt, AsyncWriteExt},
net::TcpStream,
};

let mut stream = TcpStream::connect(addr)
.await
Expand Down Expand Up @@ -1029,8 +1014,8 @@ async fn main() -> Result<()> {

if services.is_empty() {
anyhow::bail!(
"no services enabled. Check the SERVICES environment variable \
and compiled feature flags."
"no services enabled. Check the SERVICES environment variable and compiled feature \
flags."
);
}

Expand Down
Loading
Loading