Files
leleka/crates/runtime-client/tests/grpc_backend.rs
T
Pavlo Ratushnyi 0ad203f7d7 STRA-338 size-rest: tokenizer, gateway-text, gateway-domain, runtime-client, cpu-worker and experimental-ref within 400 lines per file
Oversize files before/after: tokenizer 1 -> 0 (lib.rs 840 into construction, encoding, decoding, bpe_merge, vocabulary),
gateway-text 1 -> 0, runtime-client 1 -> 0, cpu-worker 1 -> 0, experimental-ref 1 -> 0 (test files split by topic),
gateway-domain 1 -> 0: render_request_with (385 lines, complexity 93) became an entry function plus one function per
system message and one method per input item kind; messages, check order and rendered text unchanged (gateway-domain 17
tests and strata-control responses 72 tests pass).

Census prod/test (fn>30 / cx>10 / nesting>4 / wide lines): gateway-domain 16/3, 13/0, 6/0, 53/1 -> 16/3, 12/0, 5/0, 45/1;
runtime-client test 9 -> 6 long functions; experimental-ref test wide lines 58 -> 37; tokenizer, gateway-text and
cpu-worker unchanged. Test ids and outcomes unchanged.
2026-11-06 16:28:25 +01:00

50 lines
1.6 KiB
Rust

//! `GrpcBackend` against a scripted `leleka.runtime.v1` server over real loopback HTTP/2.
//!
//! The server here is a stand-in: it answers snapshots, replays the frames a test gives it and counts
//! cancels. The full chain with the real `RuntimeServer` and a scripted engine behind it is exercised
//! in `strata-desktop-core` (`tests/api_over_runtime.rs`). Nothing here loads a model.
use std::{
net::SocketAddr,
pin::Pin,
sync::{
Arc, Mutex,
atomic::{AtomicUsize, Ordering},
},
time::Duration,
};
use futures_util::Stream;
use leleka_backend_api::{
Backend, ErrorCode, FinishReason, GenerationEvent, GenerationRequest, GenerationTerminal, InferenceMode,
LoadedModel, ModelDescriptor, RuntimeConfig, SamplingOptions, StreamError, Usage,
};
use leleka_runtime_client::{
backend::GrpcBackend,
convert,
proto::{self, generation_frame::Payload},
};
use tonic::{Request, Response, Status};
#[path = "grpc_backend/attach_and_reconfigure.rs"]
mod attach_and_reconfigure;
#[path = "grpc_backend/generation.rs"]
mod generation;
#[path = "grpc_backend/runtime_restart_and_loss.rs"]
mod runtime_restart_and_loss;
#[path = "grpc_backend/stream_lifecycle.rs"]
mod stream_lifecycle;
#[path = "grpc_backend/fixtures.rs"]
mod fixtures;
use fixtures::{config, descriptor, loaded};
#[path = "grpc_backend/scripted_service.rs"]
mod scripted_service;
#[path = "grpc_backend/server_and_frames.rs"]
mod server_and_frames;
use server_and_frames::{blocking, drain, id, request, terminal, text, usage};
#[path = "grpc_backend/scripted_types.rs"]
mod scripted_types;
use scripted_types::{Fake, FakeState, Frames, Server, TOKEN};