rename

package
v2.0.8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 11, 2025 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

AllowedTopics 定义了系统支持的所有文件重命名操作主题 用于管理和限制系统中允许使用的PubSub主题

Functions

func HandleRenameFileSegmentRequestPubSub

func HandleRenameFileSegmentRequestPubSub(
	ctx context.Context,
	opt *fscfg.Options,
	db *database.DB,
	fs afero.Afero,
	nps *pubsub.NodePubSub,
	res *pubsub.Message,
)

HandleRenameFileSegmentRequestPubSub 处理重命名文件请求 参数:

  • ctx: 上下文对象,用于控制请求处理的生命周期
  • opt: 文件系统配置选项,包含系统运行所需的配置信息
  • db: 数据库实例,用于访问文件存储数据
  • fs: 文件系统接口,用于文件操作
  • nps: 节点发布订阅系统实例,用于网络通信
  • res: 接收到的消息,包含重命名请求数据

func RegisterRenamePubsubProtocol

func RegisterRenamePubsubProtocol(lc fx.Lifecycle, input RegisterPubsubProtocolInput)

RegisterRenamePubsubProtocol 注册文件重命名相关的PubSub协议处理器 参数:

  • lc: fx.Lifecycle 应用生命周期管理器,用于管理协议处理器的生命周期
  • input: RegisterPubsubProtocolInput 注册所需的输入参数,包含所有必要的依赖项

返回值:

  • error: 如果注册过程中出现错误,返回相应的错误信息;成功则返回nil

func RequestRenameFileSegmentPubSub

func RequestRenameFileSegmentPubSub(
	ctx context.Context,
	nps *pubsub.NodePubSub,
	fileID string,
	pubkeyHash []byte,
	newName string,
) error

RequestRenameFileSegmentPubSub 请求重命名文件 参数:

  • ctx: 上下文对象,用于控制请求的生命周期
  • nps: 节点发布订阅系统实例,用于发布重命名请求
  • fileID: 要重命名的文件ID,用于标识目标文件
  • pubkeyHash: 文件所有者的公钥哈希,用于验证权限
  • newName: 新的文件名,文件将被重命名为此名称

返回值:

  • error: 如果请求发送成功返回nil,否则返回错误信息

Types

type RegisterPubsubProtocolInput

type RegisterPubsubProtocolInput struct {
	fx.In

	Ctx  context.Context    // 全局上下文,用于管理整个应用的生命周期
	Opt  *fscfg.Options     // 文件存储配置选项,包含系统运行所需的各种参数
	DB   *database.DB       // 本地数据存储实例,用于持久化数据
	FS   afero.Afero        // 文件系统接口,提供文件操作能力
	Host host.Host          // libp2p网络主机实例,用于P2P网络通信
	NPS  *pubsub.NodePubSub // 发布订阅系统,用于处理P2P网络中的消息订阅和发布
}

RegisterPubsubProtocolInput 定义了注册PubsubProtocol所需的输入参数 使用fx.In标记用于依赖注入

type Topic

type Topic int

Topic 定义了文件重命名操作的主题类型 用于标识不同类型的PubSub消息主题

const (
	PubSubRenameFileSegmentRequestTopic Topic = iota // 重命名文件请求主题:用于修改文件名的请求消息
)

定义文件重命名操作的主题类型常量

func (Topic) String

func (t Topic) String() string

String 将Topic转换为对应的字符串表示 参数:

  • t: Topic类型的主题枚举值

返回值:

  • string: 返回主题对应的字符串名称

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL