Skip to content

Commit

Permalink
Address comments
Browse files Browse the repository at this point in the history
Signed-off-by: Daniele Ahmed <[email protected]>
  • Loading branch information
82marbag authored and Daniele Ahmed committed Sep 16, 2022
1 parent 3c69d37 commit d3c6db0
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class ServerServiceGeneratorV2(

/** A `Writable` block containing all the `Handler` and `Operation` setters for the builder. */
private fun builderSetters(): Writable = writable {
val pluginType = listOf("Plugin")
val pluginType = listOf("Pl")
for ((index, pair) in builderFieldNames.zip(operationStructNames).withIndex()) {
val (fieldName, structName) = pair

Expand Down Expand Up @@ -161,7 +161,7 @@ class ServerServiceGeneratorV2(
crate::operation_shape::${symbolProvider.toSymbol(operation).name.toPascalCase()},
$exts,
B,
Plugin,
Pl,
>,
$type::Service: Clone + Send + 'static,
<$type::Service as #{Tower}::Service<#{Http}::Request<B>>>::Future: Send + 'static,
Expand All @@ -177,8 +177,9 @@ class ServerServiceGeneratorV2(
/** Returns a `Writable` containing the builder struct definition and its implementations. */
private fun builder(): Writable = writable {
val extensionTypesDefault = extensionTypes.map { "$it = ()" }
val pluginName = "Plugin"
val pluginName = "Pl"
val pluginTypeList = listOf(pluginName)
val newPluginType = "New$pluginName"
val pluginTypeDefault = listOf("$pluginName = #{SmithyHttpServer}::plugin::IdentityPlugin")
val structGenerics = (builderOps + extensionTypesDefault + pluginTypeDefault).joinToString(", ")
val builderGenerics = (builderOps + extensionTypes + pluginTypeList).joinToString(", ")
Expand All @@ -205,7 +206,7 @@ class ServerServiceGeneratorV2(
${builderFields.joinToString(", ")},
##[allow(unused_parens)]
_exts: std::marker::PhantomData<(${extensionTypes.joinToString(", ")})>,
plugin: Plugin,
plugin: $pluginName,
}
impl<$builderGenerics> $builderName<$builderGenerics> {
Expand All @@ -225,9 +226,9 @@ class ServerServiceGeneratorV2(
}
}
impl<$builderGenerics, NewPlugin> #{SmithyHttpServer}::plugin::Pluggable<NewPlugin> for $builderName<$builderGenerics> {
type Output = $builderName<$builderGenericsNoPlugin, aws_smithy_http_server::plugin::PluginStack<$pluginName, NewPlugin>>;
fn apply(self, plugin: NewPlugin) -> Self::Output {
impl<$builderGenerics, $newPluginType> #{SmithyHttpServer}::plugin::Pluggable<$newPluginType> for $builderName<$builderGenerics> {
type Output = $builderName<$builderGenericsNoPlugin, #{SmithyHttpServer}::plugin::PluginStack<$pluginName, $newPluginType>>;
fn apply(self, plugin: $newPluginType) -> Self::Output {
$builderName {
$setterFields,
_exts: self._exts,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ impl PokemonServiceVariant {
};

// Give PokémonService some time to start up.
time::sleep(Duration::from_millis(1000)).await;
time::sleep(Duration::from_millis(500)).await;

process
}
Expand Down
4 changes: 2 additions & 2 deletions rust-runtime/aws-smithy-http-server/src/operation/upgrade.rs
Original file line number Diff line number Diff line change
Expand Up @@ -279,13 +279,13 @@ pub struct MissingOperation;
/// This _does_ implement [`Upgradable`] but produces a [`Service`] which always returns an internal failure message.
pub struct FailOnMissingOperation;

impl<P, Op, Exts, B, Plugin> Upgradable<P, Op, Exts, B, Plugin> for FailOnMissingOperation
impl<P, Op, Exts, B, Pl> Upgradable<P, Op, Exts, B, Pl> for FailOnMissingOperation
where
InternalFailureException: IntoResponse<P>,
{
type Service = MissingFailure<P>;

fn upgrade(self, _plugin: &Plugin) -> Self::Service {
fn upgrade(self, _plugin: &Pl) -> Self::Service {
MissingFailure { _protocol: PhantomData }
}
}
Expand Down
4 changes: 2 additions & 2 deletions rust-runtime/aws-smithy-http-server/src/plugin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use crate::operation::Operation;
///
/// ```
/// # struct PrintPlugin;
/// # use crate::plugin::Pluggable;
/// # use aws_smithy_http_server::plugin::Pluggable;
/// trait PrintExt: Pluggable<PrintPlugin> {
/// fn print(self) -> Self::Output {
/// self.apply(&PrintPlugin);
Expand All @@ -29,7 +29,7 @@ pub trait Pluggable<NewPlugin> {
}

/// Maps one [`Operation`] to another,
/// parameterised by the protocol P and operation shape Op to allow for plugin behaviour to be specialised accordingly.
/// parameterised by the protocol `P` and operation shape `Op` to allow for plugin behaviour to be specialised accordingly.
///
/// This is passed to [`Pluggable::apply`] to modify the behaviour of the builder.
pub trait Plugin<P, Op, S, L> {
Expand Down

0 comments on commit d3c6db0

Please sign in to comment.