Skip to content

Commit 69ccebf

Browse files
author
Erica Sadun
committed
EDU-4357: Prototypes language tabs
- Adds streamlined React component tooling to simplify language-specific content - Uses opt-in content. Adds placeholders for languages whose content hasn't yet been created - Uses global shared group so tab selection is preserved throughout page and site - Can add that content in any order, although canonical order is preferred For example: import { LANGUAGE_TAB_GROUP, getLanguageLabel } from '@site/src/constants/languageTabs'; import SdkTabs from '@site/src/components'; <SdkTabs> <SdkTabs.Python> ```python TEMPORAL_ADDRESS = os.environ.get("TEMPORAL_ADDRESS", "localhost:7233") TEMPORAL_NAMESPACE = os.environ.get("TEMPORAL_NAMESPACE", "default") TEMPORAL_TASK_QUEUE = os.environ.get("TEMPORAL_TASK_QUEUE", "test-task-queue") TEMPORAL_API_KEY = os.environ.get("TEMPORAL_API_KEY", "") ``` </SdkTabs.Python> </SdkTabs> ```
1 parent 7913236 commit 69ccebf

File tree

8 files changed

+2250
-2129
lines changed

8 files changed

+2250
-2129
lines changed

docs/production-deployment/cloud/get-started/how-to-guides/deploy-workers-to-aws-eks.mdx

+16-4
Original file line numberDiff line numberDiff line change
@@ -3,28 +3,28 @@ id: deploy-workers-to-aws-eks
33
title: Quick Launch - Deploying your Workers on Amazon EKS
44
sidebar_label: Deploy Workers to Amazon EKS
55
slug: /cloud/deploy-workers-to-aws-eks
6-
description: Deploy a Temporal Worker on Amazon Elastic Kubernetes Service (EKS) using the Python SDK.
6+
description: Deploy a Temporal Worker on Amazon Elastic Kubernetes Service (EKS)
77
keywords:
88
- Temporal Cloud
99
- Kubernetes
1010
- EKS
1111
- AWS
12-
- Python SDK
1312
- Worker
1413
tags:
1514
- Deploy
16-
- Python SDK
1715
- Kubernetes
1816
- Temporal Cloud
1917
---
18+
import { LANGUAGE_TAB_GROUP, getLanguageLabel } from '@site/src/constants/languageTabs';
19+
import SdkTabs from '@site/src/components';
2020

