Skip to content

Commit

Permalink
Refactor the entire code structure
Browse files Browse the repository at this point in the history
  • Loading branch information
SimFG committed Oct 18, 2023
1 parent 5210bdb commit 542be08
Show file tree
Hide file tree
Showing 79 changed files with 4,464 additions and 4,910 deletions.
79 changes: 68 additions & 11 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,80 @@ run:
- pb
- mocks

linters-settings:
golint:
min-confidence: 0.8

misspell:
locale: US

linters:
disable-all: true
enable:
- typecheck
- goimports
- misspell
- gosimple
- govet
- ineffassign
- gosimple
- staticcheck
- decorder
- depguard
- gofmt
- goimports
- gosec
- revive
- unconvert
- misspell
- typecheck
- durationcheck
- forbidigo
- gci
- whitespace
- gofumpt
- gocritic

linters-settings:
gci:
sections:
- standard
- default
- prefix(github.com/milvus-io)
custom-order: true
gofumpt:
lang-version: "1.18"
module-path: github.com/milvus-io
goimports:
local-prefixes: github.com/milvus-io
revive:
rules:
- name: unused-parameter
disabled: true
- name: var-naming
severity: warning
disabled: false
arguments:
- ["ID"] # Allow list
- name: context-as-argument
severity: warning
disabled: false
arguments:
- allowTypesBefore: "*testing.T"
- name: datarace
severity: warning
disabled: false
- name: duplicated-imports
severity: warning
disabled: false
- name: waitgroup-by-value
severity: warning
disabled: false
- name: indent-error-flow
severity: warning
disabled: false
arguments:
- "preserveScope"
- name: range-val-in-closure
severity: warning
disabled: false
- name: range-val-address
severity: warning
disabled: false
- name: string-of-int
severity: warning
disabled: false
misspell:
locale: US

issues:
exclude-use-default: false
Expand Down
15 changes: 13 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,23 @@ test-go:
@echo "Running go unittests..."
@(env bash $(PWD)/scripts/run_go_unittest.sh)

lint-fix:
@echo "Running gofumpt fix"
@gofumpt -l -w ./
@echo "Running gci fix"
@gci write ./ --skip-generated -s standard -s default -s "prefix(github.com/zilliztech)" --custom-order

static-check:
@echo "Running go-lint check:"
@(env bash $(PWD)/scripts/run_go_lint.sh)

# TODO use the array to generate the name list
CORE_API := DataHandler MessageManager MetaOp Reader ChannelManager Writer FactoryCreator

generate-mockery:
@echo "Generating mockery server mocks..."
@cd "$(PWD)/server"; mockery -r --name "CDCService|CDCFactory|MetaStore|MetaStoreFactory" --output ./mocks --case snake --with-expecter
@cd "$(PWD)/core"; mockery -r --name "CDCReader|CDCWriter|FactoryCreator|Monitor|WriteCallback|MilvusClientFactory|MilvusClientAPI|ChannelManager|TargetAPI|MetaOp" --output ./mocks --case snake --with-expecter
@echo "Joined string: $(shell echo $(strip $(CORE_API)) | tr ' ' '|')"
@echo ""

# @cd "$(PWD)/server"; mockery -r --name "CDCService|CDCFactory|MetaStore|MetaStoreFactory" --output ./mocks --case snake --with-expecter
@cd "$(PWD)/core"; mockery -r --name "$(shell echo $(strip $(CORE_API)) | tr ' ' '|')" --output ./mocks --case snake --with-expecter
47 changes: 40 additions & 7 deletions core/api/data_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,19 @@ type DataHandler interface {
DropIndex(ctx context.Context, param *DropIndexParam) error
LoadCollection(ctx context.Context, param *LoadCollectionParam) error
ReleaseCollection(ctx context.Context, param *ReleaseCollectionParam) error
CreateDatabase(ctx context.Context, param *CreateDataBaseParam) error
DropDatabase(ctx context.Context, param *DropDataBaseParam) error
Flush(ctx context.Context, param *FlushParam) error
CreateDatabase(ctx context.Context, param *CreateDatabaseParam) error
DropDatabase(ctx context.Context, param *DropDatabaseParam) error

ReplicateMessage(ctx context.Context, param *ReplicateMessageParam) error
// NOTE: please add the implements for the DataHandlerWrapper class when adding new interfaces

DescribeCollection(ctx context.Context, param *DescribeCollectionParam) error
}

type DefaultDataHandler struct{}

var _ DataHandler = (*DefaultDataHandler)(nil)

func (d *DefaultDataHandler) CreateCollection(ctx context.Context, param *CreateCollectionParam) error {
log.Warn("CreateCollection is not implemented, please check it")
return nil
Expand Down Expand Up @@ -81,12 +85,17 @@ func (d *DefaultDataHandler) ReleaseCollection(ctx context.Context, param *Relea
return nil
}

func (d *DefaultDataHandler) CreateDatabase(ctx context.Context, param *CreateDataBaseParam) error {
func (d *DefaultDataHandler) Flush(ctx context.Context, param *FlushParam) error {
log.Warn("Flush is not implemented, please check it")
return nil
}

func (d *DefaultDataHandler) CreateDatabase(ctx context.Context, param *CreateDatabaseParam) error {
log.Warn("CreateDatabase is not implemented, please check it")
return nil
}

func (d *DefaultDataHandler) DropDatabase(ctx context.Context, param *DropDataBaseParam) error {
func (d *DefaultDataHandler) DropDatabase(ctx context.Context, param *DropDatabaseParam) error {
log.Warn("DropDatabase is not implemented, please check it")
return nil
}
Expand All @@ -96,14 +105,25 @@ func (d *DefaultDataHandler) ReplicateMessage(ctx context.Context, param *Replic
return nil
}

func (d *DefaultDataHandler) DescribeCollection(ctx context.Context, param *DescribeCollectionParam) error {
log.Warn("DescribeCollection is not implemented, please check it")
return nil
}

type MsgBaseParam struct {
Base *commonpb.MsgBase
}

type CreateCollectionParam struct {
MsgBaseParam
Schema *entity.Schema
ShardsNum int32
ConsistencyLevel commonpb.ConsistencyLevel
Properties []*commonpb.KeyValuePair
}

type DropCollectionParam struct {
MsgBaseParam
CollectionName string
}

Expand All @@ -120,11 +140,13 @@ type DeleteParam struct {
}

type CreatePartitionParam struct {
MsgBaseParam
CollectionName string
PartitionName string
}

type DropPartitionParam struct {
MsgBaseParam
CollectionName string
PartitionName string
}
Expand All @@ -145,17 +167,28 @@ type ReleaseCollectionParam struct {
milvuspb.ReleaseCollectionRequest
}

type CreateDataBaseParam struct {
type CreateDatabaseParam struct {
milvuspb.CreateDatabaseRequest
}

type DropDataBaseParam struct {
type DropDatabaseParam struct {
milvuspb.DropDatabaseRequest
}

type FlushParam struct {
milvuspb.FlushRequest
}

type ReplicateMessageParam struct {
MsgBaseParam
ChannelName string
BeginTs, EndTs uint64
MsgsBytes [][]byte
StartPositions, EndPositions []*msgpb.MsgPosition

TargetMsgPosition string
}

type DescribeCollectionParam struct {
Name string
}
Loading

0 comments on commit 542be08

Please sign in to comment.