Skip to content

Commit bc6a8b9

Browse files
authored
Merge pull request #354 from microsoft/lc_LRO
Edited LRO doc
2 parents 278f3fa + d0f66a7 commit bc6a8b9

File tree

1 file changed

+46
-52
lines changed

1 file changed

+46
-52
lines changed

graph/patterns/longRunningOperations.md

Lines changed: 46 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,101 +1,95 @@
1-
# Long Running Operations
1+
# Long running operations
22

33
Microsoft Graph API Design Pattern
44

5-
### *The Long Running Operations (LRO) pattern provides the ability to model operations where processing a client request takes a long time, but the client isn't blocked and can do some other work until operation completion.*
5+
__*The long running operations (LRO) pattern provides the ability to model operations where processing a client request takes a long time, but the client isn't blocked and can do some other work until operation completion.*__
66

77
## Problem
88

9-
The API design requires modeling operations on resources which takes long time
9+
The API design requires modeling operations on resources, which takes a long time
1010
to complete so that API clients don't need to wait and can continue doing other
11-
work while waiting for the final operation result. The client should be able to
11+
work while waiting for the final operation results. The client should be able to
1212
monitor the progress of the operation and have an ability to cancel it if
13-
needed.The API needs to provide a mechanism to track the work
13+
needed. The API needs to provide a mechanism to track the work
1414
being done in the background. The mechanism needs to be expressed in the same
15-
web style as other interactive APIs and support checking on the status and/or
15+
web style as other interactive APIs. It also needs to support checking on the status and/or
1616
being notified asynchronously of the results.
1717

1818
## Solution
1919

20-
The solution is to model the API as a synchronous service which returns a
21-
resource representing the eventual completion or failure of a long-running
20+
The solution is to model the API as a synchronous service that returns a
21+
resource that represents the eventual completion or failure of a long running
2222
operation.
2323

2424
There are two flavors of this solution:
2525

26-
1. The returned resource is the targeted resource and includes the status of
27-
the operation. This pattern is often called RELO (Resource based
28-
Long-running Operation).
29-
//image
26+
- The returned resource is the targeted resource and includes the status of
27+
the operation. This pattern is often called RELO (resource-based
28+
long running operation).
29+
3030
<!-- markdownlint-disable MD033 -->
3131
<p align="center">
3232
<img src="RELO.gif" alt="The status monitor LRO flow"/>
3333
</p>
3434
<!-- markdownlint-enable MD033 -->
35-
2. The returned resource is a new API resource called 'Stepwise Operation' and
35+
36+
- The returned resource is a new API resource called 'Stepwise Operation' and
3637
is created to track the status. This LRO solution is similar to the concept
3738
of Promises or Futures in other programming languages.
38-
//image
39+
3940
<!-- markdownlint-disable MD033 -->
4041
<p align="center">
4142
<img src="LRO.gif" alt="The status monitor LRO flow"/>
4243
</p>
4344
<!-- markdownlint-enable MD033 -->
44-
RELO pattern is the preferred pattern for long running operations and should be
45-
used wherever possible. The pattern avoids complexity and consistent resource
45+
46+
The RELO pattern is the preferred pattern for long running operations and should be
47+
used wherever possible. The pattern avoids complexity, and consistent resource
4648
presentation makes things simpler for our users and tooling chain.
4749

48-
In general Microsoft Graph APIs guidelines for LRO follow [Microsoft REST API
50+
In general, Microsoft Graph API guidelines for LRO follow [Microsoft REST API
4951
Guidelines](https://github.com/microsoft/api-guidelines/blob/vNext/Guidelines.md#13-long-running-operations).
5052

51-
A single deviation from the base guidelines is that Microsoft Graph API
52-
standards require using the following response headers:
53-
54-
- Content-Location header indicates location of a RELO resource.
55-
56-
- API response says the targeted resource is being created by returning 201 status code and the resource URI provided in the Content-Location header , but indicates the request is
57-
not completed by including "Provisioning" status.
53+
A single deviation from the base guidelines is that Microsoft Graph API standards require that you use the following response headers:
5854

59-
- Location header indicates location of a new stepwise operation LRO resource.
60-
61-
- API response says the operation resource is being created at the URL
62-
provided in the Location header and indicates the request is
63-
not completed by including a 202 status code.
55+
- The Content-Location header indicates the location of a RELO resource.
56+
- The API response says the targeted resource is being created by returning a 201 status code and the resource URI is provided in the Content-Location header, but the response indicates that the request is not completed by including "Provisioning" status.
6457

65-
## When to Use this Pattern
58+
- The Location header indicates the location of a new stepwise operation LRO resource.
59+
- The API response says the operation resource is being created at the URL provided in the Location header and indicates that the request is not completed by including a 202 status code.
6660

61+
## When to use this pattern
6762

68-
Any API call that is expected to take longer than 1 seconds in the 99th percentile, should use Long-running Operations pattern.
63+
Any API call that is expected to take longer than 1 second in the 99th percentile should use the long running operations pattern.
6964

70-
How to select which flavor of LRO pattern to use? API designer can follow these
65+
How do you select which flavor of LRO pattern to use? An API designer can follow these
7166
heuristics:
7267

7368
1. If a service can create a resource with a minimal latency and continue
7469
updating its status according to the well-defined and stable state
75-
transition model until completion then RELO model is the best choice.
70+
transition model until completion, then the RELO model is the best choice.
7671

77-
2. Otherwise a service should follow the Stepwise Operation pattern.#
72+
2. Otherwise, a service should follow the Stepwise Operation pattern.
7873

7974

80-
## Issues and Considerations
75+
## Issues and considerations
8176

82-
- One or more clients MUST be able to monitor and operate on the same resource
83-
at the same time.
77+
- One or more clients MUST be able to monitor and operate on the same resource at the same time.
8478

85-
- The state of the system SHOULD be always discoverable and testable. Clients
79+
- The state of the system SHOULD always be discoverable and testable. Clients
8680
SHOULD be able to determine the system state even if the operation tracking
8781
resource is no longer active. Clients MAY issue a GET on some resource to
88-
determine the state of a long running operation
82+
determine the state of a long running operation.
8983

90-
- Long running operations SHOULD work for clients looking to "Fire and Forget"
84+
- The long running operations pattern SHOULD work for clients looking to "fire and forget"
9185
and for clients looking to actively monitor and act upon results.
9286

93-
- Long running operations pattern may be supplemented by [Change Notification
94-
pattern](change-notification.md)
87+
- The long running operations pattern might be supplemented by the [change notification
88+
pattern](change-notification.md).
9589

96-
- Cancellation does not explicitly mean rollback. On a per API defined case it
97-
may mean rollback, or compensation, or completion, or partial completion,
98-
etc. Following a canceled operation the API should return a consistent state which allows
90+
- Cancellation of a long running operation does not explicitly mean a rollback. On a per API-defined case, it
91+
might mean a rollback, or compensation, or completion, or partial completion,
92+
etc. Following a canceled operation, the API should return a consistent state that allows
9993
continued service.
10094

10195
- A recommended minimum retention time for a stepwise operation is 24 hours.
@@ -122,7 +116,7 @@ POST https://graph.microsoft.com/v1.0/databases/
122116
```
123117

124118
The API responds synchronously that the database has been created and indicates
125-
that provisioning operation is not fully completed by including the
119+
that the provisioning operation is not fully completed by including the
126120
Operation-Location header and status property in the response payload.
127121

128122
```
@@ -136,7 +130,7 @@ Content-Location: https://graph.microsoft.com/v1.0/databases/db1
136130
}
137131
```
138132

139-
### Create a new resource using Stepwise Operation:
133+
### Create a new resource using the Stepwise Operation
140134

141135
```
142136
POST https://graph.microsoft.com/v1.0/databases/
@@ -147,7 +141,7 @@ POST https://graph.microsoft.com/v1.0/databases/
147141
```
148142

149143
The API responds synchronously that the request has been accepted and includes
150-
the Location header with an operation resource for further polling .
144+
the Location header with an operation resource for further polling.
151145

152146
```
153147
HTTP/1.1 202 Accepted
@@ -156,14 +150,14 @@ Location: https://graph.microsoft.com/v1.0/operations/123
156150
157151
```
158152

159-
### Poll on a Stepwise Operation:
153+
### Poll on a Stepwise Operation
160154

161155
```
162156
163157
GET https://graph.microsoft.com/v1.0/operations/123
164158
```
165159

166-
Server responds that results are still not ready and optionally provides a
160+
The server responds that results are still not ready and optionally provides a
167161
recommendation to wait 30 seconds.
168162

169163
```
@@ -175,15 +169,15 @@ Retry-After: 30
175169
"status": "running"
176170
}
177171
```
178-
Client waits the recommended 30 seconds and then invokes another request to get
172+
The client waits the recommended 30 seconds and then invokes another request to get
179173
the results of the operation.
180174

181175
```
182176
GET https://graph.microsoft.com/v1.0/operations/123
183177
```
184178

185179

186-
Server responds with a "status:succeeded" operation that includes the resource
180+
The server responds with a "status:succeeded" operation that includes the resource
187181
location.
188182

189183
```

0 commit comments

Comments
 (0)