66// license that can be found in the LICENSE file.
77
88/*
9- Package azcore implements an HTTP request/response middleware pipeline.
9+ Package azcore implements an HTTP request/response middleware pipeline used by Azure SDK clients .
1010
1111The middleware consists of three components.
1212
@@ -114,7 +114,7 @@ The flow of Request and Response looks like the following:
114114
115115 policy.Request -> PolicyA -> PolicyB -> PolicyC -> TransportA -----+
116116 |
117- HTTP(s ) endpoint
117+ HTTP(S ) endpoint
118118 |
119119 caller <--------- PolicyA <- PolicyB <- PolicyC <- http.Response-+
120120
@@ -152,13 +152,13 @@ a means to resolve the ambiguity between a field to be excluded and its zero-val
152152In the above example, Name and Count are defined as pointer-to-type to disambiguate between
153153a missing value (nil) and a zero-value (0) which might have semantic differences.
154154
155- In a PATCH operation, any fields left as ` nil` are to have their values preserved. When updating
155+ In a PATCH operation, any fields left as nil are to have their values preserved. When updating
156156a Widget's count, one simply specifies the new value for Count, leaving Name nil.
157157
158158To fulfill the requirement for sending a JSON null, the NullValue() function can be used.
159159
160160 w := Widget{
161- Count: azcore.NullValue(0).( *int),
161+ Count: azcore.NullValue[ *int]( ),
162162 }
163163
164164This sends an explict "null" for Count, indicating that any current value for Count should be deleted.
@@ -177,5 +177,81 @@ a callback that writes to the desired location. Any custom logging implementati
177177own synchronization to handle concurrent invocations.
178178
179179See the docs for the log package for further details.
180+
181+ Pageable Operations
182+
183+ Pageable operations return potentially large data sets spread over multiple GET requests. The result of
184+ each GET is a "page" of data consisting of a slice of items.
185+
186+ Pageable operations can be identified by their New*Pager naming convention and return type of *runtime.Pager[T].
187+
188+ func (c *WidgetClient) NewListWidgetsPager(o *Options) *runtime.Pager[PageResponse]
189+
190+ The call to WidgetClient.NewListWidgetsPager() returns an instance of *runtime.Pager[T] for fetching pages
191+ and determining if there are more pages to fetch. No IO calls are made until the NextPage() method is invoked.
192+
193+ pager := widgetClient.NewListWidgetsPager(nil)
194+ for pager.More() {
195+ page, err := pager.NextPage(context.TODO())
196+ // handle err
197+ for _, widget := range page.Values {
198+ // process widget
199+ }
200+ }
201+
202+ Long-Running Operations
203+
204+ Long-running operations (LROs) are operations consisting of an initial request to start the operation followed
205+ by polling to determine when the operation has reached a terminal state. An LRO's terminal state is one
206+ of the following values.
207+
208+ * Succeeded - the LRO completed successfully
209+ * Failed - the LRO failed to complete
210+ * Canceled - the LRO was canceled
211+
212+ LROs can be identified by their Begin* prefix and their return type of *runtime.Poller[T].
213+
214+ func (c *WidgetClient) BeginCreateOrUpdate(ctx context.Context, w Widget, o *Options) (*runtime.Poller[Response], error)
215+
216+ When a call to WidgetClient.BeginCreateOrUpdate() returns a nil error, it means that the LRO has started.
217+ It does _not_ mean that the widget has been created or updated (or failed to be created/updated).
218+
219+ The *runtime.Poller[T] provides APIs for determining the state of the LRO. To wait for the LRO to complete,
220+ call the PollUntilDone() method.
221+
222+ poller, err := widgetClient.BeginCreateOrUpdate(context.TODO(), Widget{}, nil)
223+ // handle err
224+ result, err := poller.PollUntilDone(context.TODO(), nil)
225+ // handle err
226+ // use result
227+
228+ The call to PollUntilDone() will block the current goroutine until the LRO has reached a terminal state or the
229+ context is canceled/timed out.
230+
231+ Note that LROs can take anywhere from several seconds to several minutes. The duration is operation-dependent. Due to
232+ this variant behavior, pollers do _not_ have a preconfigured time-out. Use a context with the appropriate cancellation
233+ mechanism as required.
234+
235+ Resume Tokens
236+
237+ Pollers provide the ability to serialize their state into a "resume token" which can be used by another process to
238+ recreate the poller. This is achieved via the runtime.Poller[T].ResumeToken() method.
239+
240+ token, err := poller.ResumeToken()
241+ // handle error
242+
243+ Note that a token can only be obtained for a poller that's in a non-terminal state. Also note that any subsequent calls
244+ to poller.Poll() might change the poller's state. In this case, a new token should be created.
245+
246+ After the token has been obtained, it can be used to recreate an instance of the originating poller.
247+
248+ poller, err := widgetClient.BeginCreateOrUpdate(nil, Widget{}, &Options{
249+ ResumeToken: token,
250+ })
251+
252+ When resuming a poller, no IO is performed, and zero-value arguments can be used for everything but the Options.ResumeToken.
253+
254+ Resume tokens are unique per service client and operation. Attempting to resume a poller for LRO BeginB() with a token from LRO
255+ BeginA() will result in an error.
180256*/
181257package azcore
0 commit comments