2121
Temporal Workers run in [Kubernetes](https://kubernetes.io)-based deployments deliver scale, resilience, and flexible resource management.
2222
Amazon EKS (Elastic Kubernetes Service) offers one of the most popular choices for running Temporal Workers.
2323
It integrates smoothly with AWS services and supports auto-scaling and fault tolerance—key features for many Temporal users.
2424

2525
Follow this guide to deploy and manage your Temporal Workers in EKS.
2626
This guide walks you through writing Temporal Worker code, containerizing and publishing the Worker to the Amazon Elastic Container Registry (ECR), and deploying the worker to Amazon EKS.
27-
The example on this page uses Temporal’s Python SDK and Temporal Cloud.
27+
The example on this page uses Temporal Cloud.
2828

2929
:::tip
3030

@@ -55,15 +55,21 @@ In Temporal applications, business logic lives within your main Workflow code.
5555
Your Worker code runs separately, and is responsible for executing your Workflows and Activities.
5656
Make sure to configure your Worker to use environment variables so you can dynamically route your Worker to different Temporal Instances, Namespaces, and Task Queues on the fly:
5757

58+
<SdkTabs>
59+
<SdkTabs.Python>
5860
```python
5961
TEMPORAL_ADDRESS = os.environ.get("TEMPORAL_ADDRESS", "localhost:7233")
6062
TEMPORAL_NAMESPACE = os.environ.get("TEMPORAL_NAMESPACE", "default")
6163
TEMPORAL_TASK_QUEUE = os.environ.get("TEMPORAL_TASK_QUEUE", "test-task-queue")
6264
TEMPORAL_API_KEY = os.environ.get("TEMPORAL_API_KEY", "")
6365
```
66+
</SdkTabs.Python>
67+
</SdkTabs>
6468

6569
After configuration, instantiate your Temporal client:
6670

71+
<SdkTabs>
72+
<SdkTabs.Python>
6773
```
6874
client = await Client.connect(
6975
TEMPORAL_ADDRESS,
@@ -73,9 +79,13 @@ client = await Client.connect(
7379
tls=True
7480
)
7581
```
82+
</SdkTabs.Python>
83+
</SdkTabs>
7684

7785
Here is a complete Python boilerplate that showcases how to instantiate a Client and pass it to the Worker before starting the Worker execution:
7886

87+
<SdkTabs>
88+
<SdkTabs.Python>
7989
```python
8090
import asyncio
8191
import os
@@ -119,6 +129,8 @@ print("Initializing worker...")
119129
if __name__ == "__main__":
120130
asyncio.run(main())
121131
```
132+
</SdkTabs.Python>
133+
</SdkTabs>
122134

123135
## Containerize the Worker for Kubernetes
124136

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
"path": "^0.12.7",
5252
"react": "^18.2.0",
5353
"react-dom": "^18.2.0",
54+
"react-icons": "^5.5.0",
5455
"react-markdown": "^10.1.0",
5556
"react-player": "^2.6.0",
5657
"rehype-katex": "7",
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
export const Go = ({ children }) => children;
2+
Go.displayName = 'go';
3+
4+
export const Java = ({ children }) => children;
5+
Java.displayName = 'java';
6+
7+
export const Python = ({ children }) => children;
8+
Python.displayName = 'py';
9+
10+
export const TypeScript = ({ children }) => children;
11+
TypeScript.displayName = 'ts';
12+
13+
export const PHP = ({ children }) => children;
14+
PHP.displayName = 'php';
15+
16+
export const DotNet = ({ children }) => children;
17+
DotNet.displayName = 'dotnet';
18+
19+
export const Ruby = ({ children }) => children;
20+
Ruby.displayName = 'rb';
21+
+75
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
import React from 'react';
2+
import Tabs from '@theme/Tabs';
3+
import TabItem from '@theme/TabItem';
4+
import { SDK_LANGUAGES, LANGUAGE_TAB_GROUP } from '@site/src/constants/sdkLanguages';
5+
6+
// Named components for language-specific slots
7+
export const Go = ({ children }) => children;
8+
Go.displayName = 'go';
9+
10+
export const Java = ({ children }) => children;
11+
Java.displayName = 'java';
12+
13+
export const Python = ({ children }) => children;
14+
Python.displayName = 'py';
15+
16+
export const TypeScript = ({ children }) => children;
17+
TypeScript.displayName = 'ts';
18+
19+
export const PHP = ({ children }) => children;
20+
PHP.displayName = 'php';
21+
22+
export const DotNet = ({ children }) => children;
23+
DotNet.displayName = 'dotnet';
24+
25+
export const Ruby = ({ children }) => children;
26+
Ruby.displayName = 'rb';
27+
28+
// Main wrapper
29+
const SdkTabs = ({ children }) => {
30+
const contentMap = {};
31+
32+
React.Children.forEach(children, (child) => {
33+
if (child?.type?.displayName) {
34+
const langKey = child.type.displayName.toLowerCase();
35+
contentMap[langKey] = child;
36+
}
37+
});
38+
39+
return (
40+
<Tabs groupId={LANGUAGE_TAB_GROUP}>
41+
{SDK_LANGUAGES.map(({ key, icon: Icon, label }) => (
42+
<TabItem key={key} value={key} label={<Icon title={label} />}>
43+
{contentMap[key] || (
44+
<div style={{ backgroundColor: '#ffffcc', padding: '1rem', borderRadius: '6px' }}>
45+
<strong>{label}</strong> example coming soon.
46+
</div>
47+
)}
48+
</TabItem>
49+
))}
50+
</Tabs>
51+
);
52+
};
53+
54+
SdkTabs.Go = ({ children }) => children;
55+
SdkTabs.Go.displayName = 'go';
56+
57+
SdkTabs.Java = ({ children }) => children;
58+
SdkTabs.Java.displayName = 'java';
59+
60+
SdkTabs.Python = ({ children }) => children;
61+
SdkTabs.Python.displayName = 'py';
62+
63+
SdkTabs.TypeScript = ({ children }) => children;
64+
SdkTabs.TypeScript.displayName = 'ts';
65+
66+
SdkTabs.PHP = ({ children }) => children;
67+
SdkTabs.PHP.displayName = 'php';
68+
69+
SdkTabs.DotNet = ({ children }) => children;
70+
SdkTabs.DotNet.displayName = 'dotnet';
71+
72+
SdkTabs.Ruby = ({ children }) => children;
73+
SdkTabs.Ruby.displayName = 'rb';
74+
75+
export default SdkTabs;

src/components/index.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
export { default as RetrySimulator } from "./elements/RetrySimulator";
33
export { Intro } from "./elements/Intro";
44
export { SdkLogos } from "./elements/SdkLogos";
5-
export { default as PhotoCarousel } from './elements/PhotoCarousel';
5+
export { default as PhotoCarousel } from "./elements/PhotoCarousel";
6+
export { default as SdkTabs } from './elements/SdkTabs';
67

78
// Formatting components
89
export { default as DocsTable, NewDocsCell } from "./formatting/DocsTable";
@@ -16,3 +17,6 @@ export { default as DiscoverableDisclosure } from "./info/DiscoverableDisclosure
1617
export { default as ToolTipTerm } from "./info/ToolTipTerm";
1718
export { RelatedReadContainer, RelatedReadItem } from "./info/RelatedRead";
1819
export { default as RelatedReadList } from "./info/RelatedReadList";
20+
21+
// Extra export
22+
export { default } from './elements/SDKTabs';

src/constants/languageTabs.js

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { FaJs, FaPython, FaJava } from 'react-icons/fa';
2+
import { SiGo, SiDotnet, SiTypescript, SiRuby, SiPhp } from 'react-icons/si';
3+
export const LANGUAGE_TAB_GROUP = 'language';
4+
5+
export const LANGUAGE_ICONS = {
6+
go: SiGo,
7+
java: FaJava,
8+
py: FaPython,
9+
ts: SiTypescript,
10+
php: SiPhp,
11+
dotnet: SiDotnet,
12+
rb: SiRuby,
13+
};
14+
15+
export const getLanguageLabel = (lang) => {
16+
const Icon = LANGUAGE_ICONS[lang];
17+
return Icon ? <Icon title={lang} /> : lang;
18+
};

src/constants/sdkLanguages.js

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { FaPython, FaJava } from 'react-icons/fa';
2+
import { SiGo, SiTypescript, SiPhp, SiDotnet, SiRuby } from 'react-icons/si';
3+
4+
export const LANGUAGE_TAB_GROUP = 'language';
5+
6+
export const SDK_LANGUAGES = [
7+
{ key: 'go', label: 'Go', icon: SiGo },
8+
{ key: 'java', label: 'Java', icon: FaJava },
9+
{ key: 'py', label: 'Python', icon: FaPython },
10+
{ key: 'ts', label: 'TypeScript', icon: SiTypescript },
11+
{ key: 'php', label: 'PHP', icon: SiPhp },
12+
{ key: 'dotnet', label: '.NET', icon: SiDotnet },
13+
{ key: 'rb', label: 'Ruby', icon: SiRuby },
14+
];

0 commit comments

Comments
 (0)