Skip to content

Commit

Permalink
shotover config: Fix ignored fields (#1291)
Browse files Browse the repository at this point in the history
  • Loading branch information
rukai authored Aug 16, 2023
1 parent 474b7c2 commit 52f16ca
Show file tree
Hide file tree
Showing 37 changed files with 45 additions and 0 deletions.
1 change: 1 addition & 0 deletions custom-transforms-example/src/redis_get_rewrite.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use shotover::message::Messages;
use shotover::transforms::{Transform, TransformBuilder, TransformConfig, Transforms, Wrapper};

#[derive(Deserialize, Debug, Clone)]
#[serde(deny_unknown_fields)]
pub struct RedisGetRewriteConfig {
pub result: String,
}
Expand Down
1 change: 1 addition & 0 deletions shotover-proxy/tests/cassandra_int_tests/protect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use test_helpers::connection::cassandra::{
};

#[derive(Deserialize)]
#[serde(deny_unknown_fields)]
pub struct Protected {
_cipher: Vec<u8>,
_nonce: Nonce,
Expand Down
1 change: 1 addition & 0 deletions shotover/src/config/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use std::fmt::{self, Debug};
use std::iter;

#[derive(Deserialize, Debug)]
#[serde(deny_unknown_fields)]
pub struct TransformChainConfig(
#[serde(rename = "TransformChain", deserialize_with = "vec_transform_config")]
pub Vec<Box<dyn TransformConfig>>,
Expand Down
1 change: 1 addition & 0 deletions shotover/src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ pub mod chain;
pub mod topology;

#[derive(Deserialize, Debug, Clone)]
#[serde(deny_unknown_fields)]
pub struct Config {
pub main_log_level: String,
pub observability_interface: String,
Expand Down
1 change: 1 addition & 0 deletions shotover/src/config/topology.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use tokio::sync::watch;
use tracing::info;

#[derive(Deserialize, Debug)]
#[serde(deny_unknown_fields)]
pub struct Topology {
pub sources: HashMap<String, SourceConfig>,
pub chain_config: HashMap<String, TransformChainConfig>,
Expand Down
1 change: 1 addition & 0 deletions shotover/src/message/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,7 @@ pub enum Encodable {
}

#[derive(PartialEq, Debug, Clone, Deserialize)]
#[serde(deny_unknown_fields)]
pub enum QueryType {
Read,
Write,
Expand Down
1 change: 1 addition & 0 deletions shotover/src/sources/cassandra.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use tokio::task::JoinHandle;
use tracing::{error, info};

#[derive(Deserialize, Debug, Clone)]
#[serde(deny_unknown_fields)]
pub struct CassandraConfig {
pub listen_addr: String,
pub connection_limit: Option<usize>,
Expand Down
1 change: 1 addition & 0 deletions shotover/src/sources/kafka.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use tokio::task::JoinHandle;
use tracing::{error, info};

#[derive(Deserialize, Debug, Clone)]
#[serde(deny_unknown_fields)]
pub struct KafkaConfig {
pub listen_addr: String,
pub connection_limit: Option<usize>,
Expand Down
2 changes: 2 additions & 0 deletions shotover/src/sources/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ pub mod kafka;
pub mod redis;

#[derive(Deserialize, Debug, Clone, Copy)]
#[serde(deny_unknown_fields)]
pub enum Transport {
Tcp,
WebSocket,
Expand All @@ -35,6 +36,7 @@ impl Source {
}

#[derive(Deserialize, Debug, Clone)]
#[serde(deny_unknown_fields)]
pub enum SourceConfig {
Cassandra(CassandraConfig),
Redis(RedisConfig),
Expand Down
1 change: 1 addition & 0 deletions shotover/src/sources/redis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use tokio::task::JoinHandle;
use tracing::{error, info};

#[derive(Deserialize, Debug, Clone)]
#[serde(deny_unknown_fields)]
pub struct RedisConfig {
pub listen_addr: String,
pub connection_limit: Option<usize>,
Expand Down
2 changes: 2 additions & 0 deletions shotover/src/tls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ use tokio_rustls::server::TlsStream as TlsStreamServer;
use tokio_rustls::{TlsAcceptor as RustlsAcceptor, TlsConnector as RustlsConnector};

#[derive(Serialize, Deserialize, Debug, Clone)]
#[serde(deny_unknown_fields)]
pub struct TlsAcceptorConfig {
/// Path to the certificate authority in PEM format
pub certificate_authority_path: Option<String>,
Expand Down Expand Up @@ -120,6 +121,7 @@ impl TlsAcceptor {
}

#[derive(Serialize, Deserialize, Debug, Clone)]
#[serde(deny_unknown_fields)]
pub struct TlsConnectorConfig {
/// Path to the certificate authority in PEM format
pub certificate_authority_path: String,
Expand Down
1 change: 1 addition & 0 deletions shotover/src/transforms/cassandra/peers_rewrite.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ use cql3_parser::select::SelectElement;
use serde::Deserialize;

#[derive(Deserialize, Debug)]
#[serde(deny_unknown_fields)]
pub struct CassandraPeersRewriteConfig {
pub port: u16,
}
Expand Down
2 changes: 2 additions & 0 deletions shotover/src/transforms/cassandra/sink_cluster/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ const SYSTEM_KEYSPACES: [IdentifierRef<'static>; 3] = [
];

#[derive(Deserialize, Debug)]
#[serde(deny_unknown_fields)]
pub struct CassandraSinkClusterConfig {
/// contact points must be within the specified data_center and rack.
/// If this is not followed, shotover's invariants will still be upheld but shotover will communicate with a
Expand Down Expand Up @@ -181,6 +182,7 @@ impl TransformBuilder for CassandraSinkClusterBuilder {
}

#[derive(Deserialize, Debug, Clone)]
#[serde(deny_unknown_fields)]
pub struct ShotoverNode {
pub address: SocketAddr,
pub data_center: String,
Expand Down
1 change: 1 addition & 0 deletions shotover/src/transforms/cassandra/sink_single.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ use tokio::sync::{mpsc, oneshot};
use tracing::trace;

#[derive(Deserialize, Debug)]
#[serde(deny_unknown_fields)]
pub struct CassandraSinkSingleConfig {
#[serde(rename = "remote_address")]
pub address: String,
Expand Down
1 change: 1 addition & 0 deletions shotover/src/transforms/coalesce.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ pub struct Coalesce {
}

#[derive(Deserialize, Debug)]
#[serde(deny_unknown_fields)]
pub struct CoalesceConfig {
pub flush_when_buffered_message_count: Option<usize>,
pub flush_when_millis_since_last_flush: Option<u128>,
Expand Down
2 changes: 2 additions & 0 deletions shotover/src/transforms/debug/force_parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ use serde::Deserialize;
/// Messages that pass through this transform will be parsed.
/// Must be individually enabled at the request or response level.
#[derive(Deserialize, Debug)]
#[serde(deny_unknown_fields)]
pub struct DebugForceParseConfig {
pub parse_requests: bool,
pub parse_responses: bool,
Expand All @@ -37,6 +38,7 @@ impl TransformConfig for DebugForceParseConfig {
/// Messages that pass through this transform will be parsed and then reencoded.
/// Must be individually enabled at the request or response level.
#[derive(Deserialize, Debug)]
#[serde(deny_unknown_fields)]
pub struct DebugForceEncodeConfig {
pub encode_requests: bool,
pub encode_responses: bool,
Expand Down
1 change: 1 addition & 0 deletions shotover/src/transforms/debug/log_to_file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use std::sync::Arc;
use tracing::{error, info};

#[derive(Deserialize, Debug)]
#[serde(deny_unknown_fields)]
pub struct DebugLogToFileConfig;

#[cfg(feature = "alpha-transforms")]
Expand Down
1 change: 1 addition & 0 deletions shotover/src/transforms/debug/printer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use serde::Deserialize;
use tracing::info;

#[derive(Deserialize, Debug)]
#[serde(deny_unknown_fields)]
pub struct DebugPrinterConfig;

#[typetag::deserialize(name = "DebugPrinter")]
Expand Down
2 changes: 2 additions & 0 deletions shotover/src/transforms/debug/returner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use async_trait::async_trait;
use serde::Deserialize;

#[derive(Deserialize, Debug)]
#[serde(deny_unknown_fields)]
pub struct DebugReturnerConfig {
#[serde(flatten)]
response: Response,
Expand All @@ -20,6 +21,7 @@ impl TransformConfig for DebugReturnerConfig {
}

#[derive(Debug, Clone, Deserialize)]
#[serde(deny_unknown_fields)]
pub enum Response {
#[serde(skip)]
Message(Messages),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use std::collections::HashMap;
use tracing::{error, warn};

#[derive(Deserialize, Debug)]
#[serde(deny_unknown_fields)]
pub struct TuneableConsistencyScatterConfig {
pub route_map: HashMap<String, TransformChainConfig>,
pub write_consistency: i32,
Expand Down
1 change: 1 addition & 0 deletions shotover/src/transforms/filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ pub struct QueryTypeFilter {
}

#[derive(Deserialize, Debug)]
#[serde(deny_unknown_fields)]
pub struct QueryTypeFilterConfig {
pub filter: QueryType,
}
Expand Down
1 change: 1 addition & 0 deletions shotover/src/transforms/kafka/sink_cluster.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ use tokio::time::timeout;
use uuid::Uuid;

#[derive(Deserialize, Debug)]
#[serde(deny_unknown_fields)]
pub struct KafkaSinkClusterConfig {
pub first_contact_points: Vec<String>,
pub shotover_nodes: Vec<String>,
Expand Down
1 change: 1 addition & 0 deletions shotover/src/transforms/kafka/sink_single.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ use tokio::sync::{mpsc, oneshot};
use tokio::time::timeout;

#[derive(Deserialize, Debug)]
#[serde(deny_unknown_fields)]
pub struct KafkaSinkSingleConfig {
#[serde(rename = "remote_address")]
pub address: String,
Expand Down
1 change: 1 addition & 0 deletions shotover/src/transforms/load_balance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use std::sync::Arc;
use tokio::sync::Mutex;

#[derive(Deserialize, Debug)]
#[serde(deny_unknown_fields)]
pub struct ConnectionBalanceAndPoolConfig {
pub name: String,
pub max_connections: usize,
Expand Down
1 change: 1 addition & 0 deletions shotover/src/transforms/null.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use async_trait::async_trait;
use serde::Deserialize;

#[derive(Deserialize, Debug)]
#[serde(deny_unknown_fields)]
pub struct NullSinkConfig;

#[typetag::deserialize(name = "NullSink")]
Expand Down
1 change: 1 addition & 0 deletions shotover/src/transforms/parallel_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ where
}

#[derive(Deserialize, Debug)]
#[serde(deny_unknown_fields)]
pub struct ParallelMapConfig {
pub parallelism: u32,
pub chain: TransformChainConfig,
Expand Down
1 change: 1 addition & 0 deletions shotover/src/transforms/protect/key_management.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ pub enum KeyManager {
}

#[derive(Deserialize, Debug, Clone)]
#[serde(deny_unknown_fields)]
pub enum KeyManagerConfig {
AWSKms {
region: String,
Expand Down
1 change: 1 addition & 0 deletions shotover/src/transforms/protect/local_kek.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ pub struct LocalKeyManagement {
}

#[derive(Clone, Serialize, Deserialize)]
#[serde(deny_unknown_fields)]
pub struct DEKStructure {
pub nonce: Nonce,
pub key: Vec<u8>,
Expand Down
1 change: 1 addition & 0 deletions shotover/src/transforms/protect/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ mod local_kek;
mod pkcs_11;

#[derive(Deserialize, Debug)]
#[serde(deny_unknown_fields)]
pub struct ProtectConfig {
pub keyspace_table_columns: HashMap<String, HashMap<String, Vec<String>>>,
pub key_manager: KeyManagerConfig,
Expand Down
1 change: 1 addition & 0 deletions shotover/src/transforms/query_counter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ pub struct QueryCounter {
}

#[derive(Deserialize, Debug)]
#[serde(deny_unknown_fields)]
pub struct QueryCounterConfig {
pub name: String,
}
Expand Down
3 changes: 3 additions & 0 deletions shotover/src/transforms/redis/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,14 @@ enum CacheableState {
}

#[derive(Deserialize, Debug)]
#[serde(deny_unknown_fields)]
pub struct TableCacheSchemaConfig {
partition_key: Vec<String>,
range_key: Vec<String>,
}

#[derive(Deserialize, Debug, Clone)]
#[serde(deny_unknown_fields)]
pub struct TableCacheSchema {
partition_key: Vec<Identifier>,
range_key: Vec<Identifier>,
Expand All @@ -74,6 +76,7 @@ impl From<&TableCacheSchemaConfig> for TableCacheSchema {
}

#[derive(Deserialize, Debug)]
#[serde(deny_unknown_fields)]
pub struct RedisConfig {
pub caching_schema: HashMap<String, TableCacheSchemaConfig>,
pub chain: TransformChainConfig,
Expand Down
1 change: 1 addition & 0 deletions shotover/src/transforms/redis/cluster_ports_rewrite.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use bytes::{BufMut, Bytes, BytesMut};
use serde::Deserialize;

#[derive(Deserialize, Debug)]
#[serde(deny_unknown_fields)]
pub struct RedisClusterPortsRewriteConfig {
pub new_port: u16,
}
Expand Down
1 change: 1 addition & 0 deletions shotover/src/transforms/redis/sink_cluster.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ const SLOT_SIZE: usize = 16384;
type ChannelMap = HashMap<String, Vec<UnboundedSender<Request>>>;

#[derive(Deserialize, Debug)]
#[serde(deny_unknown_fields)]
pub struct RedisSinkClusterConfig {
pub first_contact_points: Vec<String>,
pub direct_destination: Option<String>,
Expand Down
1 change: 1 addition & 0 deletions shotover/src/transforms/redis/sink_single.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ use tokio_util::codec::{FramedRead, FramedWrite};
use tracing::Instrument;

#[derive(Deserialize, Debug)]
#[serde(deny_unknown_fields)]
pub struct RedisSinkSingleConfig {
#[serde(rename = "remote_address")]
pub address: String,
Expand Down
1 change: 1 addition & 0 deletions shotover/src/transforms/redis/timestamp_tagging.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use std::time::{SystemTime, UNIX_EPOCH};
use tracing::{debug, trace};

#[derive(Deserialize, Debug)]
#[serde(deny_unknown_fields)]
pub struct RedisTimestampTaggerConfig;

#[typetag::deserialize(name = "RedisTimestampTagger")]
Expand Down
2 changes: 2 additions & 0 deletions shotover/src/transforms/tee.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ pub enum ConsistencyBehavior {
}

#[derive(Deserialize, Debug)]
#[serde(deny_unknown_fields)]
pub struct TeeConfig {
pub behavior: Option<ConsistencyBehaviorConfig>,
pub timeout_micros: Option<u64>,
Expand All @@ -104,6 +105,7 @@ pub struct TeeConfig {
}

#[derive(Deserialize, Debug)]
#[serde(deny_unknown_fields)]
pub enum ConsistencyBehaviorConfig {
Ignore,
FailOnMismatch,
Expand Down
1 change: 1 addition & 0 deletions shotover/src/transforms/throttling.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ use std::sync::Arc;
use super::Transforms;

#[derive(Deserialize, Debug)]
#[serde(deny_unknown_fields)]
pub struct RequestThrottlingConfig {
pub max_requests_per_second: NonZeroU32,
}
Expand Down

0 comments on commit 52f16ca

Please sign in to comment.