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

Add helpers at /apis/{apiName}/listeners/{eventPath} #696

Merged
merged 13 commits into from
Apr 12, 2022

Conversation

awrichar
Copy link
Contributor

@awrichar awrichar commented Apr 11, 2022

This includes the commit from #693.

Add helper URLs:

GET /apis/{apiName}/listeners/{eventPath} - list all listeners matching this event on this API
POST /apis/{apiName}/listeners/{eventPath} - create a new listener for this event on this API

Also makes topic a required field for contract listeners, and enforces uniqueness of listeners across these 2 dimensions:

  • namespace + name
  • topic + contract location + event signature

Violating either uniqueness constraint when attempting to create a listener will result in HTTP 409, so applications can rely on this behavior to perform "create this listener if it does not already exist". Note that name is still optional, and a unique one will be assigned at creation time if none is specified.

Signed-off-by: Andrew Richardson <andrew.richardson@kaleido.io>
Signed-off-by: Andrew Richardson <andrew.richardson@kaleido.io>
Signed-off-by: Andrew Richardson <andrew.richardson@kaleido.io>
Signed-off-by: Andrew Richardson <andrew.richardson@kaleido.io>
These are used only for reporting and filtering on Prometheus.

Signed-off-by: Andrew Richardson <andrew.richardson@kaleido.io>
Signed-off-by: Andrew Richardson <andrew.richardson@kaleido.io>
@awrichar awrichar force-pushed the listen branch 2 times, most recently from 56460f4 to 4dfe60d Compare April 12, 2022 03:39
GET and POST to list matching listeners or create new ones.

Signed-off-by: Andrew Richardson <andrew.richardson@kaleido.io>
The same purpose is served by the root /contract/invoke and
/contracts/query endpoints, when passing an interface ID.

Also split "methodPath" out as a separate parameter, so it's
clear that you must specify either it or "method".

Signed-off-by: Andrew Richardson <andrew.richardson@kaleido.io>
@codecov-commenter
Copy link

codecov-commenter commented Apr 12, 2022

Codecov Report

Merging #696 (87e5a23) into main (09a7cc6) will not change coverage.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##              main      #696    +/-   ##
==========================================
  Coverage   100.00%   100.00%            
==========================================
  Files          323       323            
  Lines        19770     19874   +104     
==========================================
+ Hits         19770     19874   +104     
Impacted Files Coverage Δ
pkg/fftypes/contract_listener.go 100.00% <ø> (ø)
pkg/fftypes/contracts.go 100.00% <ø> (ø)
...rnal/apiserver/route_get_contract_api_listeners.go 100.00% <100.00%> (ø)
internal/apiserver/route_get_contract_apis.go 100.00% <100.00%> (ø)
...nternal/apiserver/route_get_contract_interfaces.go 100.00% <100.00%> (ø)
...nal/apiserver/route_post_contract_api_listeners.go 100.00% <100.00%> (ø)
internal/blockchain/ethereum/ethereum.go 100.00% <100.00%> (ø)
internal/blockchain/fabric/fabric.go 100.00% <100.00%> (ø)
internal/contracts/manager.go 100.00% <100.00%> (ø)
...ternal/database/sqlcommon/contractlisteners_sql.go 100.00% <100.00%> (ø)
... and 3 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 09a7cc6...87e5a23. Read the comment docs.

Signed-off-by: Andrew Richardson <andrew.richardson@kaleido.io>
Copy link
Contributor

@peterbroadhurst peterbroadhurst left a comment

Choose a reason for hiding this comment

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

Few questions from me here @awrichar

internal/blockchain/ethereum/ethereum.go Outdated Show resolved Hide resolved
internal/blockchain/ethereum/ethereum.go Show resolved Hide resolved
internal/blockchain/fabric/fabric.go Show resolved Hide resolved
internal/oapiffi/ffi2swagger.go Show resolved Hide resolved
@peterbroadhurst
Copy link
Contributor

Also, in the header comment of the PR (and soon in API descriptions fyi @nguyer ) would be good to note the 409 conflict behavior that allows apps the ability to do a create-if-not-exist check on startup with this great new API.

Signed-off-by: Andrew Richardson <andrew.richardson@kaleido.io>
Signed-off-by: Andrew Richardson <andrew.richardson@kaleido.io>
Signed-off-by: Andrew Richardson <andrew.richardson@kaleido.io>
Copy link
Contributor

@peterbroadhurst peterbroadhurst left a comment

Choose a reason for hiding this comment

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

👍

@awrichar awrichar merged commit c9ae803 into hyperledger:main Apr 12, 2022
@awrichar awrichar deleted the listen branch April 12, 2022 22:18
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.

3 participants