You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There are many use-cases for decorating a client to provide additional functionality. Some common ones that have come up before are:
wrapping exceptions, either to cast them to another type, log them, or catch them and prevent them from raising
providing defaults for _request_options (especially headers) to every service call. This is useful for things like tracking ids, authentication headers, force-master-read, etc.
retry and timeout behaviour. Within a single application it's likely that these will remain pretty consistent, so providing a decorator allows you to re-use the values for all calls
Since our service calls aren't exposed directly from the SwaggerClient there is a bit more work involved to create a decorator (the SwaggerClient only exposes resources, the resources expose operation calls, which are what we want to decorate).
I think we should provide some support for this in bravado (potentially swagger-py as well, they should be reusable for both since the external interface is basically identical).
I think there are two potential options.
provide a ClientDecorator that knows how to decorate both the resources and operations. This option is less coupled with swagger-py itself, but requires more code.
have SwaggerClient accept a list of IOperationDecorator objects which conform to some interface and apply the decorators directly to the operation. More tightly coupled with swagger-py, but easier to implement.
I prefer the second option.
The text was updated successfully, but these errors were encountered:
There are many use-cases for decorating a client to provide additional functionality. Some common ones that have come up before are:
_request_options
(especially headers) to every service call. This is useful for things like tracking ids, authentication headers, force-master-read, etc.Since our service calls aren't exposed directly from the
SwaggerClient
there is a bit more work involved to create a decorator (theSwaggerClient
only exposes resources, the resources expose operation calls, which are what we want to decorate).I think we should provide some support for this in bravado (potentially swagger-py as well, they should be reusable for both since the external interface is basically identical).
I think there are two potential options.
ClientDecorator
that knows how to decorate both the resources and operations. This option is less coupled with swagger-py itself, but requires more code.SwaggerClient
accept a list ofIOperationDecorator
objects which conform to some interface and apply the decorators directly to the operation. More tightly coupled with swagger-py, but easier to implement.I prefer the second option.
The text was updated successfully, but these errors were encountered: