Skip to content

内置依赖注入

数据库与缓存

依赖类型导入路径描述
Databaseapp.dependencies.database数据库会话(AsyncSession),用于执行数据库操作
NoContextDBapp.dependencies.database无上下文数据库会话(AsyncSession),用于在不在依赖注入共享 Session 的情况下执行数据库操作。如果你遇到了并发使用连接的问题,可以使用此依赖
Redisapp.dependencies.databaseRedis 客户端(redis.asyncio.Redis),用于缓存操作

核心服务

依赖类型导入路径描述
Fetcherapp.dependencies.fetcherFetcher 实例,用于从 osu! 官方获取数据
StorageServiceapp.dependencies.storage存储服务,用于文件存储操作
EventHubapp.dependencies.event_hub事件中心,用于发送和订阅事件

缓存服务

依赖类型导入路径描述
BeatmapsetCacheServiceapp.dependencies.cache谱面集缓存服务
UserCacheServiceapp.dependencies.cache用户缓存服务

请求上下文

依赖类型导入路径描述
IPAddressapp.dependencies.geoip客户端 IP 地址(str
GeoIPServiceapp.dependencies.geoipGeoIP 服务,用于根据 IP 查询地理位置
UserAgentInfoapp.dependencies.user_agent用户代理信息模型
APIVersionapp.dependencies.api_versionAPI 版本号(int

聊天

依赖类型导入路径描述
BanchoBotapp.dependencies.botBanchoBot 实例,用于发送聊天消息

其他服务

依赖类型导入路径描述
DownloadServiceapp.dependencies.beatmap_download谱面下载服务,提供负载均衡的下载 URL
ClientVerificationServiceapp.dependencies.client_verification客户端版本验证服务

Released under the MIT License