Client SDKs

One native Go SDK plus four HTTP client libraries. Integrate RLAAS in minutes, regardless of your tech stack.

SDK Overview

Every SDK provides the same functionality:

SDKLanguageHTTP LibraryLocation
GoGo 1.25+Native engine (embedded)pkg/rlaas/
PythonPython 3.8+requestssdk/python/
TypeScriptTypeScript / Node.jsfetchsdk/typescript/
JavaJava 11+java.net.http.HttpClientsdk/java/
.NET.NET 8HttpClientsdk/dotnet/

Go

Go SDK (Embedded)

The Go SDK is the native library — import it and evaluate decisions locally with zero network overhead.

import "github.com/suresh-p26/RLAAS/pkg/rlaas"

client := rlaas.NewClient()
decision, err := client.Check(ctx, model.RequestContext{
    OrgID:      "acme",
    TenantID:   "retail",
    SignalType: "http",
    Operation:  "charge",
    Endpoint:   "/v1/charge",
    Method:     "POST",
    UserID:     "u1",
})

if decision.Allowed {
    // proceed
} else {
    // return 429 with decision.RetryAfter
}

For concurrency limiting:

decision, release, err := client.StartConcurrencyLease(ctx, req)
if decision.Allowed {
    defer release()
    // do heavy work
}
Python

Python SDK

Install: pip install rlaas-sdk (or install from sdk/python/)

from rlaas_sdk import RlaasClient, CheckRequest

client = RlaasClient("http://localhost:8080")

# Check decision
decision = client.check(CheckRequest(
    request_id="r1",
    org_id="acme",
    tenant_id="retail",
    signal_type="http",
    operation="charge",
    endpoint="/v1/charge",
    method="POST",
    user_id="u1"
))

print(f"Allowed: {decision.allowed}, Remaining: {decision.remaining}")

# Create policy
client.create_policy({
    "policy_id": "test-limit",
    "name": "Test Limit",
    "enabled": True,
    "scope": {"org_id": "acme", "signal_type": "http"},
    "algorithm": {"type": "fixed_window", "limit": 100, "window": "1m"},
    "action": "deny",
    "rollout_percent": 100
})

# Get audit trail
audit = client.get_audit("test-limit")

# Analytics
summary = client.get_analytics_summary(top=5)
TypeScript

TypeScript SDK

Install: npm install @rlaas/sdk (or import from sdk/typescript/)

import { RlaasClient } from '@rlaas/sdk';

const client = new RlaasClient('http://localhost:8080');

// Check decision
const decision = await client.check({
  request_id: 'r1',
  org_id: 'acme',
  tenant_id: 'retail',
  signal_type: 'http',
  operation: 'charge',
  endpoint: '/v1/charge',
  method: 'POST',
  user_id: 'u1',
});

console.log(`Allowed: ${decision.allowed}, Remaining: ${decision.remaining}`);

// List policies
const policies = await client.listPolicies();

// Rollout update
await client.rollout('payments-limit', 50);

// Rollback
await client.rollback('payments-limit', 1);
Java

Java SDK

Add dependency from sdk/java/ (Maven, Java 11+).

import io.rlaas.sdk.RlaasClient;
import io.rlaas.sdk.model.CheckRequest;
import io.rlaas.sdk.model.Decision;

RlaasClient client = new RlaasClient("http://localhost:8080");

// Check decision
CheckRequest req = new CheckRequest();
req.setRequestId("r1");
req.setOrgId("acme");
req.setSignalType("http");
req.setOperation("charge");
req.setUserId("u1");

Decision decision = client.check(req);
System.out.println("Allowed: " + decision.isAllowed());
System.out.println("Remaining: " + decision.getRemaining());

// Create policy
String policyJson = """
  {
    "policy_id": "java-limit",
    "name": "Java Test",
    "enabled": true,
    "scope": {"org_id": "acme", "signal_type": "http"},
    "algorithm": {"type": "token_bucket", "limit": 200, "window": "1m", "burst": 50},
    "action": "deny",
    "rollout_percent": 100
  }
  """;
client.createPolicy(policyJson);
.NET

.NET SDK

Add project reference from sdk/dotnet/ (.NET 8).

using Rlaas.Sdk;

var client = new RlaasClient("http://localhost:8080");

// Check decision
var decision = await client.CheckAsync(new CheckRequest
{
    RequestId  = "r1",
    OrgId      = "acme",
    TenantId   = "retail",
    SignalType = "http",
    Operation  = "charge",
    Endpoint   = "/v1/charge",
    Method     = "POST",
    UserId     = "u1"
});

Console.WriteLine($"Allowed: {decision.Allowed}, Remaining: {decision.Remaining}");

// Policy management
var policies = await client.ListPoliciesAsync();
await client.RolloutAsync("payments-limit", 50);
await client.RollbackAsync("payments-limit", 1);

// Analytics
var summary = await client.GetAnalyticsSummaryAsync(top: 5);

Common Patterns

Error Handling

All SDKs raise/throw on HTTP errors. Wrap calls in try/catch for production use:

try:
    decision = client.check(req)
except Exception as e:
    # fail open: allow on error
    print(f"RLAAS error: {e}, failing open")
try {
  const d = await client.check(req);
} catch (err) {
  console.warn('RLAAS error, failing open:', err);
}
try {
    Decision d = client.check(req);
} catch (Exception e) {
    System.err.println("RLAAS error, failing open: " + e.getMessage());
}
try {
    var d = await client.CheckAsync(req);
} catch (Exception ex) {
    Console.Error.WriteLine($"RLAAS error: {ex.Message}");
}

Custom Base URL

All SDKs accept a base URL in the constructor. Point to your production RLAAS server or local sidecar:

# Production
client = RlaasClient("https://rlaas.internal.company.com")

# Local sidecar
client = RlaasClient("http://localhost:18080")