Code Monkey home page Code Monkey logo

Comments (6)

fearthecowboy avatar fearthecowboy commented on August 11, 2024

@deathly809

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.

deathly809 avatar deathly809 commented on August 11, 2024

@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.

fearthecowboy avatar fearthecowboy commented on August 11, 2024

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.

deathly809 avatar deathly809 commented on August 11, 2024

@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.

fearthecowboy avatar fearthecowboy commented on August 11, 2024

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.

deathly809 avatar deathly809 commented on August 11, 2024

@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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.