Skip to content

Commit 155c69b

Browse files
committed
chore: Add new Enterprise samples to the hub
This commit adds "Long-Running Jobs over HTTP" and "Aggregate Pattern" to the Hub Signed-off-by: Thorsten Hans <[email protected]>
1 parent ab0bca0 commit 155c69b

File tree

2 files changed

+62
-0
lines changed

2 files changed

+62
-0
lines changed

content/api/hub/pattern_aggregates.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
title = "Aggregate Pattern"
2+
template = "render_hub_content_body"
3+
date = "2024-04-11T06:50:00Z"
4+
content-type = "text/plain"
5+
tags = ["Patterns", "Service Chaining", "Polyglot"]
6+
7+
[extra]
8+
author = "Thorsten Hans"
9+
type = "hub_document"
10+
category = "Pattern"
11+
language = "Polyglot"
12+
created_at = "2024-04-11T06:50:00Z"
13+
last_updated = "2024-04-11T06:50:00Z"
14+
spin_version = ">=v2.4.2"
15+
summary = "Polyglot implementation of the Aggregate Pattern using Service Chaining capabilities provided by Spin"
16+
url = "https://github.com/fermyon/enterprise-architectures-and-patterns/tree/main/aggregate-pattern"
17+
keywords = "Patterns, Service Chaining, Polyglot"
18+
19+
---
20+
21+
This folder contains an implementation of the Aggregate Pattern. The sample consists of two backend services (written in Go and TypeScript) and an aggregate (written in Rust).
22+
23+
### What Is the Aggregate Pattern?
24+
25+
In the context of a microservices architecture, the Aggregate Design Pattern refers to a strategy for composing multiple microservices to fulfill a single business operation or query. Instead of relying on a single microservice to handle complex operations, aggregates distribute the workload across multiple services, each responsible for managing a specific aspect of the operation. This pattern helps in achieving scalability, fault isolation, and autonomy among microservices. By decomposing large operations into smaller, manageable tasks distributed across microservices, the Aggregate Design Pattern enables more efficient and resilient systems in microservices architecture.
26+
27+
## Sample Scenario
28+
29+
For demonstration purposes, take the two backend services [`customers-service`](https://github.com/fermyon/enterprise-architectures-and-patterns/tree/main/aggregate-pattern/customers-service) and [`incidents-service`](https://github.com/fermyon/enterprise-architectures-and-patterns/tree/main/aggregate-pattern/incidents-service) as given. Although they expose necessary data directly, developers must issue many requests to create a dashboard displaying information provided by those backend services.
30+
31+
Instead, an **aggregate** is implemented ([`aggregates-service](https://github.com/fermyon/enterprise-architectures-and-patterns/tree/main/aggregate-pattern/aggregates-service)) which is responsible for loading data from backend services (via service chaining) and composing a uniform representation for data that should be visualized on the dashboard.
32+
33+
In addition to calling into backend services using service chaining, the *Aggregates Service* is responsible to transform data according to the use-case.
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
title = "Long-Running Jobs over HTTP"
2+
template = "render_hub_content_body"
3+
date = "2024-04-11T06:55:00Z"
4+
content-type = "text/plain"
5+
tags = ["patterns", "Rust", "MQTT", "HTTP"]
6+
7+
[extra]
8+
author = "Thorsten Hans"
9+
type = "hub_document"
10+
category = "Pattern"
11+
language = "Rust"
12+
created_at = "2024-04-11T06:55:00Z"
13+
last_updated = "2024-04-11T06:55:00Z"
14+
spin_version = ">=v2.4.2"
15+
summary = "This sample illustrates how to offload time-intense computing from an HTTP API to a background app using MQTT"
16+
url = "https://github.com/fermyon/enterprise-architectures-and-patterns/tree/main/long-running-jobs-over-http"
17+
keywords = "Patterns, MQTT, HTTP, Rust"
18+
19+
---
20+
21+
This sample demonstrates how you can add support for long-running jobs over HTTP using Spin and its `MQTT` capabilities.
22+
23+
### What are Long-Running Jobs over HTTP
24+
25+
In some situations you may want to perform data processing which takes longer than usual HTTP requests and could result in users facing timeouts. By using the `MQTT` capabilities provided by Spin, you can move the time-consuming actions (or jobs) to a different (background) process.
26+
27+
For demonstration purposes, this application uses [Eclipse Mosquitto](https://mosquitto.org/) as a message broker to offload time-consuming tasks from the [`API`](https://github.com/fermyon/enterprise-architectures-and-patterns/tree/main/long-running-jobs-over-http/api) app to either the [`Spin Worker`](https://github.com/fermyon/enterprise-architectures-and-patterns/tree/main/long-running-jobs-over-http/spin-worker) or the [`Native Worker`](https://github.com/fermyon/enterprise-architectures-and-patterns/tree/main/long-running-jobs-over-http/native-worker). Upon creating a new job, a unique identifier for the job is created and used to track its status and report back to the callee (using response payload and the response `Location` header).
28+
29+
The API and both workers track the state of the jobs using a SQLite database.

0 commit comments

Comments
 (0)