Skip to content

MySQL async SDK#156

Merged
itowlson merged 4 commits into
spinframework:mainfrom
itowlson:mysql-async
Jul 8, 2026
Merged

MySQL async SDK#156
itowlson merged 4 commits into
spinframework:mainfrom
itowlson:mysql-async

Conversation

@itowlson

@itowlson itowlson commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

That's the last time I let you trick me into anything "not very big" @fibonacci1729

The complexity is not in the main SDK, which is as per Postgres, but in the sample, which needed to return a variety of different body types. After wasting far too much time faffing around with Box dyn, I copped out and cheated my way to success.

I put the async stuff into a mysql_async module. We could put it in the mysql module, but that would be a breaking change. At SDK 7, we can of course make that change: the user impact will be changing their module references. In the sample I did it as use mysql_async::{self as mysql} which makes things look nicer and means I only have one line to delete when SDK 7 comes around.

I tested the sample manually, and added some basic instructions on setting up MySQL because I was lost as.

@itowlson

itowlson commented Jul 7, 2026

Copy link
Copy Markdown
Contributor Author

The CI failure is another stupid "block all PRs because someone is sad about some existing dependency" cargo audit thing.

Comment thread examples/mysql/src/lib.rs Outdated
Comment thread crates/spin-sdk/src/lib.rs Outdated
Comment thread examples/mysql/src/lib.rs Outdated
@fibonacci1729

fibonacci1729 commented Jul 7, 2026

Copy link
Copy Markdown
Collaborator

Thanks for tackling this! I'm not opposed to cutting a v7 and dropping the mysql_async naming wart. Additionally #157 should help address the ServiceResponse cheat.

Also #158 will de-annoyify CI audit check.

itowlson added 2 commits July 8, 2026 10:57
Signed-off-by: itowlson <ivan.towlson@fermyon.com>
Signed-off-by: itowlson <ivan.towlson@fermyon.com>
@itowlson

itowlson commented Jul 7, 2026

Copy link
Copy Markdown
Contributor Author

BoxBodded

Signed-off-by: itowlson <ivan.towlson@fermyon.com>
@itowlson itowlson linked an issue Jul 8, 2026 that may be closed by this pull request
@fibonacci1729

Copy link
Copy Markdown
Collaborator

Given #159 i think we should just do the mysql rename in this PR before we cut a v0.7.

Comment thread crates/spin-sdk/src/lib.rs Outdated
#[cfg(feature = "mysql")]
#[cfg_attr(docsrs, doc(cfg(feature = "mysql")))]
// MySQL database access.
#[cfg(feature = "mysql-async")]

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
#[cfg(feature = "mysql-async")]
#[cfg(feature = "mysql")]

Comment thread crates/spin-sdk/src/lib.rs Outdated
#[cfg_attr(docsrs, doc(cfg(feature = "mysql")))]
// MySQL database access.
#[cfg(feature = "mysql-async")]
#[cfg_attr(docsrs, doc(cfg(feature = "mysql-async")))]

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
#[cfg_attr(docsrs, doc(cfg(feature = "mysql-async")))]
#[cfg_attr(docsrs, doc(cfg(feature = "mysql")))]

Comment thread crates/spin-sdk/Cargo.toml Outdated

[features]
default = ["http", "key-value", "json", "llm", "mqtt", "mysql", "pg", "postgres4-types", "redis", "sqlite", "variables", "export-sdk-language"]
default = ["http", "key-value", "json", "llm", "mqtt", "mysql", "mysql-async", "pg", "postgres4-types", "redis", "sqlite", "variables", "export-sdk-language"]

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
default = ["http", "key-value", "json", "llm", "mqtt", "mysql", "mysql-async", "pg", "postgres4-types", "redis", "sqlite", "variables", "export-sdk-language"]
default = ["http", "key-value", "json", "llm", "mqtt", "mysql", "pg", "postgres4-types", "redis", "sqlite", "variables", "export-sdk-language"]

Comment thread crates/spin-sdk/Cargo.toml Outdated
llm = []
mqtt = []
mysql = []
mysql-async = []

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
mysql-async = []

@fibonacci1729 fibonacci1729 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Just the feature tweaks but otherwise LGTM!

@itowlson

itowlson commented Jul 8, 2026

Copy link
Copy Markdown
Contributor Author

Faugh, sorry about that. MORE TEA

Signed-off-by: itowlson <ivan.towlson@fermyon.com>
@itowlson
itowlson merged commit 0b78e25 into spinframework:main Jul 8, 2026
3 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.

Implement support for spin:mysql/mysql@3.0.0

2 participants