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

Documentation #10

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 55 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,55 @@
# ephemeral-db
# Ephemerally

## Create and automatically cleanup temporary external resources

Infinitely extensible by design. Just install the packages for the types of resources you'd like to exist ephemerally (or create your own!).

## The Convention
All primary integration points are provided in the main `Ephemerally` namespace, typically as extension methods.

## Example Usage
To create a temporary Cosmos database and container for your persistence unit tests:
1. Install the relevant package:
```
dotnet add package Ephemerally.Azure.Cosmos
```
2. Import the namespace
```csharp
using Ephemerally;
```
3. Create and use your resources
```csharp
[Test]
public async Task Test_should_pass()
{
// Create the client to connect to the emulator (or any other instance)
var client = new CosmosClient(
"https://localhost:8081",
"C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw==");

// Create a database
await using var database = await client.CreateEphemeralDatabaseAsync();

// Now let's create a container
await using var container = await database.CreateEphemeralContainerAsync();

// You can even bring your own database or container to clean up automatically
await using var myCoolContainer = database.GetContainer("myCoolContainer").ToEphemeral();

// Resources will be automatically cleaned up
// as we exit the using scopes

Assert.Pass();
}
```

## Available Packages

### `Ephemerally`
The core library with the main types. This will be included automatically as a dependency.

### `Ephemerally.Azure`
Placeholder for now to hold general Azure dependencies.

### `Ephemerally.Azure.Cosmos`
Contains types and extension methods for creating and using ephemeral Cosmos DB resources.
Loading