Files
OpenViking/openviking/server/dependencies.py
T
Haoyu Zhangandzhanghaoyu.la aa53e7aede feat: 实现 commit、restore、show 文件系统多版本管理功能 (#2756)
* feat: 实现 commit、restore、show 文件系统多版本管理功能

fix: 修复commit时删除文件

fix: commit 的 fast path 1 添加 Racy-clean 机制

fix: 将 sdk 中的 git 命令改为 snapshot 命令,同步修改单测

fix: 多版本管理的文件存储目录改为 .ovgit

feat: snapshot cli 渲染

fix: 修复 restore 时将删除的文件回滚时,目录不存在的问题

feat: restore 命令的 project_dir 参数改为可选,不传时默认全目录回滚

feat: 更新文档

fix: 删除暂未使用的配置参数

feat: 新增示例脚本

fix: 修复示例代码

fix: 修复 restore 返回的 task id 任务完成状态

feat: 在 restore 修改文件系统时加锁

fix: fix openviking_sdk

* feat: 将git多版本管理功能改为默认打开,并复用agfs的配置参数作为默认值

* fix: restore 命令改为先完成 ref 一致性协议再写回 VFS;object store 并发改为使用唯一 temp path

* fix: 在 git 配置检验层去除未实现的cas_mode = "redis_lock"模式

* fix: 在 Rust GitService 边界统一校验 account

* fix: 当前commit不支持通过 path 传入目录,增加报错信息

* fix: 将git文件默认存储路径统一为 .ovgit

* fix: restore 时写入 VFS 失败时返回详细的报错,并继续触发 reindex

* fix: 校验 commit、restore、show 的路径

* feat: 实现 commit 时指定目录

---------

Co-authored-by: zhanghaoyu.la <zhanghaoyu.la@bytedance.com>
2026-06-25 11:28:04 +08:00

58 lines
1.6 KiB
Python

# Copyright (c) 2026 Beijing Volcano Engine Technology Co., Ltd.
# SPDX-License-Identifier: AGPL-3.0
"""Dependency injection for OpenViking HTTP Server."""
from typing import TYPE_CHECKING, Optional
from openviking.service.core import OpenVikingService
if TYPE_CHECKING:
from openviking.server.config import ServerConfig
_service: Optional[OpenVikingService] = None
_server_config: Optional["ServerConfig"] = None
def get_service() -> OpenVikingService:
"""Get the OpenVikingService instance.
Returns:
OpenVikingService instance
Raises:
RuntimeError: If service is not initialized
"""
if _service is None:
raise RuntimeError("OpenVikingService not initialized")
return _service
def get_service_or_none() -> Optional[OpenVikingService]:
"""Return the registered OpenVikingService, or None if not set."""
return _service
def set_service(service: Optional[OpenVikingService]) -> None:
"""Set (or clear) the OpenVikingService instance.
Args:
service: OpenVikingService instance to register, or None to clear.
"""
global _service
_service = service
def get_server_config() -> Optional["ServerConfig"]:
"""Return the active ServerConfig if one was registered, else None.
MCP tools that need server-level settings (e.g. public_base_url for upload URLs)
use this to read the loaded ServerConfig without going through ``app.state``.
"""
return _server_config
def set_server_config(config: "ServerConfig") -> None:
"""Register the active ServerConfig at server bootstrap."""
global _server_config
_server_config = config