feat(netconf-proto): add global YANG module cache - #22
Open
riccardo-negri wants to merge 1 commit into
Open
Conversation
riccardo-negri
force-pushed
the
add-yang-modules-cache
branch
from
August 3, 2026 08:35
0e475c2 to
6db86e4
Compare
There was a problem hiding this comment.
Pull request overview
Introduces a globally shared, thread-safe YANG module text cache in netconf-proto and wires it through the NETCONF SSH client and YANG push caching pipeline so repeated (module name, revision) fetches can avoid redundant get-schema RPCs. Also renames the NETCONF monitoring “format” enum to align terminology with RFC 6022.
Changes:
- Added
YangModuleCache(shared across SSH sessions) and integrated it intoNetConfSshClient::get_yang_module. - Plumbed the shared cache through the collector → yang-push cache actor/fetcher and exposed cache hit/miss/size metrics via OTel callbacks.
- Renamed
YangSchemaFormattoGetSchemaFormatin the NETCONF protocol layer.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| crates/yang-push/src/cache/fetcher.rs | Injects a shared YangModuleCache into per-session NETCONF connect configs. |
| crates/yang-push/src/cache/actor.rs | Registers OTel observable instruments that read YangModuleCache atomic stats. |
| crates/netconf-proto/src/yang_module_cache.rs | Adds the new global cache implementation + unit tests and exposed stats. |
| crates/netconf-proto/src/protocol.rs | Renames schema format enum to GetSchemaFormat and updates (de)serialization. |
| crates/netconf-proto/src/lib.rs | Exposes the new yang_module_cache module publicly. |
| crates/netconf-proto/src/client.rs | Adds module cache plumbing to connect/client and implements cached get_yang_module. |
| crates/collector/src/lib.rs | Creates a single shared cache instance and passes it into the yang-push cache actor/fetcher. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
riccardo-negri
force-pushed
the
add-yang-modules-cache
branch
from
August 3, 2026 09:28
6db86e4 to
0941ce2
Compare
Add `YangModuleCache`, a thread-safe cache of raw module texts shared by all SSH sessions so `get_yang_module` skips redundant `get-schema` RPCs for a given `(name, revision)`. Only versioned modules are cached; values are stored as `Arc<str>` for cheap hits. Exposes hit/miss/size counters via OTel, and renames `YangSchemaFormat` -> `GetSchemaFormat` per RFC 6022.
riccardo-negri
force-pushed
the
add-yang-modules-cache
branch
from
August 3, 2026 11:41
0941ce2 to
38bad9c
Compare
ustorbeck
reviewed
Aug 4, 2026
| } | ||
|
|
||
| fn make_key(name: &str, revision: &str) -> String { | ||
| format!("{name}@{revision}") |
Member
There was a problem hiding this comment.
why concatenating the strings to create the key?
better use them in a tuple instead, that's more robust:
type ModuleCacheKey = (String, String);
fn make_key(name: &str, revision: &str) -> ModuleCacheKey {
(name.to_owned(), revision.to_owned())
}
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add
YangModuleCache, a thread-safe cache of raw module texts shared by all SSH sessions soget_yang_moduleskips redundantget-schemaRPCs for a given(name, revision). Only versioned modules are cached; values are stored asArc<str>for cheap hits. Exposes hit/miss/size counters via OTel, and renamesYangSchemaFormat->GetSchemaFormatper RFC 6022.