Created
October 18, 2019 00:01
-
-
Save Luiz-Monad/cfbd324eebd3ee6ce23f5085eab7504d to your computer and use it in GitHub Desktop.
azure paging
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let! table = container eset | |
let nextSegment callcc args ct = asyncSeq { | |
let execute (_, filter, records) = | |
let query = TableQuery () | |
query.TakeCount <- Option.toNullable records | |
let q = query.Where(filter) | |
table.ExecuteQuerySegmentedAsync ( q, fromContinue ct ) | |
match! catch execute args with | |
| Ok segmt -> | |
yield! segmt.Results |> Seq.map Ok |> AsyncSeq.ofSeq | |
if not <| isNull segmt.ContinuationToken then | |
yield! callcc args <| toContinue segmt.ContinuationToken | |
| Error e -> | |
yield Error e | |
} | |
let segment args = | |
let rec run arg cont = | |
let fn (_, arg, cont) = | |
nextSegment run arg cont |> AsyncSeq.toList | |
cache fn (eset, arg, cont) |> AsyncSeq.ofSeq | |
run args None | |
return | |
segment (session, partition, take) | |
|> AsyncSeq.map parseDynEntry | |
|> AsyncSeq.skip skip | |
|> AsyncSeq.take (take |> Option.defaultValue System.Int32.MaxValue) | |
|> AsyncSeq.toList | |
|> List.sequenceResultA | |
|> Result.map ( List.toSeq >> Seq.choose id ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment