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

[Access] Make WebSocket responses from data providers consistent with Access REST API responses #6802

Open
wants to merge 39 commits into
base: master
Choose a base branch
from

Conversation

UlyanaAndrukhiv
Copy link
Contributor

@UlyanaAndrukhiv UlyanaAndrukhiv commented Dec 12, 2024

Closes: #6775

Note: this PR should be merged after #6818

Context

This pull request updates the WebSocket data providers to utilize the same models and response converters used by the Access REST API. By aligning the data processing logic, responses from WebSocket and REST API endpoints will now have consistent structure and content. Updated and added new unit tests to validate shared model usage.

@codecov-commenter
Copy link

codecov-commenter commented Dec 12, 2024

Codecov Report

Attention: Patch coverage is 51.53584% with 142 lines in your changes missing coverage. Please review.

Project coverage is 41.18%. Comparing base (72adf9e) to head (0eaf627).

Files with missing lines Patch % Lines
...e/access/rest/common/models/mock/link_generator.go 14.37% 129 Missing and 2 partials ⚠️
engine/access/rest/router/router.go 0.00% 5 Missing ⚠️
engine/access/rest/http/routes/blocks.go 70.00% 3 Missing ⚠️
.../rest/websockets/data_providers/blocks_provider.go 80.00% 2 Missing and 1 partial ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##           master    #6802    +/-   ##
========================================
  Coverage   41.18%   41.18%            
========================================
  Files        2109     2116     +7     
  Lines      185660   185866   +206     
========================================
+ Hits        76460    76549    +89     
- Misses     102788   102902   +114     
- Partials     6412     6415     +3     
Flag Coverage Δ
unittests 41.18% <51.53%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

// If the execution result is not yet available, it returns a nil execution result and no error.
//
// No errors are expected during normal operations.
func (p *BlocksDataProvider) getExecutionResult(b *flow.Block) (*flow.ExecutionResult, error) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We cannot use ExecutionResults from the block payload because they are not the execution results for this block. In the REST block response, the execution result specific to the block is expected. Therefore, I retrieve it from storage using the block ID.

@UlyanaAndrukhiv UlyanaAndrukhiv marked this pull request as ready for review December 26, 2024 16:21
subscription.HandleResponse(p.send, func(b *flow.Block) (interface{}, error) {
var block commonmodels.Block

executionResult, err := p.getExecutionResult(b)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you remind me why this is needed? I would expect the flow.Block object to already contain the correct execution results.

Copy link
Contributor Author

@UlyanaAndrukhiv UlyanaAndrukhiv Jan 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had a discussion with Yurii @durkmurder about execution results in flow.Block and the execution results from the flow.Block Payload cannot be used because they are not the execution result for this specific block.

Since the REST API block response is expected the execution result specific to this block, I retrieve it from storage by block ID.

Copy link
Contributor Author

@UlyanaAndrukhiv UlyanaAndrukhiv Jan 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Discussion result:

  1. Remove of expand as an argument for Websockets block subscription.
  2. Do not include theexecution result into block response.
  3. Always return the payload in block response.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Access] Make WebSocket responses from data providers consistent with Access REST API responses.
3 participants