Skip to main content

Crate product_os_connector

Crate product_os_connector 

Source
Expand description

§Product OS Connector

A flexible, configuration-driven framework for defining API servers, workflows, and authentication.

§Overview

The product-os-connector crate provides a powerful abstraction for building API integration systems using declarative configuration rather than imperative code. It supports multiple protocol types (REST, GraphQL, WebSocket) and various authentication methods (OAuth2, JWT, API keys, etc.).

§Features

  • definition: Core flow definitions and routing (depends on matchit, serde_json, regex)
  • connectors: Full connector functionality with async support (depends on async-trait, parking_lot)
  • openapi: OpenAPI/Swagger integration for automatic API definition import
  • default: Enables all features with standard library support

§Architecture

The crate is organized around several key concepts:

  • Definition: Declarative API specification (protocols, paths, auth, flows)
  • Connector: Runtime handler that processes inward/outward requests
  • Interface: Protocol-specific implementations (REST, GraphQL, WebSocket)
  • Flows: Inward (server endpoints) and Outward (client calls) request handling
  • Authentication: Pluggable auth methods with lock/unlock semantics

§Quick Start

use product_os_connector::{Definition, ProductOSConnectors, ConnectorKind};
use std::collections::BTreeMap;

// Load or create connector definitions
let mut definitions = BTreeMap::new();
// definitions.insert("my-api".to_string(), my_definition);

// Initialize connectors
let connectors = ProductOSConnectors::new(definitions);

// Register with router (requires product-os-router)
// let mut router = ProductOSRouter::new();
// connectors.setup_handlers(&mut router).await;

§Configuration-Driven Workflows

Instead of writing code for each API endpoint, you define them in configuration:

{
  "info": {
    "identifier": "my-service",
    "version": "1.0.0"
  },
  "kind": "rest",
  "protocol": "https",
  "addresses": ["api.example.com"],
  "inward_root": "/api/v1",
  "flows_inward": {
    "/users": {
      "methods": {
        "get": {
          "auth_method": "jwt",
          "output": { /* mapping */ }
        }
      }
    }
  }
}

§no_std Support

This crate is no_std compatible via the no-std-compat facade, though async operations and networking features require an allocator.

§See Also

  • [Definition]: The core configuration structure
  • [ProductOSConnectors]: Main entry point for connector runtime
  • ConnectorKind: Supported protocol types

Enums§

ConnectorKind
The type of connector protocol to use for API communication.