Skip to content
This repository was archived by the owner on Apr 23, 2026. It is now read-only.

refactor(proxmox-client): trait 도입으로 match AccessType 중복 소거 (1/2) - #72

Merged
dalsoop merged 1 commit into
mainfrom
feat/proxmox-client-trait
Apr 20, 2026
Merged

refactor(proxmox-client): trait 도입으로 match AccessType 중복 소거 (1/2)#72
dalsoop merged 1 commit into
mainfrom
feat/proxmox-client-trait

Conversation

@dalsoop

@dalsoop dalsoop commented Apr 20, 2026

Copy link
Copy Markdown
Owner

Summary

`fetch_containers` / `start_container` / `stop_container` / `console_cmd` 4개 함수에서 반복되던 `match server.access { Ssh => ..., Api => ... }` 분기를 `ProxmoxClient` trait 으로 대체.

API

```rust
pub trait ProxmoxClient {
fn fetch_containers_raw(&self) -> Vec;
fn start(&self, c: &Container);
fn stop(&self, c: &Container);
fn console(&self, c: &Container) -> Option;
}
```

  • `SshProxmoxClient`, `ApiProxmoxClient` 둘 다 `&ProxmoxServer` 만 참조 (lifetime)
  • `client_for(server) -> Box<dyn ProxmoxClient + '_>`
  • 기존 free fn 4개는 시그니처 그대로, 내부 1~2줄 wrapper 로 축소
  • 캐시/정렬(running first)은 wrapper 레벨 공통화 그대로 (fetch_containers)
  • 호출부(`cli.rs`, `main.rs`) 변경 없음

남은 것 (PR 2/2 예정)

`fetch_host_info / fetch_resources / fetch_docker / fetch_ports / fetch_snapshots / docker_logs_cmd / container_logs_cmd / docker_exec_cmd` — 이 rest 도 trait 에 흡수하면 모든 `match AccessType` 이 사라짐. 범위가 커 분리.

Test plan

  • `cargo test --release -p tmux-config` — 58/58
  • `cargo clippy --release -p tmux-config -- -D warnings` — clean
  • pve 호스트 `pve-list` / `pve-ct pve` (43 rows) 회귀 확인

🤖 Generated with Claude Code

fetch_containers / start_container / stop_container / console_cmd 4개에서
반복되던 match server.access { Ssh => ..., Api => ... } 을 ProxmoxClient trait
으로 대체.

- pub trait ProxmoxClient { fetch_containers_raw / start / stop / console }
- SshProxmoxClient / ApiProxmoxClient (둘 다 &ProxmoxServer 참조)
- client_for(server) -> Box<dyn ProxmoxClient + '_>
- 기존 free fn 4개는 시그니처 유지한 채 내부 1~2줄 wrapper 로 축소
- 캐시·정렬 로직은 wrapper 레벨에 그대로 두어 공통화 (+fetch_containers)
- 호출부(cli/main) 변경 없음

후속: fetch_host_info / resources / docker / ports / snapshots / *_cmd 들도
같은 방식으로 trait 에 흡수 예정 (PR 2/2)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@dalsoop

dalsoop commented Apr 20, 2026

Copy link
Copy Markdown
Owner Author

Dalteam Review

No findings.

@dalsoop
dalsoop merged commit 5a49925 into main Apr 20, 2026
2 checks passed
@dalsoop
dalsoop deleted the feat/proxmox-client-trait branch April 20, 2026 05:00
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant