Drop Options generic and thread signal directly#391
Merged
Conversation
|
f2b0041 to
6f886c5
Compare
4 tasks
0c6386d to
a2998f9
Compare
5f1b5d0 to
3d6ae17
Compare
a2998f9 to
188c71d
Compare
d9fff4c to
bfc6d6a
Compare
188c71d to
552db13
Compare
`AsyncReadable<Options>` existed so stores could receive arbitrary per-call state. Auth headers, presigning context, cancellation signals, even chunk-layer concerns like caching and prefetch priority (#296, vole-core's `wrapArray`). It was a catch-all for extensions that had nowhere else to live, and the cost was a pile of type magic: higher-kinded-type encoding in the store middleware system (#384), threading generic types that didn't actually provide that much type safety. (TypeScript could often bail out to `any` when inference broke.) Those extensions now have proper homes. Store middleware (#384) gives transport-layer concerns (auth, presigning, request transformation) a proper extension point, and the custom `fetch` option on `FetchStore` (#388) handles the per-store cases at the callsite. Chunk-layer concerns will move to `zarr.extendArray` in a follow-up. What's left is `signal`, which now lives properly on the (non-generic) `AsyncReadable` interface and can be passed directly in `zarr.get` and `zarr.set` from the caller: // Before interface AsyncReadable<Options = unknown> { get(key: AbsolutePath, opts?: Options): Promise<Uint8Array | undefined>; } await zarr.get(arr, null, { opts: { signal: ctl.signal } }); // After interface AsyncReadable { get(key: AbsolutePath, opts?: { signal?: AbortSignal }): Promise<Uint8Array | undefined>; } await zarr.get(arr, null, { signal: ctl.signal }); Batched caller signals in `withRangeBatching` are now merged with `AbortSignal.any` instead of a user-supplied `mergeOptions` reducer. The deprecated `opts?: { signal? }` shape still works for one major version and is folded into the new `signal` via `AbortSignal.any`.
Covers the three paths that previously only worked incidentally through the `Options` generic: `zarr.get()` with a first-class `signal`, propagation through the sharded chunk getter (#306), and the deprecated `opts.signal` shim.
552db13 to
c4784ce
Compare
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
AsyncReadable<Options>existed so stores could receive arbitrary per-call state. Auth headers, presigning context, cancellation signals, even chunk-layer concerns like caching and prefetch priority (#296, vole-core'swrapArray).It was a catch-all for extensions that had nowhere else to live, and the cost was a pile of type magic: higher-kinded-type encoding in the store middleware system (#384), threading generic types that didn't actually provide that much type safety. (TypeScript could often bail out to
anywhen inference broke.)Those extensions now have proper homes. Store middleware (#384) gives transport-layer concerns (auth, presigning, request transformation) a proper extension point, and the custom
fetchoption onFetchStore(#388) handles the per-store cases at the callsite. Chunk-layer concerns will move tozarr.extendArrayin a follow-up.What's left is
signal, which now lives properly on the (non-generic)AsyncReadableinterface and can be passed directly inzarr.getandzarr.setfrom the caller:Batched caller signals in
withRangeBatchingare now merged withAbortSignal.anyinstead of a user-suppliedmergeOptionsreducer. The deprecatedopts?: { signal? }shape still works for one major version and is folded into the newsignalviaAbortSignal.any.