Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🏗️ Add examples directory #136

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

jharrilim
Copy link

This PR adds some new examples to the repo:

  1. A simple example, akin to the one found on the readme
  2. An example of how to use the connection pool feature
  3. An example of using the connection pool in an Axum app

While trying to get this up and running, I was looking into how I could properly set up a connection pool. It required a little bit of digging, so I figured I may as well pitch in and add an example. I wanted to use it with Axum in particular, so I've also included an example for that too. Getting this setup required some shifts around the repo.

From my commit message:

To get this to work, we also need to move the code from src/ to its own package in memcache. This is because we're adding a complex example with axum, which includes its own Cargo.toml. This has other effects: it means that you can't add single file examples anymore. It must be a crate. This is the same decision used in the Axum repo, and is just a current limitation of cargo.

see also: https://github.com/tokio-rs/axum/tree/main/examples

To get this to work, we also need to move the code from src/ to its own
package in memcache. This is because we're adding a complex example
with axum, which includes its own Cargo.toml. This has other effects: it
means that you can't add single file examples anymore. It must be a
crate. This is the same decision used in the Axum repo, and is just a
current limitation of cargo.
@aisk
Copy link
Owner

aisk commented Jan 21, 2024

Adding examples is good, but I don't think it's a good reason to change the whole project structure. The axum project has multiple crates besides the example, so it is reasonable.

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.

2 participants