Migrating service initialization to use the Config
object
#3096
david-perez
announced in
Change Log
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Since smithy-rs 0.57.0, with the introduction of #3095, the methods:
builder_with_plugins
on the service builder,builder_without_plugins
on the service builder; andlayer
on the built serviceare deprecated. They will be removed in a future release.
Instead, a
${serviceName}Config
object is now generated, which serves as the central place to register plugins and layers.Previously, you used
builder_with_plugins
to initialize the service builder with a set of plugins, orbuilder_without_plugins
if you did not need any plugins. In both cases, you can now use the config builder object.Before:
Now:
Note you can also push multiple plugins directly onto
PokemonServiceConfig
:Similarly, you can now add layers onto
PokemonServiceConfig
. Before:Now:
The layers get applied in the same place as before, namely, uniformly around routes inside the router.
The methods have not been removed, only deprecated, so you can continue using them until a future release. Therefore, in most cases your code should not break. However, there is a breaking change in the service builder: it now has one extra type parameter representing the layers, for a total of 4 generic type parameters. This may affect you if, for example, you have a variable binding using type ascription:
Example breaking code:
Fix:
Beta Was this translation helpful? Give feedback.
All reactions