0.5.1-pre.006
This commit is contained in:
@@ -1,8 +1,13 @@
|
||||
<!-- file: ks-onchain-transport/CHANGELOG.md -->
|
||||
<!-- version: 13 -->
|
||||
<!-- version: 14 -->
|
||||
|
||||
# CHANGELOG — ks-onchain-transport
|
||||
|
||||
## `0.5.1-pre.006`
|
||||
|
||||
- permet de construire directement les pools HTTP et WebSocket depuis `ks_config::TransportProfileConfig` ;
|
||||
- conserve temporairement les constructeurs `from_profile` sur le contrat runtime résolu pour compatibilité pendant la décomposition de configuration.
|
||||
|
||||
## `0.5.1-pre.002`
|
||||
|
||||
- renomme `kb-onchain-transport` en `ks-onchain-transport` et `kb_onchain_transport` en `ks_onchain_transport` ;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<!-- file: ks-onchain-transport/README.md -->
|
||||
<!-- version: 2 -->
|
||||
<!-- version: 3 -->
|
||||
|
||||
# ks-onchain-transport
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
- requêtes JSON-RPC HTTP standard ;
|
||||
- sessions et pools WebSocket ;
|
||||
- routage par rôle d’endpoint ;
|
||||
- consommation directe des profils partagés définis par `config/transport.config.json` via `ks-config` ;
|
||||
- adaptation des réponses RPC vers les contrats canoniques ;
|
||||
- simulation, soumission et confirmation de transactions ;
|
||||
- acquisition de signatures et transactions pour le backfill ;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<!-- file: ks-onchain-transport/USAGE.md -->
|
||||
<!-- version: 6 -->
|
||||
<!-- version: 7 -->
|
||||
|
||||
# Utilisation de ks-onchain-transport
|
||||
|
||||
@@ -9,7 +9,7 @@ La crate expose les contrats publics nécessaires aux communications RPC HTTP et
|
||||
|
||||
## Prérequis
|
||||
|
||||
- une configuration `ks-config` contenant au moins un endpoint compatible ;
|
||||
- un profil de transport `ks-config::TransportProfileConfig` contenant au moins un endpoint compatible ;
|
||||
- un runtime Tokio pour les opérations asynchrones ;
|
||||
- des limites et engagements adaptés à l’opération demandée.
|
||||
|
||||
@@ -32,9 +32,9 @@ fn build_http_client(
|
||||
|
||||
```rust
|
||||
fn select_query_client(
|
||||
profile: &ks_config::ProfileConfig,
|
||||
profile: &ks_config::TransportProfileConfig,
|
||||
) -> ks_core::Result<ks_onchain_transport::HttpClient> {
|
||||
let pool_result = ks_onchain_transport::HttpEndpointPool::from_profile(profile);
|
||||
let pool_result = ks_onchain_transport::HttpEndpointPool::from_transport_profile(profile);
|
||||
let pool = match pool_result {
|
||||
Ok(pool) => pool,
|
||||
Err(error) => return Err(error),
|
||||
@@ -44,7 +44,7 @@ fn select_query_client(
|
||||
}
|
||||
```
|
||||
|
||||
`HttpEndpointPool::snapshot` fournit un état sérialisable des endpoints actifs et de leurs rôles.
|
||||
`HttpEndpointPool::snapshot` fournit un état sérialisable des endpoints actifs et de leurs rôles. Les constructeurs `from_profile` restent temporairement disponibles pour le contrat runtime `ProfileConfig` résolu pendant la migration `0.5.1`.
|
||||
|
||||
## Classer une méthode RPC
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// file: ks-onchain-transport/src/http_pool.rs
|
||||
// version: 9
|
||||
// version: 10
|
||||
|
||||
//! HTTP endpoint pool and role-based routing.
|
||||
|
||||
@@ -11,10 +11,21 @@ pub struct HttpEndpointPool {
|
||||
}
|
||||
|
||||
impl crate::HttpEndpointPool {
|
||||
/// Builds a pool from the active profile HTTP endpoint list.
|
||||
/// Builds a pool from an independently selected transport profile.
|
||||
pub fn from_transport_profile(
|
||||
profile: &ks_config::TransportProfileConfig,
|
||||
) -> ks_core::Result<Self> {
|
||||
return crate::HttpEndpointPool::from_http_endpoints(&profile.http_endpoints);
|
||||
}
|
||||
|
||||
/// Builds a pool from the resolved application profile HTTP endpoint list.
|
||||
pub fn from_profile(profile: &ks_config::ProfileConfig) -> ks_core::Result<Self> {
|
||||
return crate::HttpEndpointPool::from_http_endpoints(&profile.solana.http_endpoints);
|
||||
}
|
||||
|
||||
fn from_http_endpoints(endpoints: &[ks_config::HttpEndpointConfig]) -> ks_core::Result<Self> {
|
||||
let mut clients = std::vec::Vec::new();
|
||||
for endpoint in &profile.solana.http_endpoints {
|
||||
for endpoint in endpoints {
|
||||
if !endpoint.enabled {
|
||||
continue;
|
||||
}
|
||||
@@ -184,6 +195,26 @@ mod tests {
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn transport_profile_builds_http_pool_without_resolved_app_profile() {
|
||||
let profile = ks_config::TransportProfileConfig {
|
||||
name: "direct".to_string(),
|
||||
http_endpoints: std::vec![endpoint(
|
||||
"direct",
|
||||
"http_queries",
|
||||
std::vec!["get_version".to_string()],
|
||||
)],
|
||||
ws_endpoints: std::vec::Vec::new(),
|
||||
};
|
||||
let pool = match crate::HttpEndpointPool::from_transport_profile(&profile) {
|
||||
std::result::Result::Ok(value) => value,
|
||||
std::result::Result::Err(error) => {
|
||||
panic!("transport profile pool creation failed: {error}")
|
||||
},
|
||||
};
|
||||
assert_eq!(pool.snapshot().len(), 1);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn new_rejects_empty_pool() {
|
||||
let result = crate::HttpEndpointPool::new(std::vec::Vec::new());
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// file: ks-onchain-transport/src/ws_pool.rs
|
||||
// version: 7
|
||||
// version: 8
|
||||
|
||||
//! WebSocket endpoint pool and role-based routing.
|
||||
|
||||
@@ -11,10 +11,21 @@ pub struct WsEndpointPool {
|
||||
}
|
||||
|
||||
impl crate::WsEndpointPool {
|
||||
/// Builds a pool from the active profile WebSocket endpoint list.
|
||||
/// Builds a pool from an independently selected transport profile.
|
||||
pub fn from_transport_profile(
|
||||
profile: &ks_config::TransportProfileConfig,
|
||||
) -> ks_core::Result<Self> {
|
||||
return crate::WsEndpointPool::from_ws_endpoints(&profile.ws_endpoints);
|
||||
}
|
||||
|
||||
/// Builds a pool from the resolved application profile WebSocket endpoint list.
|
||||
pub fn from_profile(profile: &ks_config::ProfileConfig) -> ks_core::Result<Self> {
|
||||
return crate::WsEndpointPool::from_ws_endpoints(&profile.solana.ws_endpoints);
|
||||
}
|
||||
|
||||
fn from_ws_endpoints(endpoints: &[ks_config::WsEndpointConfig]) -> ks_core::Result<Self> {
|
||||
let mut clients = std::vec::Vec::new();
|
||||
for endpoint in &profile.solana.ws_endpoints {
|
||||
for endpoint in endpoints {
|
||||
if !endpoint.enabled {
|
||||
continue;
|
||||
}
|
||||
@@ -164,6 +175,26 @@ mod tests {
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn transport_profile_builds_ws_pool_without_resolved_app_profile() {
|
||||
let profile = ks_config::TransportProfileConfig {
|
||||
name: "direct".to_string(),
|
||||
http_endpoints: std::vec::Vec::new(),
|
||||
ws_endpoints: std::vec![endpoint(
|
||||
"direct",
|
||||
"slot_notifications",
|
||||
std::vec!["slot_subscribe".to_string()],
|
||||
)],
|
||||
};
|
||||
let pool = match crate::WsEndpointPool::from_transport_profile(&profile) {
|
||||
std::result::Result::Ok(value) => value,
|
||||
std::result::Result::Err(error) => {
|
||||
panic!("transport profile pool creation failed: {error}")
|
||||
},
|
||||
};
|
||||
assert_eq!(pool.snapshot().len(), 1);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn new_rejects_empty_pool() {
|
||||
let result = crate::WsEndpointPool::new(std::vec::Vec::new());
|
||||
|
||||
Reference in New Issue
Block a user