| @@ -2,17 +2,4 @@ package cmd | |||||
| import "github.com/spf13/cobra" | import "github.com/spf13/cobra" | ||||
| var RootCmd = &cobra.Command{ | |||||
| Use: "coordinator", | |||||
| Short: "Coordinator service for storage", | |||||
| Long: `Coordinator service for storage`, | |||||
| } | |||||
| func init() { | |||||
| var configPath string | |||||
| RootCmd.Flags().StringVarP(&configPath, "config", "c", "", "Path to config file") | |||||
| RootCmd.Run = func(cmd *cobra.Command, args []string) { | |||||
| serve(configPath) | |||||
| } | |||||
| } | |||||
| var RootCmd = &cobra.Command{} | |||||
| @@ -5,6 +5,7 @@ import ( | |||||
| "fmt" | "fmt" | ||||
| "os" | "os" | ||||
| "github.com/spf13/cobra" | |||||
| "gitlink.org.cn/cloudream/common/pkgs/logger" | "gitlink.org.cn/cloudream/common/pkgs/logger" | ||||
| "gitlink.org.cn/cloudream/common/pkgs/mq" | "gitlink.org.cn/cloudream/common/pkgs/mq" | ||||
| coormq "gitlink.org.cn/cloudream/jcs-pub/common/pkgs/mq/coordinator" | coormq "gitlink.org.cn/cloudream/jcs-pub/common/pkgs/mq/coordinator" | ||||
| @@ -14,6 +15,20 @@ import ( | |||||
| mymq "gitlink.org.cn/cloudream/jcs-pub/coordinator/internal/mq" | mymq "gitlink.org.cn/cloudream/jcs-pub/coordinator/internal/mq" | ||||
| ) | ) | ||||
| func init() { | |||||
| var configPath string | |||||
| cmd := &cobra.Command{ | |||||
| Use: "serve", | |||||
| Short: "Start coordinator server", | |||||
| Long: `Start coordinator server`, | |||||
| Run: func(cmd *cobra.Command, args []string) { | |||||
| serve(configPath) | |||||
| }, | |||||
| } | |||||
| cmd.Flags().StringVarP(&configPath, "config", "c", "", "Path to config file") | |||||
| RootCmd.AddCommand(cmd) | |||||
| } | |||||
| func serve(configPath string) { | func serve(configPath string) { | ||||
| err := config.Init(configPath) | err := config.Init(configPath) | ||||
| if err != nil { | if err != nil { | ||||
| @@ -13,7 +13,6 @@ type StorageFeature interface { | |||||
| } | } | ||||
| var _ = serder.UseTypeUnionInternallyTagged(types.Ref(types.NewTypeUnion[StorageFeature]( | var _ = serder.UseTypeUnionInternallyTagged(types.Ref(types.NewTypeUnion[StorageFeature]( | ||||
| (*TempStore)(nil), | |||||
| (*BypassWriteFeature)(nil), | (*BypassWriteFeature)(nil), | ||||
| (*MultipartUploadFeature)(nil), | (*MultipartUploadFeature)(nil), | ||||
| (*InternalServerlessCallFeature)(nil), | (*InternalServerlessCallFeature)(nil), | ||||
| @@ -21,20 +20,6 @@ var _ = serder.UseTypeUnionInternallyTagged(types.Ref(types.NewTypeUnion[Storage | |||||
| (*ECMultiplierFeature)(nil), | (*ECMultiplierFeature)(nil), | ||||
| )), "type") | )), "type") | ||||
| type TempStore struct { | |||||
| serder.Metadata `union:"TempStore"` | |||||
| Type string `json:"type"` | |||||
| TempRoot string `json:"tempRoot"` // 临时文件存放目录 | |||||
| } | |||||
| func (f *TempStore) GetFeatureType() string { | |||||
| return "TempStore" | |||||
| } | |||||
| func (f *TempStore) String() string { | |||||
| return "TempStore" | |||||
| } | |||||
| // 存储服务支持被非MasterHub直接上传文件 | // 存储服务支持被非MasterHub直接上传文件 | ||||
| type BypassWriteFeature struct { | type BypassWriteFeature struct { | ||||
| serder.Metadata `union:"BypassWrite"` | serder.Metadata `union:"BypassWrite"` | ||||