Skip to content

Commit

Permalink
First commit
Browse files Browse the repository at this point in the history
Signed-off-by: JeffMboya <[email protected]>

Revert docs

Signed-off-by: JeffMboya <[email protected]>

Revert docs

Signed-off-by: JeffMboya <[email protected]>

Revert docs

Signed-off-by: JeffMboya <[email protected]>
  • Loading branch information
JeffMboya committed Dec 4, 2024
1 parent 5ca555e commit 59da76b
Show file tree
Hide file tree
Showing 9 changed files with 161 additions and 67 deletions.
83 changes: 26 additions & 57 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,83 +1,52 @@
# 🚀 Propeller
# 🚀 Propeller

**Propeller** is a cutting-edge orchestrator for **WebAssembly (Wasm)** workloads across the **Cloud-Edge continuum**. It enables seamless deployment of Wasm applications from powerful cloud servers to constrained microcontrollers, combining flexibility, security, and performance.
**Propeller** is a cutting-edge orchestrator for **WebAssembly (Wasm)** workloads across the **Cloud-Edge continuum**. It enables seamless deployment of Wasm applications from powerful cloud servers to constrained microcontrollers, combining flexibility, security, and performance.

---

## 🌟 Features
## 🌟 Features

- 🌐 **Cloud-Edge Orchestration**: Deploy Wasm workloads effortlessly across diverse environments, from robust cloud servers to lightweight microcontrollers.
-**Fast Boot Times**: Take advantage of Wasm's near-instant startup for efficient workload execution.
- 📦 **FaaS Deployment**: Enable Function-as-a-Service (FaaS) capabilities for scalable and event-driven applications.
- 🖥️ **OCI Registry Support**: Push and pull Wasm workloads from OCI-compliant registries for streamlined workflow integration.
- 🔧 **WAMR on Zephyr RTOS**: Deploy lightweight Wasm workloads on constrained devices running Zephyr RTOS via the WebAssembly Micro Runtime (WAMR).
- 🛠️ **Powerful Service Mesh**: Integrates with **[SuperMQ](https://github.com/absmach)** for secure, efficient IoT device communication.
- 🔒 **Security at the Core**: Propeller ensures secure workload execution and communication for IoT environments.
- 🌐 **Cloud-Edge Orchestration**: Deploy Wasm workloads effortlessly across diverse environments, from robust cloud servers to lightweight microcontrollers.
-**Fast Boot Times**: Take advantage of Wasm's near-instant startup for efficient workload execution.
- 📦 **FaaS Deployment**: Enable Function-as-a-Service (FaaS) capabilities for scalable and event-driven applications.
- 🖥️ **OCI Registry Support**: Push and pull Wasm workloads from OCI-compliant registries for streamlined workflow integration.
- 🔧 **WAMR on Zephyr RTOS**: Deploy lightweight Wasm workloads on constrained devices running Zephyr RTOS via the WebAssembly Micro Runtime (WAMR).
- 🛠️ **Powerful Service Mesh**: Integrates with **[SuperMQ](https://github.com/absmach)** for secure, efficient IoT device communication.
- 🔒 **Security at the Core**: Propeller ensures secure workload execution and communication for IoT environments.

---

## 🏗️ Architecture Overview
## 🛠️ How It Works

Propeller's architecture consists of three key components:

### 1. 🖥️ **User Interface (CLI/API)**

- Provides users with tools to interact with Propeller, whether via a command-line interface (CLI) or RESTful API.

### 2. 🚀 **Manager**

- Acts as the control hub, responsible for workload scheduling and orchestration.
- Integrates a **scheduler** for efficient resource allocation and workload distribution.
- Maintains an internal database for tracking workloads, worker states, and metadata.
- Currently, the system supports **1 manager : multiple workers** as shown in (a). In the future, the system will be expanded to support **multiple managers : multiple workers** as shown in (b).

### 3. ⚙️ **Workers**

- Responsible for executing workloads based on instructions from the manager.
- All workers operate within the same communication channel.
- Two worker types are supported:
- **Golang Workers**: Designed for general-purpose workloads on cloud or edge devices.
- **C & Rust Workers**: Optimized for constrained microcontroller environments, enabling lightweight and efficient task execution.
- Workers communicate using multiple protocols:
- MQTT and CoAP for constrained devices.
- WebSocket (WS) for other devices.
- At present, the system is configured to support a **1 worker : 1 task** execution model as shown in (a). In the future, the system will be expanded to support **1 worker : multiple tasks** as shown in (b).

![Propeller Orchestration Diagram](architecture.svg)

---

## 🛠️ How It Works

1. **Develop in WebAssembly**: Write portable, lightweight Wasm workloads for your application.
2. **Register Workloads**: Push your workloads to an OCI-compliant registry for easy deployment.
3. **Deploy Anywhere**: Use Propeller to orchestrate and manage workload deployment across the cloud, edge, and IoT devices.
4. **Monitor & Scale**: Leverage real-time monitoring and dynamic scaling to optimize your system's performance.
1. **Develop in WebAssembly**: Write portable, lightweight Wasm workloads for your application.
2. **Register Workloads**: Push your workloads to an OCI-compliant registry for easy deployment.
3. **Deploy Anywhere**: Use Propeller to orchestrate and manage workload deployment across the cloud, edge, and IoT devices.
4. **Monitor & Scale**: Leverage real-time monitoring and dynamic scaling to optimize your system's performance.

---

## 📖 Documentation
## 📖 Documentation

For setup instructions, API references, and usage examples, see the documentation:
🔗 [Documentation Link](#)
🔗 [Documentation Link](#)

---

## 💡 Use Cases
## 💡 Use Cases

- 🏭 **Industrial IoT**: Deploy analytics or control applications to edge devices in factories.
- 🛡️ **Secure Workloads**: Run isolated, portable workloads securely on cloud or edge devices.
- 🌎 **Smart Cities**: Power scalable IoT networks with efficient communication and dynamic workloads.
- ☁️ **Serverless Applications**: Deploy FaaS applications leveraging Propeller's Wasm orchestration capabilities.
- 🏭 **Industrial IoT**: Deploy analytics or control applications to edge devices in factories.
- 🛡️ **Secure Workloads**: Run isolated, portable workloads securely on cloud or edge devices.
- 🌎 **Smart Cities**: Power scalable IoT networks with efficient communication and dynamic workloads.
- ☁️ **Serverless Applications**: Deploy FaaS applications leveraging Propeller's Wasm orchestration capabilities.

---

## 🤝 Contributing
## 🤝 Contributing

Contributions are welcome! Please check the [CONTRIBUTING.md](#) for details on how to get started.
Contributions are welcome! Please check the [CONTRIBUTING.md](#) for details on how to get started.

---

## 📜 License
## 📜 License

Propeller is licensed under the **Apache-2.0 License**. See the [LICENSE](LICENSE) file for more details.
Propeller is licensed under the **Apache-2.0 License**. See the [LICENSE](LICENSE) file for more details.
10 changes: 0 additions & 10 deletions architecture.svg

This file was deleted.

7 changes: 7 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@ module github.com/absmach/propeller
go 1.22.6

require (
github.com/go-chi/chi/v5 v5.1.0
github.com/go-kit/kit v0.13.0
github.com/google/uuid v1.6.0
github.com/tetratelabs/wazero v1.7.3
)

require (
github.com/go-kit/log v0.2.1 // indirect
github.com/go-logfmt/logfmt v0.5.1 // indirect
)
8 changes: 8 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
github.com/go-chi/chi/v5 v5.1.0 h1:acVI1TYaD+hhedDJ3r54HyA6sExp3HfXq7QWEEY/xMw=
github.com/go-chi/chi/v5 v5.1.0/go.mod h1:DslCQbL2OYiznFReuXYUmQ2hGd1aDpCnlMNITLSKoi8=
github.com/go-kit/kit v0.13.0 h1:OoneCcHKHQ03LfBpoQCUfCluwd2Vt3ohz+kvbJneZAU=
github.com/go-kit/kit v0.13.0/go.mod h1:phqEHMMUbyrCFCTgH48JueqrM3md2HcAZ8N3XE4FKDg=
github.com/go-kit/log v0.2.1 h1:MRVx0/zhvdseW+Gza6N9rVzU/IVzaeE1SFI4raAhmBU=
github.com/go-kit/log v0.2.1/go.mod h1:NwTd00d/i8cPZ3xOwwiv2PO5MOcx78fFErGNcVmBjv0=
github.com/go-logfmt/logfmt v0.5.1 h1:otpy5pqBCBZ1ng9RQ0dPu4PN7ba75Y/aA+UpowDyNVA=
github.com/go-logfmt/logfmt v0.5.1/go.mod h1:WYhtIu8zTZfxdn5+rREduYbwxfcBr/Vr6KEVveWlfTs=
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/tetratelabs/wazero v1.7.3 h1:PBH5KVahrt3S2AHgEjKu4u+LlDbbk+nsGE3KLucy6Rw=
Expand Down
15 changes: 15 additions & 0 deletions worker/api/endpoint.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package api

import (
"context"

"github.com/absmach/propeller/worker"
"github.com/go-kit/kit/endpoint"
)

func MakeGetWorkerStatEndpoint(svc worker.WorkerService) endpoint.Endpoint {
return func(ctx context.Context, request interface{}) (interface{}, error) {
req := request.(WorkerRequestDTO)
return svc.GetWorkerStats(ctx, req.WorkerID)
}
}
5 changes: 5 additions & 0 deletions worker/api/requests.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package api

type WorkerRequestDTO struct {
WorkerID string `json:"worker_id"`
}
18 changes: 18 additions & 0 deletions worker/api/responses.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package api

import "time"

type WorkerResponseDTO struct {
WorkerID string `json:"worker_id"`
Name string `json:"name"`
State string `json:"state"`
Function string `json:"function"`
RestartPolicy string `json:"restart_policy"`
RestartCount int `json:"restart_count"`
StartTime time.Time `json:"start_time"`
FinishTime time.Time `json:"finish_time"`
CPUUsage float64 `json:"cpu_usage"`
MemoryUsage float64 `json:"memory_usage"`
TaskCount int `json:"task_count"`
RunningTasks int `json:"running_tasks"`
}
49 changes: 49 additions & 0 deletions worker/api/transport.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package api

import (
"context"
"encoding/json"
"errors"
"net/http"
"strings"

"github.com/absmach/propeller/worker"

"github.com/go-chi/chi/v5"
kithttp "github.com/go-kit/kit/transport/http"
)

func MakeHandler(svc worker.WorkerService) http.Handler {
opts := []kithttp.ServerOption{}

mux := chi.NewRouter()

mux.Route("/workers", func(r chi.Router) {
r.Get("/{worker_id}", kithttp.NewServer(
MakeGetWorkerStatEndpoint(svc),
decodeWorkerRequest,
encodeWorkerResponse,
opts...,
).ServeHTTP)
})

return mux
}

func decodeWorkerRequest(_ context.Context, r *http.Request) (interface{}, error) {
if !strings.Contains(r.Header.Get("Content-Type"), "application/json") {
return nil, errors.New("unsupported content type")
}

workerID := chi.URLParam(r, "worker_id")
if workerID == "" {
return nil, errors.New("worker_id is required")
}

return WorkerRequestDTO{WorkerID: workerID}, nil
}

func encodeWorkerResponse(_ context.Context, w http.ResponseWriter, response interface{}) error {
w.Header().Set("Content-Type", "application/json")
return json.NewEncoder(w).Encode(response)
}
33 changes: 33 additions & 0 deletions worker/service.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package worker

import (
"context"
"time"
)

type WorkerService interface {
GetWorkerStats(ctx context.Context, workerID string) (WorkerResponseDTO, error)
}

type workerService struct{}

func NewWorkerService() WorkerService {
return &workerService{}
}

func (s *workerService) GetWorkerStats(ctx context.Context, workerID string) (WorkerResponseDTO, error) {
return WorkerResponseDTO{
WorkerID: workerID,
Name: "WorkerName",
State: "Running",
Function: "Compute",
RestartPolicy: "Always",
RestartCount: 1,
StartTime: time.Now().Add(-2 * time.Hour),
FinishTime: time.Now().Add(1 * time.Hour),
CPUUsage: 0.75,
MemoryUsage: 0.65,
TaskCount: 10,
RunningTasks: 3,
}, nil
}

0 comments on commit 59da76b

Please sign in to comment.