Skip to content

capa-cloud/capa

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

7 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Capa Runtime

Cloud Application API Β· Multi-Runtime Sidecar Β· Write Once, Run Anywhere

Capa Java Β· Capa Python Β· Capa Go

Go Version License


πŸ“– Introduction

Capa Runtime is the sidecar implementation of the Capa (Cloud Application API) ecosystem. It provides extended capabilities that complement the Capa SDK, enabling advanced features like traffic interception, Actor model, and external system bindings.

Capa Runtime works alongside Capa SDK implementations to provide a complete Multi-Runtime solution for cloud-native applications.

Dual-Mode Architecture

Mode Description Use Case
SDK Mode Direct API calls via Capa SDK Standard operations, low latency
Sidecar Mode Capa Runtime provides extended APIs Actor, Binding, Traffic interception

πŸ—οΈ Architecture

Capa Runtime Architecture

Architecture Layers

capa/
β”œβ”€β”€ cmd/                    # Entry points and CLI commands
β”œβ”€β”€ pkg/                    # Core packages
β”‚   β”œβ”€β”€ actor/             # Actor runtime implementation
β”‚   β”œβ”€β”€ binding/           # External system bindings
β”‚   β”œβ”€β”€ proxy/             # Traffic proxy and interception
β”‚   β”œβ”€β”€ runtime/           # Core runtime logic
β”‚   └── saas/              # SaaS integrations
β”œβ”€β”€ docker/                 # Docker configurations
β”œβ”€β”€ spec/                   # API specifications
└── utils/                  # Utility functions

Key Design Principles:

  • Optional Sidecar: Capa Runtime is optional; SDK works independently
  • Extended Capabilities: Provides APIs that SDK cannot support
  • Dual Mode: Supports both sidecar and proxyless modes
  • Negotiation: Application negotiates with proxy to determine mode

✨ Features

Capa Runtime Features

HTTP Traffic Interception (Experimental)

Feature Description Status
iptables Integration L7 HTTP traffic interception πŸ”¬ Experimental
Traffic Analysis Monitor and analyze request flow πŸ”¬ Experimental
Request Routing Dynamic traffic routing πŸ”¬ Experimental

⚠️ Warning: This feature affects the main traffic path. Use with caution in production.

Actor API

Feature Description Status
Virtual Actors Dapr-style virtual actor model βœ… Stable
State Management Actor state persistence βœ… Stable
Reminders Scheduled actor callbacks βœ… Stable
Concurrency Turn-based concurrency βœ… Stable

Actor model is not suitable for SDK integration and is provided via runtime.

Binding API

Feature Description Status
Input Bindings Trigger from external sources βœ… Stable
Output Bindings Send to external systems βœ… Stable
Extensibility Pluggable binding components βœ… Stable

Binding provides loosely-coupled interaction with external systems.

SaaS API (Experimental)

Feature Description Status
SaaS Connectors Pre-built SaaS integrations πŸ”¬ Experimental
Data Sync Bi-directional data synchronization πŸ”¬ Experimental
Webhook Support Event-driven SaaS interactions πŸ”¬ Experimental

🎯 Motivation

Why Sidecar?

While Capa SDK provides rich functionality, some capabilities require sidecar architecture:

  1. Actor Model: Requires persistent connections and scheduling
  2. Traffic Interception: Needs network-level control (iptables)
  3. Binding: Benefits from decoupled event processing

Sidecar or SDK?

Capability SDK Sidecar Notes
RPC βœ… βœ… SDK preferred for performance
Configuration βœ… βœ… SDK preferred
Pub/Sub βœ… βœ… SDK preferred
Actor ❌ βœ… Only sidecar
Binding βœ… βœ… Sidecar for async
Traffic Interception ❌ βœ… Only sidecar

πŸš€ Getting Started

Prerequisites

  • Go 1.18 or higher
  • Docker (optional, for containerized deployment)
  • Kubernetes (optional, for orchestrated deployment)

Installation

# Clone the repository
git clone https://github.com/capa-cloud/capa.git
cd capa

# Build the runtime
go build -o capa-runtime ./cmd

# Run locally
./capa-runtime --config ./config.yaml

Docker Deployment

# Build Docker image
docker build -t capa-runtime:latest .

# Run container
docker run -d \
  --name capa-runtime \
  -p 3500:3500 \
  -v $(pwd)/config:/config \
  capa-runtime:latest

Kubernetes Deployment

apiVersion: apps/v1
kind: Deployment
metadata:
  name: capa-runtime
spec:
  replicas: 1
  selector:
    matchLabels:
      app: capa-runtime
  template:
    metadata:
      labels:
        app: capa-runtime
    spec:
      containers:
      - name: capa-runtime
        image: capa-runtime:latest
        ports:
        - containerPort: 3500
---
apiVersion: v1
kind: Service
metadata:
  name: capa-runtime
spec:
  selector:
    app: capa-runtime
  ports:
  - port: 3500
    targetPort: 3500

βš™οΈ Configuration

Control Plane

Capa Runtime minimizes external dependencies. Instead of a dedicated control plane, it uses:

  • Configuration Component: For dynamic configuration delivery
  • Service Discovery: Built-in or via external registry

Operating Modes

Sidecar Mode

mode: sidecar
sidecar:
  port: 3500
  grpcPort: 50001
  metricsPort: 9090
  traffic:
    interception:
      enabled: true
      port: 80

Proxyless Mode

mode: proxyless
proxyless:
  directConnection: true
  sdkEndpoints:
    - localhost:3500

Negotiation

The application negotiates with the proxy to determine the operating mode:

// Application requests mode preference
mode := runtime.NegotiateMode(
    runtime.WithPreference(runtime.SDKMode),
    runtime.WithFallback(runtime.SidecarMode),
)

πŸ“š API Examples

Actor API

// Initialize actor runtime
actorRuntime := runtime.NewActorRuntime()

// Register actor type
actorRuntime.RegisterActor("MyActor", &MyActor{})

// Invoke actor method
response, err := actorRuntime.Invoke(
    ctx,
    "MyActor",
    "actor-id-123",
    "DoWork",
    []byte("payload"),
)

Binding API

// Initialize binding
binding := runtime.NewBinding("kafka-binding")

// Send to external system
err := binding.Send(ctx, &runtime.InvokeRequest{
    Data: []byte("message"),
    Metadata: map[string]string{
        "topic": "orders",
    },
})

// Receive from external system
binding.Receive(func(req *runtime.InvokeRequest) (*runtime.InvokeResponse, error) {
    // Process incoming message
    return &runtime.InvokeResponse{Data: []byte("ack")}, nil
})

🌐 Ecosystem

Capa Runtime is part of the Capa Cloud ecosystem:

Project Language Description
capa-java Java Java SDK implementation
capa-python Python Python SDK implementation
capa-go Go Go SDK implementation
cloud-runtimes-jvm Java JVM API specification
cloud-runtimes-golang Go Go API specification

🀝 Contributing

We welcome contributions to Capa Runtime!

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Development Setup

# Clone and build
git clone https://github.com/capa-cloud/capa.git
cd capa

# Download dependencies
go mod download

# Run tests
go test ./...

# Build binary
go build -o capa-runtime ./cmd

πŸ“œ License

This project is licensed under the Apache License 2.0 - see the LICENSE file for details.


Building the future of cloud-native applications with Multi-Runtime architecture

Capa Cloud Β· Documentation

About

Mecha Runtime of Cloud Application Api.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors