Conversation
UncleSema
left a comment
There was a problem hiding this comment.
TinkoffClient стоит сделать синглтоном. В будущем мы добавить бд и получается, что либо ты собираешься там хранить TinkoffClient (у тебя это не получится) либо каждый раз, когда будешь вычитывать инфу из базы, создавать TinkoffClient для каждого из клиентов, что нехорошо для перформанса + лишние запросы
| } | ||
|
|
||
| public void subscribe(String token, List<String> figis) { | ||
| public void subscribe(TinkoffClient client, List<String> figis) { |
There was a problem hiding this comment.
Вынеси TinkoffClient как поле класса
| public void subscribe(TinkoffClient client, List<String> figis) { | ||
| log.info("New subscribe"); | ||
| CandleSubscriber subs = new CandleSubscriber(candlesProducer); | ||
| Consumer<Throwable> onErrorCallback = error -> log.error(error.toString()); |
There was a problem hiding this comment.
Стоит делать кстати чет типа log.error("Exception during trying to subscribe", error). Просто log.error(String, Throwable) выводит не только message ошибки, но и stack trace, что мб полезно
| throw new NoTinkoffAccountException(); | ||
| } | ||
| var mainAccountId = br.get(0).getId(); | ||
| public void subscribe(TinkoffClient client) { |
There was a problem hiding this comment.
Аналогично. Клиента в поле. Поменять способ логирования
| public void unsubscribe(String token) { | ||
| //TODO: check is that right? | ||
| api.remove(token); | ||
| public void unsubscribe(TinkoffClient client) { |
| import java.util.List; | ||
| import java.util.function.Consumer; | ||
|
|
||
| public class TinkoffClient { |
| try { | ||
| api.getInstrumentsService().getCurrencyByFigi(figi); | ||
| } catch (ApiRuntimeException e) { | ||
| answer = !e.getCode().equals("50002"); |
| public boolean isListOfFigisValid(List<String> figis) { | ||
| boolean yes = true; | ||
| for (String figi : figis) { | ||
| yes &= isFigiValid(figi); |
|
|
||
| public void subscribeOperations(OperationSubscriber subscriber, Consumer<Throwable> onErrorCallback) { | ||
| List<Account> accounts = getAccountsList(); | ||
| List<Account> br = accounts.stream().filter(s -> s.getType() == AccountType.ACCOUNT_TYPE_TINKOFF).toList(); |
There was a problem hiding this comment.
stream.findFirst() или stream.findAny()
|
|
||
| producer.sendMessage(Utilities.create(response.getCandle())); | ||
| } else { | ||
| log.info("Some other response..."); |
There was a problem hiding this comment.
log.warn("Got unknown message: {}", response)
|
|
||
| Candle tinkoffCandle = Candle.newBuilder(). | ||
| setLow( | ||
| Quotation.newBuilder(). |
There was a problem hiding this comment.
Сделай утилитный метод quotation(int, int), а то много одинакового кода
…eting?name=Semen (#21) Co-authored-by: Alexey Grunskii robochat@mail.ru
Нормально ли то, что init() будет вызываться перед каждым тестом, или можно как-то сделать, чтобы он вызвался один раз? (testAll() не помогает, т.к. его нужно делать статическим)