Skip to content
This repository has been archived by the owner on Nov 10, 2023. It is now read-only.

Commit

Permalink
Supports natsmq
Browse files Browse the repository at this point in the history
Signed-off-by: shaoyue.chen <shaoyue.chen@zilliz.com>
  • Loading branch information
haorenfsa committed Aug 15, 2023
1 parent daa1cbf commit cca07a7
Show file tree
Hide file tree
Showing 15 changed files with 904 additions and 33 deletions.
12 changes: 8 additions & 4 deletions apis/milvus.io/v1beta1/dependencies_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ type MilvusDependencies struct {
// +kubebuilder:validation:Optional
Etcd MilvusEtcd `json:"etcd"`

// +kubebuilder:validation:Enum:={"pulsar", "kafka", "rocksmq", ""}
// +kubebuilder:validation:Enum:={"pulsar", "kafka", "rocksmq", "natsmq", ""}
// +kubebuilder:validation:Optional
// MsgStreamType default to pulsar for cluster, rocksmq for standalone
MsgStreamType MsgStreamType `json:"msgStreamType,omitempty"`
Expand All @@ -28,7 +28,10 @@ type MilvusDependencies struct {
Kafka MilvusKafka `json:"kafka,omitempty"`

// +kubebuilder:validation:Optional
RocksMQ MilvusRocksMQ `json:"rocksmq,omitempty"`
RocksMQ MilvusBuildInMQ `json:"rocksmq,omitempty"`

// +kubebuilder:validation:Optional
NatsMQ MilvusBuildInMQ `json:"natsmq,omitempty"`

// +kubebuilder:validation:Optional
Storage MilvusStorage `json:"storage"`
Expand All @@ -40,6 +43,7 @@ const (
MsgStreamTypePulsar MsgStreamType = "pulsar"
MsgStreamTypeKafka MsgStreamType = "kafka"
MsgStreamTypeRocksMQ MsgStreamType = "rocksmq"
MsgStreamTypeNatsMQ MsgStreamType = "natsmq"
)

type MilvusEtcd struct {
Expand Down Expand Up @@ -88,8 +92,8 @@ type MilvusStorage struct {
External bool `json:"external,omitempty"`
}

// MilvusRocksMQ configuration
type MilvusRocksMQ struct {
// MilvusBuildInMQ (rocksmq or natsmq) configuration
type MilvusBuildInMQ struct {
Persistence Persistence `json:"persistence"`
}

Expand Down
10 changes: 10 additions & 0 deletions apis/milvus.io/v1beta1/milvus_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,16 @@ func (ms MilvusSpec) GetMilvusVersionByImage() (*semver.Version, error) {
return provisioner.GetSemanticVersion(splited[1])
}

func (ms *MilvusSpec) GetPersistenceConfig() *Persistence {
switch ms.Dep.MsgStreamType {
case MsgStreamTypeRocksMQ:
return &ms.Dep.RocksMQ.Persistence
case MsgStreamTypeNatsMQ:
return &ms.Dep.NatsMQ.Persistence
}
return nil
}

// MilvusMode defines the mode of Milvus deployment
type MilvusMode string

Expand Down
13 changes: 13 additions & 0 deletions apis/milvus.io/v1beta1/milvus_types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,3 +216,16 @@ func TestGetMilvusVersionByGlobalImage(t *testing.T) {
_, err = m.Spec.GetMilvusVersionByImage()
assert.Error(t, err)
}

func TestGetPersistenceConfig(t *testing.T) {
m := Milvus{}
m.Spec.Dep.MsgStreamType = MsgStreamTypePulsar
assert.Nil(t, m.Spec.GetPersistenceConfig())

m.Spec.Dep.MsgStreamType = MsgStreamTypeRocksMQ
m.Spec.Dep.NatsMQ.Persistence.Enabled = true
assert.Same(t, &m.Spec.Dep.RocksMQ.Persistence, m.Spec.GetPersistenceConfig())

m.Spec.Dep.MsgStreamType = MsgStreamTypeNatsMQ
assert.Same(t, &m.Spec.Dep.NatsMQ.Persistence, m.Spec.GetPersistenceConfig())
}
33 changes: 17 additions & 16 deletions apis/milvus.io/v1beta1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit cca07a7

Please sign in to comment.