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 authored and rodneyosodo committed Dec 19, 2024
1 parent b794084 commit 29fac94
Show file tree
Hide file tree
Showing 7 changed files with 139 additions and 21 deletions.
38 changes: 19 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
# 🚀 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.

---

Expand All @@ -34,21 +34,21 @@ For setup instructions, API references, and usage examples, see the documentatio

---

## 💡 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.
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ github.com/absmach/magistrala v0.15.1 h1:3Bk2hlyWcV591LxPYwlvRcyCXTfuZ1g/EkNmU+o
github.com/absmach/magistrala v0.15.1/go.mod h1:9pto6xuBt/IuCtZRdEha0iDQKNQ5tyNOjLXJgUiikYk=
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
github.com/caarlos0/env/v11 v11.2.2 h1:95fApNrUyueipoZN/EhA8mMxiNxrBwDa+oAZrMWl3Kg=
github.com/caarlos0/env/v11 v11.2.2/go.mod h1:JBfcdeQiBoI3Zh1QRAWfe+tpiNTmDtcCj/hHHHMx0vc=
github.com/caarlos0/env/v11 v11.3.0 h1:CVTN6W6+twFC1jHKUwsw9eOTEiFpzyJOSA2AyHa8uvw=
github.com/caarlos0/env/v11 v11.3.0/go.mod h1:Q5lYHeOsgY20CCV/R+b50Jwg2MnjySid7+3FUBz2BJw=
github.com/cenkalti/backoff/v4 v4.3.0 h1:MyRJ/UdXutAwSAT+s3wNd7MfTIcy71VQueUuFK343L8=
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"

Check failure on line 6 in worker/api/endpoint.go

View workflow job for this annotation

GitHub Actions / Lint and Build

could not import github.com/absmach/propeller/worker (-: # 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)

Check failure on line 9 in worker/service.go

View workflow job for this annotation

GitHub Actions / Lint and Build

undefined: WorkerResponseDTO

Check failure on line 9 in worker/service.go

View workflow job for this annotation

GitHub Actions / Lint and Build

undefined: WorkerResponseDTO
}

type workerService struct{}

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

func (s *workerService) GetWorkerStats(ctx context.Context, workerID string) (WorkerResponseDTO, error) {

Check failure on line 18 in worker/service.go

View workflow job for this annotation

GitHub Actions / Lint and Build

undefined: WorkerResponseDTO

Check failure on line 18 in worker/service.go

View workflow job for this annotation

GitHub Actions / Lint and Build

undefined: WorkerResponseDTO
return WorkerResponseDTO{

Check failure on line 19 in worker/service.go

View workflow job for this annotation

GitHub Actions / Lint and Build

undefined: WorkerResponseDTO (typecheck)

Check failure on line 19 in worker/service.go

View workflow job for this annotation

GitHub Actions / Lint and Build

undefined: WorkerResponseDTO) (typecheck)
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 29fac94

Please sign in to comment.