feat: 添加业务服务层和结构化日志
- JobService: 提交、查询、取消、历史记录,记录关键操作日志 - ClusterService: 节点、分区、诊断查询,记录错误日志 - NewSlurmClient: JWT 认证 HTTP 客户端工厂 - 所有构造函数接受 *zap.Logger 参数实现依赖注入 - 提交/取消成功记录 Info,API 错误记录 Error - 完整 TDD 测试,使用 zaptest/observer 验证日志输出 Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
15
internal/service/slurm_client.go
Normal file
15
internal/service/slurm_client.go
Normal file
@@ -0,0 +1,15 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"gcy_hpc_server/internal/slurm"
|
||||
)
|
||||
|
||||
// NewSlurmClient creates a Slurm SDK client with JWT authentication.
|
||||
// It reads the JWT key from the given keyPath and signs tokens automatically.
|
||||
func NewSlurmClient(apiURL, userName, jwtKeyPath string) (*slurm.Client, error) {
|
||||
return slurm.NewClientWithOpts(
|
||||
apiURL,
|
||||
slurm.WithUsername(userName),
|
||||
slurm.WithJWTKey(jwtKeyPath),
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user