Skip to content

SDK Overview

SDKs for можно. are client libraries that fetch rule sets from the server and evaluate feature flags locally in your application.

Architecture

sequenceDiagram
    participant App as Application
    participant SDK as SDK
    participant Server as Server
        
    SDK->>Server: GET /api/client/features
    Server-->>SDK: flag rules
    Note over SDK: Caches in memory
        
    Note over App,SDK: Flag evaluation
    App->>SDK: isEnabled("flag", ctx)
        Note over SDK: Evaluates locally<br/>using cached rules
    SDK-->>App: true / false
        
    Note over SDK,Server: Background refresh
    loop every 15 seconds
            SDK->>Server: GET /api/client/features<br/>(If-None-Match)
            Server-->>SDK: 304 Not Modified<br/>or updated rules
        end

How Local Evaluation Works

  1. Startup: The SDK fetches all flag rules from the server once.
  2. Caching: Rules are stored in memory.
  3. Local evaluation: Each isEnabled() call is evaluated locally — no network latency.
  4. Background refresh: The SDK periodically polls the server (default every 15 seconds) and updates the cache. Uses ETag / If-None-Match for efficient delta updates.
BenefitDescription
Zero latencyFlag evaluation: sub-millisecond
No single point of failureIf the server is unavailable, the SDK continues working with cached rules
ScalableThe server is not loaded with flag evaluation requests

Evaluation Logic

Evaluation order — Targeting. Operators and context types — Contexts.

Polling

The SDK uses polling (periodic requests) to stay in sync. Default interval is 15 seconds.

sequenceDiagram
    participant SDK
    participant Server

    SDK->>Server: GET /api/client/features (If-None-Match)
    Server-->>SDK: 200 + JSON (or 304 Not Modified)
    Note over SDK: Cache in memory

    loop Every 15 seconds
        SDK->>Server: GET /api/client/features (If-None-Match)
        Server-->>SDK: 304 Not Modified (or updated flags)
        Note over SDK: Atomic cache update
    end
ParameterDefaultDescription
Polling interval15 secondsrefreshInterval (JS) / fetchTogglesInterval (Java)
Retry on errorExponential backoff1s → 2s → 4s
Circuit breaker (Java)5 failures → 60s pauseServer overload protection

Evaluation Context

The context carries user/request attributes used for targeting:

java
MozhnoContext context = MozhnoContext.builder()
    .userId("user-123")
    .sessionId("session-abc")
    .addProperty("country", "US")
    .addProperty("plan", "premium")
    .build();
typescript
const context = {
  userId: 'user-123',
  sessionId: 'session-abc',
  country: 'US',
  plan: 'premium',
};

Error Handling & Resilience

Behavior Rules

ScenarioBehavior
Server unreachable at startupSDK starts and keeps retrying in the background. isEnabled() returns false until rules are loaded
Server becomes unreachableSDK continues working with cached rules. Background reconnection attempts
Flag not foundReturns false (fail-closed)
Context attribute missingRule referencing that attribute returns false
Cache is emptyReturns false

Propagation Delay

Flag changes in the dashboard reach the SDK within one polling interval (default 15 seconds).

Next Steps

Released under the BSL 1.1 License.