Skip to content

Commit

Permalink
BE-682 | Set isBestEffort when there are no orderbooks in the system …
Browse files Browse the repository at this point in the history
…to process (#609)

* BE-682 | Set isBestEffort when there are no orderbooks in the system to process

Sets best effort flag for active-orders when there are no orderbooks in
the system ingested that may indicate issues with no data incoming
from the Node.
  • Loading branch information
deividaspetraitis authored Jan 31, 2025
1 parent e2980dc commit f89bc00
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ Ref: https://keepachangelog.com/en/1.0.0/

Unreleased

- #609 - BE-682 | Set isBestEffort when there are no orderbooks in the system to process
- #608 - BE-682 | Set isBestEffort on error processing orderbook active orders

## v28.1.0
Expand Down
7 changes: 7 additions & 0 deletions orderbook/usecase/orderbook_usecase.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,13 @@ func (o *OrderbookUseCaseImpl) GetActiveOrders(ctx context.Context, address stri
return nil, false, types.FailedGetAllCanonicalOrderbookPoolIDsError{Err: err}
}

// When there are no orderbooks, return early with best effort flag set to true
// Such cases are not considered an error, but it may indicate that the SQS
// is not receiving any orderbook data from the Node.
if len(orderbooks) == 0 {
return nil, true, nil
}

results := make(chan orderbookdomain.OrderbookResult, len(orderbooks))

// Process orderbooks concurrently
Expand Down
14 changes: 14 additions & 0 deletions orderbook/usecase/orderbook_usecase_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,20 @@ func (s *OrderbookUsecaseTestSuite) TestGetActiveOrders() {
address: "osmo1npsku4qlqav6udkvgfk9eran4s4edzu69vzdm6",
expectedError: &types.FailedGetAllCanonicalOrderbookPoolIDsError{},
},
{
name: "no canonical orderbook pool IDs",
setupContext: func() context.Context {
return context.Background()
},
setupMocks: func(usecase *orderbookusecase.OrderbookUseCaseImpl, orderbookrepository *mocks.OrderbookRepositoryMock, grpcclient *mocks.OrderbookGRPCClientMock, poolsUsecase *mocks.PoolsUsecaseMock, tokensusecase *mocks.TokensUsecaseMock) {
poolsUsecase.GetAllCanonicalOrderbookPoolIDsFunc = func() ([]domain.CanonicalOrderBooksResult, error) {
return nil, nil
}
},
address: "osmo1npsku4qlqav6udkvgfk9eran4s4edzu69vzdm6",
expectedError: nil,
expectedIsBestEffort: true,
},
{
name: "context is done before processing all orderbooks",
setupContext: func() context.Context {
Expand Down

0 comments on commit f89bc00

Please sign in to comment.