Split sync and async return iterators for Get
and List
#19
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In obstore it's very convenient to have a single method that returns both an async and a sync iterator. You can call
list()
and iterate over either withfor
orasync for
.But I imagine that some obspec implementations will be either only sync or only async. In this case, we don't want to require that the returned value can always be iterated over in both manners.
So it's probably good to have some separation in the protocol. Here, this PR suggests a separation between
Get
andGetAsync
whereGet
returns a synchronous iterator andGetAsync
returns an async iterator. I think this should be compatible with obstore because obstore's iterators are a superset.It would be nice to have a single
list
named method still, but it doesn't look like Python can intersect the return objects. So you can't have aList
andListAsync
protocol that each definedef list()
, even if you could imagine having an intersection of their return iterators.In practice, this means that obstore would need to get an essentially duplicative
list_async
method. Even though that function would return the same thing asobstore.list
Closes #10
cc @sharkinsspatial @maxrjones @TomNicholas