JCS-pub/common/pkgs/rpc/coordinator/pub_shards.go

90 lines
3.0 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package corrpc
import (
context "context"
"gitlink.org.cn/cloudream/jcs-pub/common/pkgs/rpc"
jcstypes "gitlink.org.cn/cloudream/jcs-pub/common/types"
)
type PubShardsService interface {
CreatePubShards(ctx context.Context, msg *CreatePubShards) (*CreatePubShardsResp, *rpc.CodeError)
HubLoadPubShards(ctx context.Context, msg *HubLoadPubShards) (*HubLoadPubShardsResp, *rpc.CodeError)
UserGetPubShards(ctx context.Context, msg *UserGetPubShards) (*UserGetPubShardsResp, *rpc.CodeError)
}
type CreatePubShards struct {
// 密码原文
Password string
MasterHub jcstypes.HubID
// 公共分片存储的名称,不要求唯一
Name string
// 用户空间所在的存储服务配置
Storage jcstypes.StorageType
// 用户在指定存储节点的凭证信息比如用户账户AK/SK等
Credential jcstypes.StorageCredential
// 用户空间的分片存储配置
ShardStore jcstypes.ShardStoreUserConfig
// 存储服务特性功能的配置
Features []jcstypes.StorageFeature
// 各种组件保存数据的根目录。组件工作过程中都会以这个目录为根除了BaseStore
WorkingDir jcstypes.JPath
}
type CreatePubShardsResp struct {
PubShardStore jcstypes.PubShards
}
var _ = TokenAuth(Coordinator_CreatePubShards_FullMethodName)
func (c *Client) CreatePubShards(ctx context.Context, msg *CreatePubShards) (*CreatePubShardsResp, *rpc.CodeError) {
if c.fusedErr != nil {
return nil, c.fusedErr
}
return rpc.UnaryClient[*CreatePubShardsResp](c.cli.CreatePubShards, ctx, msg)
}
func (s *Server) CreatePubShards(ctx context.Context, msg *rpc.Request) (*rpc.Response, error) {
return rpc.UnaryServer(s.svrImpl.CreatePubShards, ctx, msg)
}
// Hub端加载公共分片存储信息
type HubLoadPubShards struct {
// 公共分片存储的ID
PubShardsID jcstypes.PubShardsID
}
type HubLoadPubShardsResp struct {
PubShards jcstypes.PubShards
}
func (c *Client) HubLoadPubShards(ctx context.Context, msg *HubLoadPubShards) (*HubLoadPubShardsResp, *rpc.CodeError) {
if c.fusedErr != nil {
return nil, c.fusedErr
}
return rpc.UnaryClient[*HubLoadPubShardsResp](c.cli.HubLoadPubShards, ctx, msg)
}
func (s *Server) HubLoadPubShards(ctx context.Context, msg *rpc.Request) (*rpc.Response, error) {
return rpc.UnaryServer(s.svrImpl.HubLoadPubShards, ctx, msg)
}
// 用户获取公共分片存储信息,需要验证密码
type UserGetPubShards struct {
// 公共分片存储的ID
PubShardsID jcstypes.PubShardsID
Password string
}
type UserGetPubShardsResp struct {
PubShards jcstypes.PubShards
MasterHub jcstypes.Hub
}
var _ = TokenAuth(Coordinator_UserGetPubShards_FullMethodName)
func (c *Client) UserGetPubShards(ctx context.Context, msg *UserGetPubShards) (*UserGetPubShardsResp, *rpc.CodeError) {
if c.fusedErr != nil {
return nil, c.fusedErr
}
return rpc.UnaryClient[*UserGetPubShardsResp](c.cli.UserGetPubShards, ctx, msg)
}
func (s *Server) UserGetPubShards(ctx context.Context, msg *rpc.Request) (*rpc.Response, error) {
return rpc.UnaryServer(s.svrImpl.UserGetPubShards, ctx, msg)
}