Repository navigation
Ambassador Pattern #722 - #755
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. |
iluwatar
left a comment
There was a problem hiding this comment.
Well written pattern example. Please let me know when you've done the changes so we can merge it.
| --- | ||
|
|
||
| ## 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.
Isn't networking just one example of Ambassador usages? Could the description be more general?
|
|
||
| private RemoteService() { | ||
|
|
||
| } |
There was a problem hiding this comment.
This can be written on one line private RemoteService() {}. Please check whitespace usage elsewhere too.
| try { | ||
| sleep(DELAY_MS); | ||
| } catch (InterruptedException e) { | ||
| e.printStackTrace(); |
There was a problem hiding this comment.
Use logger for output. Check this elsewhere too.
| */ | ||
| public class Client { | ||
|
|
||
| private ServiceAmbassador serviceAmbassador; |
There was a problem hiding this comment.
Could be private final ServiceAmbassador serviceAmbassador = new ServiceAmbassador();
|
|
||
| long useService(int value) { | ||
| long result = serviceAmbassador.doRemoteFunction(value); | ||
| System.out.println(result); |
| 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.
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.
Not sure where this assertion comes from
| @Test | ||
| public void test() { | ||
| ServiceAmbassador ambassador = new ServiceAmbassador(); | ||
| long result = ambassador.doRemoteFunction(10); |
|
@iluwatar Changes have now been made. Only bit not changed was: |
iluwatar
left a comment
There was a problem hiding this comment.
Looks good. Thanks for the explanation.
Ambassador Pattern
Pull request description: