Questions regarding Exchange and Service's states and lifecycle
See original GitHub issueLet’s say we have the following code in my class.
this.exchange = ExchangeFactory.INSTANCE.createExchange(this.exchangeSpecification);
this.marketDataService = this.exchange.getMarketDataService();
this.accountService = this.exchange.getAccountService();
this.tradeService = this.exchange.getTradeService();
If I pass around the references to other classes, do I need to handle any synchronization or inconsistent state issue across classes when using these services?
Basically, I want to know during my program’s lifecycle, is it safe to assume I only need to create one instance of Exchange and pass its reference anywhere without worrying about any internal inconsistency?
Am I correct to assume so because it’s REST API so instance of Exchange doesn’t hold any internal state information and it’s just a set of interfaces.
Assuming the exchange specification is the same, does it mean, in no circumstance, that I need to recreate the instance of exchange and its services in case of exceptions? Once they are created, they are always valid to use?
Let me know if my questions are ambiguous and I’d structure them more clearly.
Issue Analytics
- State:
- Created 6 years ago
- Comments:14 (14 by maintainers)
Top GitHub Comments
I don’t know the exact exceptions but you can force them to happen by setting the two timeout values to 1ms. Obviously, you’ll need to do them one at a time because the read timeout won’t happen if the connection isn’t made.
it would be beneficial if this could be integrated with the rate-limiter discussion. mutex block with rate-limiting consideration.