mirror of
https://github.com/johndoe6345789/metabuilder.git
synced 2026-04-25 14:25:02 +00:00
Created 11 packagerepo-specific workflow plugins: - auth_verify_jwt - JWT token verification - auth_check_scopes - Scope-based authorization - parse_path - URL path parameter extraction (Express-style) - normalize_entity - Field normalization (trim, lower, unique, sort) - validate_entity - JSON schema validation - kv_get/kv_put - RocksDB key-value operations - blob_put - Filesystem blob storage with SHA-256 hashing - index_upsert - Index entry management - respond_json/respond_error - Response formatting Created string.sha256 plugin: - Compute SHA256 hash of strings/bytes - Optional "sha256:" prefix - Used by packagerepo for content-addressed storage All plugins follow standard pattern: - Class extending NodeExecutor - Factory with create() function - package.json with metadata - Access external state via runtime parameter Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
44 lines
1.4 KiB
Python
44 lines
1.4 KiB
Python
"""Workflow plugin: get value from RocksDB key-value store."""
|
|
|
|
from typing import Dict, Any
|
|
import json
|
|
|
|
from ...base import NodeExecutor
|
|
|
|
|
|
class KvGet(NodeExecutor):
|
|
"""Get value from RocksDB key-value store."""
|
|
|
|
node_type = "packagerepo.kv_get"
|
|
category = "packagerepo"
|
|
description = "Get value from RocksDB key-value store"
|
|
|
|
def execute(self, inputs: Dict[str, Any], runtime: Any = None) -> Dict[str, Any]:
|
|
"""Get value from KV store."""
|
|
key = inputs.get("key")
|
|
|
|
if not key:
|
|
return {"error": "key is required"}
|
|
|
|
if not runtime or not hasattr(runtime, "kv_store"):
|
|
return {"error": "kv_store not available in runtime"}
|
|
|
|
try:
|
|
# Get value from KV store
|
|
value_bytes = runtime.kv_store.get(key.encode("utf-8"))
|
|
|
|
if value_bytes is None:
|
|
return {"result": {"found": False, "value": None}}
|
|
|
|
# Try to decode as JSON
|
|
try:
|
|
value = json.loads(value_bytes.decode("utf-8"))
|
|
except (json.JSONDecodeError, UnicodeDecodeError):
|
|
# Return raw bytes as string if not JSON
|
|
value = value_bytes.decode("utf-8", errors="replace")
|
|
|
|
return {"result": {"found": True, "value": value}}
|
|
|
|
except Exception as e:
|
|
return {"error": f"failed to get value: {str(e)}", "error_code": "KV_GET_FAILED"}
|