You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: ambassador/README.md
+39-10Lines changed: 39 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,28 +10,37 @@ tags:
10
10
---
11
11
12
12
## Intent
13
+
13
14
Provide a helper service instance on a client and offload common functionality away from a shared resource.
14
15
15
16
## Explanation
17
+
16
18
Real world example
17
19
18
-
> A remote service has many clients accessing a function it provides. The service is a legacy application and is impossible to update. Large numbers of requests from users are causing connectivity issues. New rules for request frequency should be implemented along with latency checks and client-side logging.
20
+
> A remote service has many clients accessing a function it provides. The service is a legacy application and is
21
+
> impossible to update. Large numbers of requests from users are causing connectivity issues. New rules for request
22
+
> frequency should be implemented along with latency checks and client-side logging.
19
23
20
24
In plain words
21
25
22
-
> Using the ambassador pattern, we can implement less-frequent polling from clients along with latency checks and logging.
26
+
> With the Ambassador pattern, we can implement less-frequent polling from clients along with latency checks and
27
+
> logging.
23
28
24
29
Microsoft documentation states
25
30
26
-
> An ambassador service can be thought of as an out-of-process proxy that is co-located with the client. This pattern can be useful for offloading common client connectivity tasks such as monitoring, logging, routing, security (such as TLS), and resiliency patterns in a language agnostic way. It is often used with legacy applications, or other applications that are difficult to modify, in order to extend their networking capabilities. It can also enable a specialized team to implement those features.
31
+
> An ambassador service can be thought of as an out-of-process proxy which is co-located with the client. This pattern
32
+
> can be useful for offloading common client connectivity tasks such as monitoring, logging, routing,
33
+
> security (such as TLS), and resiliency patterns in a language agnostic way. It is often used with legacy applications,
34
+
> or other applications that are difficult to modify, in order to extend their networking capabilities. It can also
35
+
> enable a specialized team to implement those features.
27
36
28
37
**Programmatic Example**
29
38
30
-
With the above example in mind we will imitate the functionality in a simple manner. We have an interface implemented by the remote service as well as the ambassador service:
39
+
With the above introduction in mind we will imitate the functionality in this example. We have an interface implemented
40
+
by the remote service as well as the ambassador service:
31
41
32
42
```java
33
43
interfaceRemoteServiceInterface {
34
-
35
44
longdoRemoteFunction(intvalue) throwsException;
36
45
}
37
46
```
@@ -136,7 +145,7 @@ public class Client {
136
145
}
137
146
```
138
147
139
-
And here are two clients using the service.
148
+
Here are two clients using the service.
140
149
141
150
```java
142
151
publicclassApp {
@@ -149,13 +158,29 @@ public class App {
149
158
}
150
159
```
151
160
161
+
Here's the output for running the example:
162
+
163
+
```java
164
+
Time taken (ms):111
165
+
Service result:120
166
+
Time taken (ms):931
167
+
Failed to reach remote: (1)
168
+
Time taken (ms):665
169
+
Failed to reach remote: (2)
170
+
Time taken (ms):538
171
+
Failed to reach remote: (3)
172
+
Service result:-1
173
+
```
174
+
152
175
## Class diagram
176
+
153
177

154
178
155
179
## Applicability
156
-
Ambassador is applicable when working with a legacy remote service that cannot
157
-
be modified or would be extremely difficult to modify. Connectivity features can
158
-
be implemented on the client avoiding the need for changes on the remote service.
180
+
181
+
Ambassador is applicable when working with a legacy remote service which cannot be modified or would be extremely
182
+
difficult to modify. Connectivity features can be implemented on the client avoiding the need for changes on the remote
183
+
service.
159
184
160
185
* Ambassador provides a local interface for a remote service.
161
186
* Ambassador provides logging, circuit breaking, retries and security on the client.
@@ -168,10 +193,14 @@ be implemented on the client avoiding the need for changes on the remote service
168
193
* Offload remote service tasks
169
194
* Facilitate network connection
170
195
171
-
## Real world examples
196
+
## Known uses
172
197
173
198
*[Kubernetes-native API gateway for microservices](https://github.com/datawire/ambassador)
*[Design Patterns: Elements of Reusable Object-Oriented Software](https://www.amazon.com/gp/product/0201633612/ref=as_li_tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=0201633612&linkCode=as2&tag=javadesignpat-20&linkId=675d49790ce11db99d90bde47f1aeb59)
0 commit comments