You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: main.rs
    path of file: ./repos/matano/lib/rust/alert_writer/src
    
    the code of the file until where you have to start completion: use aws_lambda_events::sqs::SqsEvent;
use aws_sdk_dynamodb::types::AttributeValue;
use aws_sdk_sns::types::PublishBatchRequestEntry;
use bytes::Bytes;
use futures_util::future::{join_all, try_join, try_join_all};
use futures_util::{FutureExt, TryFutureExt};
use serde_dynamo::aws_sdk_dynamodb_0_25::{from_item, to_item};
use serde_json::json;
use shared::alert_util::encode_alerts_for_publish;
use std::collections::HashMap;
use std::pin::Pin;
use std::sync::{Arc, Mutex};

use anyhow::{anyhow, Context, Result};
use async_once::AsyncOnce;
use base64::decode;
use futures::{Stream, StreamExt, TryStreamExt};
use lambda_runtime::{
    run, service_fn, Context as LambdaContext, Error as LambdaError, LambdaEvent,
};
use lazy_static::lazy_static;
use log::{debug, error, info};
use serde::{Deserialize, Serialize};

use std::collections::BTreeMap;
use tokio_util::codec::{FramedRead, LinesCodec};
use tokio_util::io::StreamReader;

use async_compression::tokio::bufread::ZstdDecoder;

use ::value::Value;
use shared::setup_logging;
use shared::vrl_util::vrl;
use shared::{alert_util::*, ArcMutexExt};
use vrl::{state, value};

#[global_allocator]
static ALLOC: tikv_jemallocator::Jemalloc = tikv_jemallocator::Jemalloc;

lazy_static! {
    static ref AWS_CONFIG: AsyncOnce<aws_config::SdkConfig> =
        AsyncOnce::new(async { aws_config::load_from_env().await });
    static ref SQS_CLIENT: AsyncOnce<aws_sdk_sqs::Client> =
        AsyncOnce::new(async { aws_sdk_sqs::Client::new(AWS_CONFIG.get().await) });
    static ref SNS_CLIENT: AsyncOnce<aws_sdk_sns::Client> =
        AsyncOnce::new(async { aws_sdk_sns::Client::new(AWS_CONFIG.get().await) });
    static ref DYNAMODB_C
    
async fn handler(event: LambdaEvent<SqsEvent>) -> Result<()> {
    let bytes = event
        .payload
        .records
        .into_iter()
        .flat_map(|record| record.body.and_then(|b| Some(decode(b).ok()?)))
        .flatten()
        .collect::<Vec<_>>();

    let input_bytes = bytes.len();
    info!("Processing {} input bytes", input_bytes);

    let alert_lines = get_alert_lines(bytes);

    let failed_lines = vec![];
    let failed_lines = Arc::new(Mutex::new(failed_lines));

    let cdc_payloads = alert_lines
        // TODO: this shouldn't happen but maybe don't swallow?
        .filter_map(|r| async move { r.ok() })
        .map(|l| async move { (l.clone(), process_alert_line(l).await) })
        .buffer_unordered(50)
        .filter_map(|(l, r)| {
            let failed_lines = failed_lines.clone();
            async move {
                r.map_err(|e| {
                    error!("Encountered error processing alert: {:#}", e);
                    failed_lines.lock().unwrap().push(l)
                })
                .ok()
            }
        })
        .collect::<Vec<_>>()
        .await;

    let alert_payload_count = cdc_payloads.len();
    let processed_alert_ids = cdc_payloads
        .iter()
        .map(|(p, _)| p.updated_alert.id.clone())
        .collect::<Vec<_>>();

    // Only publish activated alerts
    let activated_entries = cdc_payloads
        .into_iter()
        .filter(|(p, _)| p.updated_alert.is_activated())
        .collect::<Vec<_>>();
    let publish_count = activated_entries.len();
    info!("Publishing {} alert cdc payloads.", alert_payload_count);
    publish_alert_cdc_batch(activated_entries).await?;

    let failed_lines = failed_lines.try_unwrap_arc_mutex()?;
    let had_error = !failed_lines.is_empty();

    if !failed_lines.is_empty() {
        redrive_failed_alerts(failed_lines).await?;
    }

    let log = json!({
        "matano_log": true,
        "type": "matano_service_log",
        "service": "alert_writer",
        "processed_alert_ids": processed_alert_ids,
        "input_bytes": input_bytes,
        "alert_processed_count": alert_payload_count,
        "alert_publish_count": publish_count,
        "error": had_error,
    });
    info!("{}", serde_json::to_string(&log).unwrap_or_default());

    Ok(())
}