userver Framework

repository·develop·Indexed 25 days ago

https://github.com/userver-framework/userver

An open-source asynchronous C++ framework for building high-performance microservices and utilities. It features a coroutine-based architecture to optimize I/O-bound workloads and includes a core runtime with an asynchronous engine, component system, and dynamic configuration. The framework provides asynchronous drivers for databases (PostgreSQL, MongoDB, Redis, Valkey, ClickHouse, MySQL/MariaDB, YDB, SQLite) and protocols (HTTP/1.1, HTTP/2.0, gRPC, AMQP 0-9-1, Kafka, TCP, TLS, WebSocket), as well as the Chaotic JSON schema codegen tool.

Tokens
118.1K
Snippets
187
Records
787
Agent score
83%

What's inside userver

  1. Overview of userver core functionality

    develop

    The userver core provides the fundamental building blocks for high-performance asynchronous services. Key features include:

    • Asynchronous Engine: The core runtime for managing non-blocking operations.
    • Synchronization Primitives: Tools for managing concurrency.
    • HTTP Client and Server: Built-in support for web communication.
    • Component System: A framework for managing service components and their lifecycles.
    • Sockets: Low-level networking capabilities.
    • Dynamic Configs: Support for updating configuration at runtime.
    • Caches: High-performance caching mechanisms.
    • Logging and Tracing: Observability tools for monitoring application flow.
    • Metrics: Integration for service monitoring and telemetry.
    • Universal Utilities: Helper classes provided via the userver::universal CMake target.
  2. Overview of userver Kafka Driver

    develop
    The userver Kafka Driver provides a high-performance, asynchronous client for interacting with Apache Kafka. It is designed to integrate seamlessly with the userver framework's coroutine-based architecture, allowing for non-blocking Kafka operations within your services.
  3. Overview of HTTP, HTTPS, and WebSocket capabilities

    develop

    The userver-core library provides a Server component that implements several networking protocols and features:

    Supported Protocols:

    • HTTP 1.1/1.0
    • HTTPS
    • WebSocket
    • HTTP 2.0

    Key Features:

    • Compression: Body decompression with Content-Encoding: gzip.
    • Performance: HTTP pipelining and streaming support.
    • Security & Control: Custom authorization, rate limiting (via Congestion control and individual handler configuration), and requests-in-flight limiting.
    • Inspection: Request inspection via server::handlers::InspectRequests.
    • Limits: Configurable limits for body size, headers count, URL length, etc.
    • Data Handling: Multipart/form-data support (file uploads) and deadline propagation.
  4. Overview of userver framework

    develop
    userver is a modern open-source asynchronous C++ framework designed for creating high-performance microservices, services, and utilities. It provides a rich set of abstractions to handle efficient I/O interactions transparently, allowing developers to write code that looks synchronous while executing asynchronously.
  5. Overview of userver C++ Asynchronous Framework

    develop
    userver is a modern open-source asynchronous framework designed for the fast and efficient creation of C++ microservices, services, and utilities. It transparently handles efficient I/O interactions, allowing developers to write straightforward source code while avoiding CPU-consuming OS context switches. The framework utilizes a small number of execution threads to efficiently maximize CPU utilization.
  6. Overview of userver code generation capabilities

    develop

    userver provides several code generation tools to automate the creation of routine code and types from declarative external contracts. Supported generation tasks include:

    • JSON Schema to C++: Generates types, parsers, and serializers for PostgreSQL JSON/JSONB types, static configurations, and Kafka/RabbitMQ messages.
    • JSON Schema to Dynamic Configs: Generates wrappers for dynamic configuration variables.
    • OpenAPI/Swagger to HTTP Client: Generates a C++ HTTP client from an OpenAPI/Swagger specification.
    • OpenAPI/Swagger to Server Handlers: Generates C++ server handlers and view stubs from an OpenAPI/Swagger specification.
    • SQL Files: Generates code from SQL files.
  7. Overview of userver asynchronous framework

    develop
    userver is an open-source asynchronous C++ framework designed for building high-performance microservices, services, and utilities. It provides high-level abstractions that handle efficient I/O interactions transparently. Instead of suspending OS threads during I/O operations, userver allows threads to process other requests and tasks, returning to the original operation only when it can execute immediately. This approach minimizes CPU-consuming context switches and maximizes CPU utilization with a minimal number of execution threads.
  8. Overview of userver Chaotic Codegen Functionality

    develop
    The chaotic component provides JSON schema codegen functionality. It is used to generate C++ code from JSON schemas, enabling efficient DOM and SAX parsing for custom types. The toolchain involves transforming YAML to a Python representation, which is then transformed into C++ code.
  9. Understand Deadline Propagation in userver

    develop

    Deadline propagation ensures that if a parent request times out, all downstream requests (to other services or databases) are also canceled to save CPU and prevent wasted work.

    In userver:

    • HTTP Clients: Send the remaining time via X-YaTaxi-Client-TimeoutMs (duration) and optionally X-Request-Deadline (absolute Unix timestamp).
    • HTTP Handlers: Inherit the deadline from headers, use it for downstream clients, and return a special Deadline expired response if the deadline is reached during processing.
    • Clients: Immediately return an error if the deadline has already expired and propagate the deadline to downstream services.
    • Database Clients: Stop waiting for connections if the deadline has expired and include the deadline in the query.