-
Notifications
You must be signed in to change notification settings - Fork 30
Add service info retrieving [ECR-3859] #1247
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
Conversation
* | ||
* @param serviceName the name of a service instance | ||
*/ | ||
Optional<ServiceInfo> getServiceInfoByName(String serviceName); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shall we use get or find prefix to highlight it returns an Optional?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed to findServiceInfoByName
Optional<ServiceInfo> getServiceInfoByName(String serviceName); | ||
|
||
/** | ||
* Returns the list of service info of all started service instances. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Returns information on/about all started service instances.
@see #getServiceInfoByName
String name; | ||
|
||
/** | ||
* Service id. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it must use just as good documentation as com.exonum.binding.core.runtime.ServiceInstanceSpec
.
} | ||
|
||
@Test | ||
void getServiceInfoByInvalidName() throws InterruptedException { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The name seems OK in this case, but the service is not found by the name. Unknown name/NotFound.
exonum-light-client/README.md
Outdated
|
||
|
||
### Retrieving service info | ||
To build a transaction, service id is needed. It can be obtained with either |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This documentation seems out of place. I think it shall be included in the section on creating a transaction message, saying that the service id, required to create a message, can be obtained, if needed, by the service name:
// Update the code to be correct and compile!
int serviceId = exonumClient.getServiceInfoByName(serviceName)
.mapToInt(#getId)
.orElseThrow(() -> new IllegalStateException("No service with the given name found: " + serviceName);
This section may remain, but rewritten as just the way to get information on active services in the blockchain.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but rewritten as just the way to get information on active services in the blockchain.
It still starts as "To build a transaction, service id is needed."
exonum-light-client/README.md
Outdated
|
||
|
||
### Retrieving service info | ||
To build a transaction, service id is needed. It can be obtained with either |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but rewritten as just the way to get information on active services in the blockchain.
It still starts as "To build a transaction, service id is needed."
* @param serviceName the name of a service instance | ||
*/ | ||
Optional<ServiceInfo> getServiceInfoByName(String serviceName); | ||
Optional<ServiceInfo> findServiceInfoByName(String serviceName); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe drop ByName
since it must be clear enough from the parameter list and there are no other String query parameters (i.e., no BySomeOtherStringProperty
that won't work with overloads)?
|
||
List<ServiceInfo> actual = ExplorerApiHelper.parseServicesResponse(json); | ||
assertThat(actual, contains(expected.toArray())); | ||
int serviceId = Optional.of(serviceInfo1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That must be a draft.
List<ServiceInfo> actual = ExplorerApiHelper.parseServicesResponse(json); | ||
assertThat(actual, contains(expected.toArray())); | ||
int serviceId = Optional.of(serviceInfo1) | ||
.map(ServiceInfo::getId) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will mapToInt
be more appropriate (in the example also)? OptionalInt also has https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/OptionalInt.html#orElseThrow(java.util.function.Supplier)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, either I don't understand what exactly do you propose here or it's something like
int serviceId = Optional.of(serviceInfo1).stream()
.mapToInt(ServiceInfo::getId)
.findFirst()
.orElseThrow(() -> new IllegalStateException("No service with the given name found: " + serviceName);
which doesn't seem better to me.
Optional
doesn't have mapToInt
method.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, sorry, I must have missed there is no mapToInt in Optional. It's good then, a stream is certainly inferior.
exonum-light-client/src/test/java/com/exonum/client/ExplorerApiHelperTest.java
Show resolved
Hide resolved
Why does it target ECR-3860 and not |
Overview
Add service info retrieving.
Targeted into
ECR-3860
until it's merged.See: https://jira.bf.local/browse/ECR-3859
Definition of Done