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

docs: multiple environments #248

Merged
merged 2 commits into from
Mar 7, 2024
Merged
Show file tree
Hide file tree
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
10 changes: 6 additions & 4 deletions frontend/docs/pages/home/basics/_meta.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{
"overview":"Overview",
"steps": "Understanding Steps",
"overview": "Overview",
"steps": "Understanding Steps",
"workflows": "Understanding Workflows",
"workers": "Understanding Workers"
}
"workers": "Understanding Workers",
"dashboard": "Dashboard",
"environments": "Managing Environments"
}
48 changes: 48 additions & 0 deletions frontend/docs/pages/home/basics/environments.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import { Bleed } from 'nextra-theme-docs'

# Managing Environments with Hatchet

When working with Hatchet, it's important to understand how to effectively manage your execution environments. Hatchet provides flexibility in distributing tasks across multiple workers, whether they are running locally or in the cloud. However, this flexibility also requires careful consideration to ensure that your workflows are executed in the desired environment. In this guide, we'll explore how to manage environments with Hatchet and leverage its multi-tenancy feature for better control over event dispatching.

## Understanding Worker Assignment

One key aspect of Hatchet is how it assigns workflow runs to available workers. It's important to keep in mind that Hatchet does not differentiate between local and cloud workers when making assignments. Instead, it follows a random assignment strategy, distributing tasks evenly across all available workers.

Here are a few things to consider:

- **Worker Availability:** Hatchet will assign a workflow run to any worker that is currently available, regardless of whether it's a local worker or a cloud worker.
- **Random Assignment:** If you have both local and cloud workers set up, Hatchet will randomly assign tasks between them. There is no inherent preference for one type of worker over the other.

## Leveraging Hatchet's Multi-Tenancy Feature

Hatchet offers multi-tenancy that allows you to segment where events are dispatched. This feature is particularly useful when you want to have separate environments for different purposes, such as local, development, staging, and production.

To take advantage of multi-tenancy in Hatchet, follow these steps:

<Bleed>
<iframe
className="aspect-video w-full"
src="https://www.youtube.com/embed/r9NY_nqvqig?si=8cmpM94uYm43jqJI"
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
allowFullScreen
/>
</Bleed>


1. **Access the Tenant Dropdown:** In the Hatchet dashboard, locate the tenant dropdown in the bottom left corner of the screen.
2. **Create a New Tenant:** Click on the tenant dropdown and select the "Add New Tenant" option.
3. **Provide a Tenant Name:** Give your new tenant a descriptive name that reflects its purpose, such as "Development", "Staging", or "Production".
4. **Create the Tenant:** Click the "Create" button to create the new tenant.
5. **Generate a New Token:** Once the tenant is created, generate a new token specifically for that tenant. This token will be used to authenticate and authorize access to the tenant's resources.
6. **Update Your Environment Configuration:** In your project's `.env` file, update the relevant configuration variables to use the newly generated token for the specific tenant.

By creating separate tenants for different environments, you can ensure that events are dispatched only within the intended environment. This segregation helps maintain isolation between environments and prevents unintended interactions .

## Best Practices for Environment Management

To effectively manage environments with Hatchet, consider the following best practices:
- **Clearly Define Environment Purposes:** Determine the specific purposes of each environment, such as development, staging, and production. Clearly communicate these purposes to your team to ensure everyone understands the role of each environment. Create one tenant per local developer to prevent conflicts.
- **Use Descriptive Tenant Names:** Choose descriptive names for your tenants that reflect their intended purpose. This helps avoid confusion and makes it easier to identify the correct tenant for each environment.
- **Secure Your Tokens:** Treat tenant tokens as sensitive information and keep them secure. Avoid sharing tokens across different environments or exposing them publicly.
- **Regularly Review and Update Configurations:** Periodically review your environment configurations to ensure they are up to date and aligned with your current needs. Update the `.env` file and other relevant configurations as necessary.

Loading