Skip to content

feat(sdk): add util module with collect helper func; update spin-kv example to suit#139

Merged
vdice merged 1 commit intospinframework:mainfrom
vdice:feat/util-module-with-collect
Apr 8, 2026
Merged

feat(sdk): add util module with collect helper func; update spin-kv example to suit#139
vdice merged 1 commit intospinframework:mainfrom
vdice:feat/util-module-with-collect

Conversation

@vdice
Copy link
Copy Markdown
Contributor

@vdice vdice commented Apr 7, 2026

Closes #134

@vdice vdice force-pushed the feat/util-module-with-collect branch from 0e0d7c1 to 5c8dfdc Compare April 7, 2026 23:16
@vdice vdice requested review from dicej, itowlson and karthik2804 April 7, 2026 23:17
Copy link
Copy Markdown
Collaborator

@dicej dicej left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks! Just one doc tweak suggestion inline.

@vdice vdice force-pushed the feat/util-module-with-collect branch from 6564e59 to 749cd69 Compare April 7, 2026 23:24
…xample to suit

Signed-off-by: Vaughn Dice <vdice@akamai.com>
Co-authored-by: Joel Dice <joel.dice@akamai.com>
@vdice vdice force-pushed the feat/util-module-with-collect branch from 749cd69 to 5b224e3 Compare April 7, 2026 23:26
T = TypeVar('T')
E = TypeVar('E')

async def collect(tuple: Tuple[StreamReader[T], FutureReader[Result[None, E]]]) -> List[T]:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this be usable for PostgreSQL and SQLite rows? The APIs there return (list<column>, stream<row>, future<result>) rather than the mere 2-tuple of get-keys - can users still call this as collect(stream, future) or would they need to re-tuple the stream and future?

Wow I explained that badly but hopefully makes sense.

Copy link
Copy Markdown
Collaborator

@dicej dicej Apr 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could do something like this:

columns, stream, result = connection.execute_async(statement, parameters)
rows = collect((stream, result))

Copy link
Copy Markdown
Collaborator

@dicej dicej Apr 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So yes, you'd need to re-tuple, but the syntax for that is pretty simple.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@itowlson merging this to get some docs URLs to point to for the new util module and collect helper, but please do file a follow-up if I or @dicej can attend to improvements here.

@vdice vdice merged commit 9bffd96 into spinframework:main Apr 8, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

modules(key_value): add get_keys convenience method

3 participants