Browse Source

coor增加serve命令

feature_gxh
Sydonian 7 months ago
parent
commit
bb0fbeb7d6
3 changed files with 16 additions and 29 deletions
  1. +1
    -14
      coordinator/internal/cmd/cmd.go
  2. +15
    -0
      coordinator/internal/cmd/serve.go
  3. +0
    -15
      coordinator/types/storage_feature.go

+ 1
- 14
coordinator/internal/cmd/cmd.go View File

@@ -2,17 +2,4 @@ package cmd

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{}

+ 15
- 0
coordinator/internal/cmd/serve.go View File

@@ -5,6 +5,7 @@ import (
"fmt"
"os"

"github.com/spf13/cobra"
"gitlink.org.cn/cloudream/common/pkgs/logger"
"gitlink.org.cn/cloudream/common/pkgs/mq"
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"
)

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) {
err := config.Init(configPath)
if err != nil {


+ 0
- 15
coordinator/types/storage_feature.go View File

@@ -13,7 +13,6 @@ type StorageFeature interface {
}

var _ = serder.UseTypeUnionInternallyTagged(types.Ref(types.NewTypeUnion[StorageFeature](
(*TempStore)(nil),
(*BypassWriteFeature)(nil),
(*MultipartUploadFeature)(nil),
(*InternalServerlessCallFeature)(nil),
@@ -21,20 +20,6 @@ var _ = serder.UseTypeUnionInternallyTagged(types.Ref(types.NewTypeUnion[Storage
(*ECMultiplierFeature)(nil),
)), "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直接上传文件
type BypassWriteFeature struct {
serder.Metadata `union:"BypassWrite"`


Loading…
Cancel
Save