-
-
Notifications
You must be signed in to change notification settings - Fork 27k
Ambassador Pattern #722 #755
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
… and provides new client-side functionality. Need to clean up code, add tests and add descriptive comments.
…va. Removing added function in ServiceAmbassador as it's not appropriate for the example.
Requesting a review - please let me know if any changes or improvements should be made. |
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.
Well written pattern example. Please let me know when you've done the changes so we can merge it.
ambassador/README.md
Outdated
--- | ||
|
||
## Intent | ||
Provide a helper service that sends network requests on behalf of a client and offload common additional connectivity tasks. |
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.
Isn't networking just one example of Ambassador usages? Could the description be more general?
ambassador/README.md
Outdated
|
||
private RemoteService() { | ||
|
||
} |
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 can be written on one line private RemoteService() {}
. Please check whitespace usage elsewhere too.
ambassador/README.md
Outdated
try { | ||
sleep(DELAY_MS); | ||
} catch (InterruptedException e) { | ||
e.printStackTrace(); |
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.
Use logger for output. Check this elsewhere too.
*/ | ||
public class Client { | ||
|
||
private ServiceAmbassador serviceAmbassador; |
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.
Could be private final ServiceAmbassador serviceAmbassador = new ServiceAmbassador();
|
||
long useService(int value) { | ||
long result = serviceAmbassador.doRemoteFunction(value); | ||
System.out.println(result); |
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.
Use logger
private long checkLatency(int value) { | ||
RemoteService service = RemoteService.getRemoteService(); | ||
long startTime = System.currentTimeMillis(); | ||
long result = service.doRemoteFunction(value); |
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.
Could be written on one line RemoteService.getRemoteService().doRemoteFunction(value)
RemoteService remoteService = RemoteService.getRemoteService(); | ||
long result = remoteService.doRemoteFunction(10); | ||
|
||
assert result == 100 || result == -1; |
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.
Not sure where this assertion comes from
@Test | ||
public void test() { | ||
ServiceAmbassador ambassador = new ServiceAmbassador(); | ||
long result = ambassador.doRemoteFunction(10); |
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.
Could be written on one line
@iluwatar Changes have now been made. Only bit not changed was: |
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.
Looks good. Thanks for the explanation.
Ambassador Pattern
Pull request description: