Open lanmower opened 5 years ago
@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
});
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.
aah! i noticed it too :)
Seems like the latest built release on NPM is different from the current source code and does not include the fix from #91.
I like the idea, I guess if demux wasn't abandoned 3-4 months ago I'd be happily testing and improving the code...
I ended up writing a simple block by block reader, which is way way dumber and less refined than demux, but at least it works, demux is unusable without it recovering from failure properly, and it could take a day to test and fix it but it could take a month.
On Fri, Jun 7, 2019 at 11:30 PM Matei Radu notifications@github.com wrote:
@lanmower https://github.com/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 optionalnumRetries
andwaitTimeMs
. / public async getBlock( blockNumber: number, numRetries?: number, waitTimeMs?: number ): Promise{ 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 });
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/EOSIO/demux-js-eos/issues/84?email_source=notifications&email_token=AAFAPI2JG46NRCJMMZYH3HTPZLHN7A5CNFSM4HNJR5V2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODXHBLVY#issuecomment-500045271, or mute the thread https://github.com/notifications/unsubscribe-auth/AAFAPI3XOMAVIE533GWG7WTPZLHN7ANCNFSM4HNJR5VQ .
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.