Comments (6)
Is this something you'd like to implement once across all cmdlets, or are you thinking it would only apply to specific cmdlets?
If it's once for everything, then I can add an extensibility point in the Module
class where you could create a 'Module.cs' file in the custom
folder:
namespace Sample.API.Whatever {
public partial class Module {
void AfterCreatePipeline(System.Management.Automation.InvocationInfo invocationInfo, ref Microsoft.Azure.PowerShell.Cmdlets.BridgeAdmin.Runtime.HttpPipeline pipeline)
{
// append this step to the
pipeline.Append(retryOn427);
}
public async System.Threading.Tasks.Task<System.Net.Http.HttpResponseMessage> retryOn427( System.Net.Http.HttpRequestMessage requestMessage, Runtime.IEventListener listener, Runtime.ISendAsync next )
{
var count = 3;
System.Net.Http.HttpResponseMessage result = null;
while( true )
{
// make the call
result = await next.SendAsync(requestMessage,listener);
// check to see if we want to retry
if( 427 == (int)result.StatusCode && count-- >= 0 ) {
// wait before retrying
await System.Threading.Tasks.Task.Delay(10000);
continue;
}
// apparently not retrying, let's get out.
break;
};
// return whatever we have.
return result;
}
}
}
from autorest.powershell.
@fearthecowboy This is for specific cmdlets I believe. Usually related cmdlets which might cause a service to migrate to another node which would cause a blip and the cmdlet to fail. I don't think it would hurt to add it for an entire module though. I will need to reach out to the team that asked for this, we had a re-org and I need to find out who owns this now.
from autorest.powershell.
Hopefully it's ok for all, if its not, I'm pretty sure I can give you another alternative that tweaks the pipeline on a per-cmdlet basis; the only downside is that you'd have to implement tiny partial class for each one.
It's also possible I could craft a directive you could use.
G
from autorest.powershell.
@fearthecowboy I can't imagine anything bad can happen. But, that is how bugs happen I guess lol.
Too bad we can provide a class that allows us to Inherit from your class where we can define a method that you call after you add all the default handlers i.e
public async System.Threading.Tasks.Task<System.Net.Http.HttpResponseMessage> FinalHandler( System.Net.Http.HttpRequestMessage requestMessage, Runtime.IEventListener listener, Runtime.ISendAsync next );
from autorest.powershell.
That's actually not too hard to implement -- generated cmdlets only inherit from PSCmdlet
-- we don't force a weird base class.
Would be a small directive to alter the inheritance on a subset of cmdlets so you could make a class inherit from PSCmdlet and the generated cmdlets could inherit from that.
I was thinking of that ; just want to see if a partial
method in a child class can be fulfilled by a base class.
from autorest.powershell.
@fearthecowboy What would the tag thing entail? Could we provide something in the spec itself? Something like x-ms-failover-aware?
from autorest.powershell.
Related Issues (20)
- Module will be created and inited many times in one session when `-Parallel` is used. HOT 2
- Monitor Metric Get-AzMetricsBatch encode name parameter twice HOT 1
- [Feature] Generate cmdlet to Add/remove elements for a complex array parameter HOT 1
- [Feature] Generate parameter description with possbile values. HOT 2
- Parameter Capability is an array, enum is the items, value should be generated HOT 2
- build-module.ps1 - The parameter 'Body' has multiple parameter types HOT 1
- Dockerfile needs updating HOT 2
- Test-Module: Import Az.Accounts should not be required HOT 3
- Infinite recursion issue when traversing object properties HOT 2
- Remove use of write-information as it pollutes information stream when loading Az-modules
- format url is invalid type when generating with autorest 3.x HOT 2
- Add support for 'operation-location' for dataplane LRO(Long Running Operations) HOT 2
- Module fails to build due to duplicate definitions HOT 2
- MG-graph Mail Forward issue HOT 1
- Module fails to build due to missing arguments HOT 8
- Parameter name is a duplicate HOT 4
- Synopsis/Description does not support newlines
- Question: Will multiple servers in openapi generate a param for selecting the server per cmdlet? HOT 2
- Generate quote for angle bracket in doc
- question mark in link got removed
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from autorest.powershell.