Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How do I configure the retry settings? #84

Open
lanmower opened this issue May 16, 2019 · 5 comments
Open

How do I configure the retry settings? #84

lanmower opened this issue May 16, 2019 · 5 comments
Labels
bug Something isn't working

Comments

@lanmower
Copy link

I would like to configure it to wait longer between retries... how would I go about doing that? I've been trying to figure out for days.

@matei-radu
Copy link
Contributor

@lanmower I've come up with a solution.

Assuming you are referring to the NodeosActionReader, you can extend it and create your own reader. Doing so, you can accept additional constructor options and propagate the number of retries and retry delay time to the existing implementations:

interface EnhancedNodeosActionReaderOptions extends NodeosActionReaderOptions {
  numRetries?: number;
  waitTimeMs?: number;
}

class EnhancedNodeosActionReader extends NodeosActionReader {
  private numRetries: number;
  private waitTimeMs: number;

  constructor(props: EnhancedNodeosActionReaderOptions) {
    super(props);

    this.numRetries = props.numRetries ? props.numRetries : 120; 
    this.waitTimeMs = props.waitTimeMs ? props.waitTimeMs : 250;
  }
 
  /**
   * Thin wrapper around the original implementation of `getBlock`.
   * We can now pass the optional `numRetries` and `waitTimeMs`.
   */
  public async getBlock(
    blockNumber: number,
    numRetries?: number,
    waitTimeMs?: number
  ): Promise<NodeosBlock> {
    return super.getBlock(
      blockNumber,
      numRetries ? numRetries : this.numRetries,
      waitTimeMs ? waitTimeMs : this.waitTimeMs
    );
  }

  // Other class methods that you can change...
}

In the above example only getBlock was changed but you can/should do the same thing for the other methods as well.

Finally, a new instance of EnhancedNodeosActionReader would look like this:

const actionReader = new EnhancedNodeosActionReader({
  nodeosEndpoint: "https://some-endpoint.com"
  startAtBlock: -1,
  // New options!
  numRetries: 3,
  waitTimeMs: 300
});

@matei-radu
Copy link
Contributor

However, I noticed today that the retry mechanism is broken, so there is no point in changing the retry parameters until this is fixed and released.

@lanmower
Copy link
Author

lanmower commented Jun 9, 2019

aah! i noticed it too :)

@chris-allnutt chris-allnutt added the bug Something isn't working label Aug 1, 2019
@lucasrcosta
Copy link

lucasrcosta commented Sep 20, 2019

Seems like the latest built release on NPM is different from the current source code and does not include the fix from #91.

@lanmower
Copy link
Author

lanmower commented Sep 27, 2019 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants