Skip to content

Commit 5dc6c28

Browse files
authored
Edited doc
1 parent 278f3fa commit 5dc6c28

File tree

1 file changed

+42
-50
lines changed

1 file changed

+42
-50
lines changed

graph/patterns/longRunningOperations.md

Lines changed: 42 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,38 @@
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).
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).
2929
//image
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+
- The returned resource is a new API resource called 'Stepwise Operation' and
3636
is created to track the status. This LRO solution is similar to the concept
3737
of Promises or Futures in other programming languages.
3838
//image
@@ -41,61 +41,53 @@ There are two flavors of this solution:
4141
<img src="LRO.gif" alt="The status monitor LRO flow"/>
4242
</p>
4343
<!-- 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
44+
The RELO pattern is the preferred pattern for long running operations and should be
45+
used wherever possible. The pattern avoids complexity, and consistent resource
4646
presentation makes things simpler for our users and tooling chain.
4747

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

51-
A single deviation from the base guidelines is that Microsoft Graph API
52-
standards require using the following response headers:
51+
A single deviation from the base guidelines is that Microsoft Graph API standards require that you use the following response headers:
5352

54-
- Content-Location header indicates location of a RELO resource.
53+
- The Content-Location header indicates the location of a RELO resource.
54+
- 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.
5555

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.
56+
- The Location header indicates the location of a new stepwise operation LRO resource.
57+
- 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.
5858

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.
59+
## When to use this pattern
6460

65-
## When to Use this Pattern
61+
Any API call that is expected to take longer than 1 second in the 99th percentile should use the long running operations pattern.
6662

67-
68-
Any API call that is expected to take longer than 1 seconds in the 99th percentile, should use Long-running Operations pattern.
69-
70-
How to select which flavor of LRO pattern to use? API designer can follow these
63+
How do you select which flavor of LRO pattern to use? An API designer can follow these
7164
heuristics:
7265

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

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

7972

80-
## Issues and Considerations
73+
## Issues and considerations
8174

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

85-
- The state of the system SHOULD be always discoverable and testable. Clients
77+
- The state of the system SHOULD always be discoverable and testable. Clients
8678
SHOULD be able to determine the system state even if the operation tracking
8779
resource is no longer active. Clients MAY issue a GET on some resource to
88-
determine the state of a long running operation
80+
determine the state of a long running operation.
8981

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

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

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
88+
- Cancellation of a long running operation does not explicitly mean a rollback. On a per API-defined case, it
89+
might mean a rollback, or compensation, or completion, or partial completion,
90+
etc. Following a canceled operation, the API should return a consistent state that allows
9991
continued service.
10092

10193
- A recommended minimum retention time for a stepwise operation is 24 hours.
@@ -122,7 +114,7 @@ POST https://graph.microsoft.com/v1.0/databases/
122114
```
123115

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

128120
```
@@ -136,7 +128,7 @@ Content-Location: https://graph.microsoft.com/v1.0/databases/db1
136128
}
137129
```
138130

139-
### Create a new resource using Stepwise Operation:
131+
### Create a new resource using the Stepwise Operation
140132

141133
```
142134
POST https://graph.microsoft.com/v1.0/databases/
@@ -147,7 +139,7 @@ POST https://graph.microsoft.com/v1.0/databases/
147139
```
148140

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

152144
```
153145
HTTP/1.1 202 Accepted
@@ -156,14 +148,14 @@ Location: https://graph.microsoft.com/v1.0/operations/123
156148
157149
```
158150

159-
### Poll on a Stepwise Operation:
151+
### Poll on a Stepwise Operation
160152

161153
```
162154
163155
GET https://graph.microsoft.com/v1.0/operations/123
164156
```
165157

166-
Server responds that results are still not ready and optionally provides a
158+
The server responds that results are still not ready and optionally provides a
167159
recommendation to wait 30 seconds.
168160

169161
```
@@ -175,15 +167,15 @@ Retry-After: 30
175167
"status": "running"
176168
}
177169
```
178-
Client waits the recommended 30 seconds and then invokes another request to get
170+
The client waits the recommended 30 seconds and then invokes another request to get
179171
the results of the operation.
180172

181173
```
182174
GET https://graph.microsoft.com/v1.0/operations/123
183175
```
184176

185177

186-
Server responds with a "status:succeeded" operation that includes the resource
178+
The server responds with a "status:succeeded" operation that includes the resource
187179
location.
188180

189181
```

0 commit comments

Comments
 (0)