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: graph/patterns/longRunningOperations.md
+46-52Lines changed: 46 additions & 52 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,101 +1,95 @@
1
-
# Long Running Operations
1
+
# Long running operations
2
2
3
3
Microsoft Graph API Design Pattern
4
4
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.*__
6
6
7
7
## Problem
8
8
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
10
10
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
12
12
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
14
14
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
16
16
being notified asynchronously of the results.
17
17
18
18
## Solution
19
19
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 longrunning
22
22
operation.
23
23
24
24
There are two flavors of this solution:
25
25
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
+
30
30
<!-- markdownlint-disable MD033 -->
31
31
<palign="center">
32
32
<imgsrc="RELO.gif"alt="The status monitor LRO flow"/>
33
33
</p>
34
34
<!-- 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
36
37
is created to track the status. This LRO solution is similar to the concept
37
38
of Promises or Futures in other programming languages.
38
-
//image
39
+
39
40
<!-- markdownlint-disable MD033 -->
40
41
<palign="center">
41
42
<imgsrc="LRO.gif"alt="The status monitor LRO flow"/>
42
43
</p>
43
44
<!-- 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
46
48
presentation makes things simpler for our users and tooling chain.
47
49
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
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:
58
54
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.
64
57
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.
66
60
61
+
## When to use this pattern
67
62
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.
69
64
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
71
66
heuristics:
72
67
73
68
1. If a service can create a resource with a minimal latency and continue
74
69
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.
76
71
77
-
2. Otherwise a service should follow the Stepwise Operation pattern.#
72
+
2. Otherwise, a service should follow the Stepwise Operation pattern.
78
73
79
74
80
-
## Issues and Considerations
75
+
## Issues and considerations
81
76
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.
84
78
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
86
80
SHOULD be able to determine the system state even if the operation tracking
87
81
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.
89
83
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"
91
85
and for clients looking to actively monitor and act upon results.
92
86
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).
95
89
96
-
- Cancellation does not explicitly mean rollback. On a per APIdefined 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
99
93
continued service.
100
94
101
95
- A recommended minimum retention time for a stepwise operation is 24 hours.
@@ -122,7 +116,7 @@ POST https://graph.microsoft.com/v1.0/databases/
122
116
```
123
117
124
118
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
126
120
Operation-Location header and status property in the response payload.
0 commit comments