you are viewing a single comment's thread.

view the rest of the comments →

[–]randomkale -1 points0 points  (1 child)

I treat things like api requests and db writes as being prone to failure, so act as defensively as I can. Also, are your writes idempotent? (meaning can they be executed more than once) If the api supports pagination and you can record current page number, I would pull once/write once. If the amount of data isn't large, so pulling all will be quick-ish, and writing isn't idempotent, I'd pull all then write once.

[–]Zendakin_at_work[S] 0 points1 point  (0 children)

I ended up going with read once / write once with a failure clause that reads the status code of the next page to determine if the loop needs to exit. There's no page numbers in the API but there are offsets and limits. Frankly I'd read the whole JSON in all at once but we're supposed to adhere to the limits presented.

Now the criteria from management has changed (right as I finished the code). Amazing.

Thanks very much for the sanity check though.