Skip to content

Commit d508715

Browse files
authored
Merge pull request #20 from kanishkarj/master
Readme update
2 parents 25f6230 + e9f1971 commit d508715

1 file changed

Lines changed: 49 additions & 61 deletions

File tree

README.md

Lines changed: 49 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -28,106 +28,94 @@ The Learn Layer5 sample application is to be available for use across all servic
2828
- for [Service Mesh Interface conformance](https://docs.google.com/document/d/1HL8Sk7NSLLj-9PRqoHYVIGyU6fZxUQFotrxbmfFtjwc/edit#)
2929

3030
## Application Architecture
31-
The Learn Layer5 application includes three services: `app-a`, `app-b`, and `app-c`. Each service is listening on port `9091/tcp`.
31+
The Learn Layer5 application includes three services: `app-a`, `app-b`, and `app-c`. Though they are different services, they are defines using the same app (source code in ./service). Each service is listening on port `9091/tcp`.
3232

3333
### Service
3434

3535
The following are the routes defined by the `service` app and their functionality.
3636

3737
#### POST /call
3838

39-
This is the route whose metrics will be collected by the app. This route can be used to make the service call any other web service.
39+
This route makes the service make requests to another service. Metrics are collected for this route. sample usage given below:
4040

41-
Simple POST request
42-
```shell
43-
# Command
44-
curl --location --request POST 'http://localhost:9091/call' \
45-
--data-raw ''
46-
# No Output
47-
```
4841

49-
`service` makes a POST request to `"http://httpbin.org/post"`.
5042
```shell
5143
# Command
52-
curl --location --request POST 'http://localhost:9091/call' \
44+
curl --location --request POST 'http://service-a:9091/call' \
5345
--header 'Content-Type: application/json' \
5446
--data-raw '{
55-
"host": "http://httpbin.org/post",
56-
"body": "{\n\t\"hello\": \"bye\"\n}"
47+
"url": "http://service-b:9091/call",
48+
"body": "{\r\n\"url\": \"http:\/\/service-c:9091\/echo\",\r\n\"body\": \"\",\r\n\"method\": \"GET\"\r\n}",
49+
"method": "POST",
50+
"headers": {
51+
"h1":"v1"
52+
}
5753
}'
58-
# Output
54+
55+
# No Output
56+
GET /echo HTTP/1.1
57+
Host: service-c:9091
58+
User-Agent: Go-http-client/1.1
59+
Accept-Encoding: gzip
60+
Servicename: Service-B
61+
```
62+
63+
In the above example, we are making a post request from `service-a` with the body:
64+
```json
5965
{
60-
"args": {},
61-
"data": "{\n\t\"hello\": \"bye\"\n}",
62-
"files": {},
63-
"form": {},
66+
"url": "http://service-b:9091/call",
67+
"body": "{\r\n\"url\": \"http:\/\/service-c:9091\/echo\",\r\n\"body\": \"\",\r\n\"method\": \"GET\"\r\n}",
68+
"method": "POST",
6469
"headers": {
65-
"Accept-Encoding": "gzip",
66-
"Content-Length": "19",
67-
"Content-Type": "application/json",
68-
"Host": "httpbin.org",
69-
"User-Agent": "Go-http-client/1.1",
70-
},
71-
"json": {
72-
"hello": "bye"
73-
},
74-
"origin": "...",
75-
"url": "http://httpbin.org/post"
70+
"h1":"v1"
71+
}
7672
}
7773
```
78-
79-
`service` makes a get request (as body is not provided) to `http://httpbin.org/get`.
80-
```shell
81-
# Command
82-
curl --location --request POST 'http://localhost:9091/call' \
83-
--header 'Content-Type: application/json' \
84-
--data-raw '{
85-
"host": "http://httpbin.org/get",
86-
}'
87-
# Output
74+
This will make `service-a` to make a `POST` request to `http://service-b:9091/call` with the headers specified above, and the body:
75+
```json
8876
{
89-
"args": {},
90-
"headers": {
91-
"Accept-Encoding": "gzip",
92-
"Host": "httpbin.org",
93-
"User-Agent": "Go-http-client/1.1",
94-
},
95-
"origin": "...",
96-
"url": "http://httpbin.org/get"
77+
"url": "http://service-c:9091/echo",
78+
"body":"",
79+
"method": "GET"
9780
}
9881
```
82+
This inturn will make `service-b` to make a `GET` request to `http://service-c:9091/echo`.
9983

10084
#### GET /metrics
10185

102-
Gets the metrics from `service`
86+
Gets the metrics from `service-a`
10387
```shell
10488
# Command
105-
curl --location --request GET 'localhost:9091/metrics' \
106-
--header 'Content-Type: application/json' \
107-
--data-raw '{
108-
"hello": "bye"
109-
}'
89+
curl --location --request GET 'http://service-b:9091/metrics'
11090
# Output
11191
{
112-
"requestsReceived": "19", # Total requests service recieved
113-
"responsesFailed": "3", # The responses of the requests the service made that failed
114-
"responsesSucceeded": "7" # The responses of the requests the service made that succeeded
92+
"ReqReceived": [
93+
"Service-A"
94+
],
95+
"RespSucceeded": [
96+
{
97+
"URL": "http://service-c:9091/echo",
98+
"Method": "GET",
99+
"Headers": null
100+
}
101+
],
102+
"RespFailed": []
115103
}
116104
```
105+
* In ReqReceived we see list of requests `service-b` received and from whom it received. Here we see `service-A`. Actually each of the service sets a header `ServiceName` which is read by the service to determine the sender.
106+
* As `service-b` made a request to `service-c` and the request succeeded, we can see the details in the list of successful responses (RespSucceeded).
117107

118108
#### DELETE /metrics
119109

120110
Clears the counters in `service`
121111
```shell
122112
# Command
123-
curl --location --request DELETE 'localhost:9091/metrics' \
124-
--header 'Content-Type: application/json' \
125-
--data-raw '{
126-
"hello": "bye"
127-
}'
113+
curl --location --request DELETE 'http://34.68.35.174:9091/metrics'
128114
# No Output
129115
```
130116

117+
> Note: metrics are collected only for `/call` and `/echo`.
118+
131119
<br /><br /><p align="center"><i>If you’re using Learn Layer5 or if you like the project, please <a href="https://github.com/layer5io/meshery/stargazers">★</a> star this repository to show your support! 🤩</i></p>
132120
</p>
133121

0 commit comments

Comments
 (0)