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

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

Merged
merged 3 commits into from
Jan 31, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading