You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by ha...@apache.org on 2021/05/07 03:10:33 UTC
[skywalking-banyandb] branch main updated: Setup basic models and
document them
This is an automated email from the ASF dual-hosted git repository.
hanahmily pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/skywalking-banyandb.git
The following commit(s) were added to refs/heads/main by this push:
new 98b879f Setup basic models and document them
98b879f is described below
commit 98b879f9184ad79469e529b30c6195ebae48a74a
Author: Gao Hongtao <ha...@gmail.com>
AuthorDate: Fri May 7 11:03:42 2021 +0800
Setup basic models and document them
Signed-off-by: Gao Hongtao <ha...@gmail.com>
---
api/common/kind_version.go | 28 ++
banyand/index/index.go => api/data/trace.go | 42 +--
banyand/index/index.go => api/event/discovery.go | 43 +--
api/fbs/Makefile | 22 ++
banyand/index/index.go => api/fbs/v1/database.fbs | 52 ++--
api/fbs/v1/database_generated.go | 290 +++++++++++++++++++++
api/fbs/v1/trace.fbs | 20 ++
.../index.go => api/fbs/v1/trace_generated.go | 47 ++--
banyand/{index/index.go => discovery/discovery.go} | 42 +--
banyand/doc.go | 52 ++++
banyand/executor/executor.go | 69 -----
banyand/index/index.go | 41 +--
banyand/internal/bus/bus.go | 4 +
banyand/internal/cmd/standalone.go | 59 +++--
banyand/liaison/grpc/grpc.go | 74 ++++++
banyand/{index/index.go => liaison/liaison.go} | 43 +--
banyand/{index/index.go => query/query.go} | 41 +--
banyand/{storage/pipeline.go => queue/local.go} | 27 +-
banyand/{index/index.go => queue/queue.go} | 42 +--
banyand/shard/shard.go | 67 -----
banyand/{series/series.go => storage/database.go} | 37 +--
banyand/storage/query.go | 87 -------
banyand/{index/index.go => storage/storage.go} | 42 +--
go.mod | 3 +-
go.sum | 47 +++-
pkg/logger/setting_test.go | 91 -------
scripts/ci/instal_fb.sh | 46 ++++
27 files changed, 760 insertions(+), 698 deletions(-)
diff --git a/api/common/kind_version.go b/api/common/kind_version.go
new file mode 100644
index 0000000..3da5374
--- /dev/null
+++ b/api/common/kind_version.go
@@ -0,0 +1,28 @@
+// Licensed to Apache Software Foundation (ASF) under one or more contributor
+// license agreements. See the NOTICE file distributed with
+// this work for additional information regarding copyright
+// ownership. Apache Software Foundation (ASF) licenses this file to you under
+// the Apache License, Version 2.0 (the "License"); you may
+// not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package common
+
+// KindVersion contains elements which identify the API uniquely
+type KindVersion struct {
+ Version string
+ Kind string
+}
+
+func (s *KindVersion) String() string {
+ return s.Version + ":" + s.Kind
+}
diff --git a/banyand/index/index.go b/api/data/trace.go
similarity index 50%
copy from banyand/index/index.go
copy to api/data/trace.go
index 496e145..a86ffbd 100644
--- a/banyand/index/index.go
+++ b/api/data/trace.go
@@ -15,44 +15,20 @@
// specific language governing permissions and limitations
// under the License.
-package index
+package trace
import (
- "github.com/apache/skywalking-banyandb/banyand/internal/bus"
- "github.com/apache/skywalking-banyandb/banyand/storage"
- "github.com/apache/skywalking-banyandb/pkg/logger"
- "github.com/apache/skywalking-banyandb/pkg/run"
+ "github.com/apache/skywalking-banyandb/api/common"
+ v1 "github.com/apache/skywalking-banyandb/api/fbs/v1"
)
-const name = "index"
+var TraceKindVersion = common.KindVersion{Version: "v1", Kind: "data-trace"}
-var (
- _ bus.MessageListener = (*Index)(nil)
- _ run.PreRunner = (*Index)(nil)
- _ storage.DataSubscriber = (*Index)(nil)
-)
-
-type Index struct {
- log *logger.Logger
-}
-
-func (s *Index) ComponentName() string {
- return name
-}
-
-func (s *Index) Sub(subscriber bus.Subscriber) error {
- return subscriber.Subscribe(storage.TraceIndex, s)
-}
-
-func (s Index) Name() string {
- return name
-}
-
-func (s Index) PreRun() error {
- s.log = logger.GetLogger(name)
- return nil
+type Trace struct {
+ common.KindVersion
+ PayLoad v1.Trace
}
-func (s Index) Rev(message bus.Message) {
- s.log.Info("rev", logger.Any("msg", message.Data()))
+func NewTrace() *Trace {
+ return &Trace{KindVersion: TraceKindVersion}
}
diff --git a/banyand/index/index.go b/api/event/discovery.go
similarity index 51%
copy from banyand/index/index.go
copy to api/event/discovery.go
index 496e145..6916c65 100644
--- a/banyand/index/index.go
+++ b/api/event/discovery.go
@@ -15,44 +15,25 @@
// specific language governing permissions and limitations
// under the License.
-package index
+package event
import (
- "github.com/apache/skywalking-banyandb/banyand/internal/bus"
- "github.com/apache/skywalking-banyandb/banyand/storage"
- "github.com/apache/skywalking-banyandb/pkg/logger"
- "github.com/apache/skywalking-banyandb/pkg/run"
+ "github.com/apache/skywalking-banyandb/api/common"
+ v1 "github.com/apache/skywalking-banyandb/api/fbs/v1"
)
-const name = "index"
-
var (
- _ bus.MessageListener = (*Index)(nil)
- _ run.PreRunner = (*Index)(nil)
- _ storage.DataSubscriber = (*Index)(nil)
+ ShardEventKindVersion = common.KindVersion{
+ Version: "v1",
+ Kind: "event-shard",
+ }
)
-type Index struct {
- log *logger.Logger
-}
-
-func (s *Index) ComponentName() string {
- return name
-}
-
-func (s *Index) Sub(subscriber bus.Subscriber) error {
- return subscriber.Subscribe(storage.TraceIndex, s)
-}
-
-func (s Index) Name() string {
- return name
-}
-
-func (s Index) PreRun() error {
- s.log = logger.GetLogger(name)
- return nil
+type Shard struct {
+ common.KindVersion
+ Payload v1.ShardEvent
}
-func (s Index) Rev(message bus.Message) {
- s.log.Info("rev", logger.Any("msg", message.Data()))
+func NewShard() *Shard {
+ return &Shard{KindVersion: ShardEventKindVersion}
}
diff --git a/api/fbs/Makefile b/api/fbs/Makefile
new file mode 100644
index 0000000..86af690
--- /dev/null
+++ b/api/fbs/Makefile
@@ -0,0 +1,22 @@
+# Licensed to Apache Software Foundation (ASF) under one or more contributor
+# license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright
+# ownership. Apache Software Foundation (ASF) licenses this file to you under
+# the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+
+VERSION := v1
+
+build:
+ flatc --go --gen-onefile --go-namespace $(VERSION) -o $(VERSION) $(VERSION)/*.fbs
diff --git a/banyand/index/index.go b/api/fbs/v1/database.fbs
similarity index 50%
copy from banyand/index/index.go
copy to api/fbs/v1/database.fbs
index 496e145..d9d98cc 100644
--- a/banyand/index/index.go
+++ b/api/fbs/v1/database.fbs
@@ -15,44 +15,30 @@
// specific language governing permissions and limitations
// under the License.
-package index
+namespace database;
-import (
- "github.com/apache/skywalking-banyandb/banyand/internal/bus"
- "github.com/apache/skywalking-banyandb/banyand/storage"
- "github.com/apache/skywalking-banyandb/pkg/logger"
- "github.com/apache/skywalking-banyandb/pkg/run"
-)
-
-const name = "index"
-
-var (
- _ bus.MessageListener = (*Index)(nil)
- _ run.PreRunner = (*Index)(nil)
- _ storage.DataSubscriber = (*Index)(nil)
-)
-
-type Index struct {
- log *logger.Logger
+table Node {
+ id:string;
+ addr:string;
+ update_time:int64;
+ create_time:int64;
}
-func (s *Index) ComponentName() string {
- return name
+table Shard {
+ id:int64;
+ node:Node;
+ update_time:int64;
+ create_time:int64;
}
-func (s *Index) Sub(subscriber bus.Subscriber) error {
- return subscriber.Subscribe(storage.TraceIndex, s)
-}
+enum Aciton:byte { Put = 0, Delete = 1 }
-func (s Index) Name() string {
- return name
+table ShardEvent {
+ shard:Shard;
+ action:Aciton;
+ time:int64;
}
-func (s Index) PreRun() error {
- s.log = logger.GetLogger(name)
- return nil
-}
-
-func (s Index) Rev(message bus.Message) {
- s.log.Info("rev", logger.Any("msg", message.Data()))
-}
+root_type Shard;
+root_type Node;
+root_type ShardEvent;
diff --git a/api/fbs/v1/database_generated.go b/api/fbs/v1/database_generated.go
new file mode 100644
index 0000000..99c57bc
--- /dev/null
+++ b/api/fbs/v1/database_generated.go
@@ -0,0 +1,290 @@
+//
+// Licensed to Apache Software Foundation (ASF) under one or more contributor
+// license agreements. See the NOTICE file distributed with
+// this work for additional information regarding copyright
+// ownership. Apache Software Foundation (ASF) licenses this file to you under
+// the Apache License, Version 2.0 (the "License"); you may
+// not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+// Code generated by the FlatBuffers compiler. DO NOT EDIT.
+
+package v1
+
+import (
+ "strconv"
+
+ flatbuffers "github.com/google/flatbuffers/go"
+)
+
+type Aciton int8
+
+const (
+ AcitonPut Aciton = 0
+ AcitonDelete Aciton = 1
+)
+
+var EnumNamesAciton = map[Aciton]string{
+ AcitonPut: "Put",
+ AcitonDelete: "Delete",
+}
+
+var EnumValuesAciton = map[string]Aciton{
+ "Put": AcitonPut,
+ "Delete": AcitonDelete,
+}
+
+func (v Aciton) String() string {
+ if s, ok := EnumNamesAciton[v]; ok {
+ return s
+ }
+ return "Aciton(" + strconv.FormatInt(int64(v), 10) + ")"
+}
+
+type Node struct {
+ _tab flatbuffers.Table
+}
+
+func GetRootAsNode(buf []byte, offset flatbuffers.UOffsetT) *Node {
+ n := flatbuffers.GetUOffsetT(buf[offset:])
+ x := &Node{}
+ x.Init(buf, n+offset)
+ return x
+}
+
+func (rcv *Node) Init(buf []byte, i flatbuffers.UOffsetT) {
+ rcv._tab.Bytes = buf
+ rcv._tab.Pos = i
+}
+
+func (rcv *Node) Table() flatbuffers.Table {
+ return rcv._tab
+}
+
+func (rcv *Node) Id() []byte {
+ o := flatbuffers.UOffsetT(rcv._tab.Offset(4))
+ if o != 0 {
+ return rcv._tab.ByteVector(o + rcv._tab.Pos)
+ }
+ return nil
+}
+
+func (rcv *Node) Addr() []byte {
+ o := flatbuffers.UOffsetT(rcv._tab.Offset(6))
+ if o != 0 {
+ return rcv._tab.ByteVector(o + rcv._tab.Pos)
+ }
+ return nil
+}
+
+func (rcv *Node) UpdateTime() int64 {
+ o := flatbuffers.UOffsetT(rcv._tab.Offset(8))
+ if o != 0 {
+ return rcv._tab.GetInt64(o + rcv._tab.Pos)
+ }
+ return 0
+}
+
+func (rcv *Node) MutateUpdateTime(n int64) bool {
+ return rcv._tab.MutateInt64Slot(8, n)
+}
+
+func (rcv *Node) CreateTime() int64 {
+ o := flatbuffers.UOffsetT(rcv._tab.Offset(10))
+ if o != 0 {
+ return rcv._tab.GetInt64(o + rcv._tab.Pos)
+ }
+ return 0
+}
+
+func (rcv *Node) MutateCreateTime(n int64) bool {
+ return rcv._tab.MutateInt64Slot(10, n)
+}
+
+func NodeStart(builder *flatbuffers.Builder) {
+ builder.StartObject(4)
+}
+func NodeAddId(builder *flatbuffers.Builder, id flatbuffers.UOffsetT) {
+ builder.PrependUOffsetTSlot(0, flatbuffers.UOffsetT(id), 0)
+}
+func NodeAddAddr(builder *flatbuffers.Builder, addr flatbuffers.UOffsetT) {
+ builder.PrependUOffsetTSlot(1, flatbuffers.UOffsetT(addr), 0)
+}
+func NodeAddUpdateTime(builder *flatbuffers.Builder, updateTime int64) {
+ builder.PrependInt64Slot(2, updateTime, 0)
+}
+func NodeAddCreateTime(builder *flatbuffers.Builder, createTime int64) {
+ builder.PrependInt64Slot(3, createTime, 0)
+}
+func NodeEnd(builder *flatbuffers.Builder) flatbuffers.UOffsetT {
+ return builder.EndObject()
+}
+
+type Shard struct {
+ _tab flatbuffers.Table
+}
+
+func GetRootAsShard(buf []byte, offset flatbuffers.UOffsetT) *Shard {
+ n := flatbuffers.GetUOffsetT(buf[offset:])
+ x := &Shard{}
+ x.Init(buf, n+offset)
+ return x
+}
+
+func (rcv *Shard) Init(buf []byte, i flatbuffers.UOffsetT) {
+ rcv._tab.Bytes = buf
+ rcv._tab.Pos = i
+}
+
+func (rcv *Shard) Table() flatbuffers.Table {
+ return rcv._tab
+}
+
+func (rcv *Shard) Id() int64 {
+ o := flatbuffers.UOffsetT(rcv._tab.Offset(4))
+ if o != 0 {
+ return rcv._tab.GetInt64(o + rcv._tab.Pos)
+ }
+ return 0
+}
+
+func (rcv *Shard) MutateId(n int64) bool {
+ return rcv._tab.MutateInt64Slot(4, n)
+}
+
+func (rcv *Shard) Node(obj *Node) *Node {
+ o := flatbuffers.UOffsetT(rcv._tab.Offset(6))
+ if o != 0 {
+ x := rcv._tab.Indirect(o + rcv._tab.Pos)
+ if obj == nil {
+ obj = new(Node)
+ }
+ obj.Init(rcv._tab.Bytes, x)
+ return obj
+ }
+ return nil
+}
+
+func (rcv *Shard) UpdateTime() int64 {
+ o := flatbuffers.UOffsetT(rcv._tab.Offset(8))
+ if o != 0 {
+ return rcv._tab.GetInt64(o + rcv._tab.Pos)
+ }
+ return 0
+}
+
+func (rcv *Shard) MutateUpdateTime(n int64) bool {
+ return rcv._tab.MutateInt64Slot(8, n)
+}
+
+func (rcv *Shard) CreateTime() int64 {
+ o := flatbuffers.UOffsetT(rcv._tab.Offset(10))
+ if o != 0 {
+ return rcv._tab.GetInt64(o + rcv._tab.Pos)
+ }
+ return 0
+}
+
+func (rcv *Shard) MutateCreateTime(n int64) bool {
+ return rcv._tab.MutateInt64Slot(10, n)
+}
+
+func ShardStart(builder *flatbuffers.Builder) {
+ builder.StartObject(4)
+}
+func ShardAddId(builder *flatbuffers.Builder, id int64) {
+ builder.PrependInt64Slot(0, id, 0)
+}
+func ShardAddNode(builder *flatbuffers.Builder, node flatbuffers.UOffsetT) {
+ builder.PrependUOffsetTSlot(1, flatbuffers.UOffsetT(node), 0)
+}
+func ShardAddUpdateTime(builder *flatbuffers.Builder, updateTime int64) {
+ builder.PrependInt64Slot(2, updateTime, 0)
+}
+func ShardAddCreateTime(builder *flatbuffers.Builder, createTime int64) {
+ builder.PrependInt64Slot(3, createTime, 0)
+}
+func ShardEnd(builder *flatbuffers.Builder) flatbuffers.UOffsetT {
+ return builder.EndObject()
+}
+
+type ShardEvent struct {
+ _tab flatbuffers.Table
+}
+
+func GetRootAsShardEvent(buf []byte, offset flatbuffers.UOffsetT) *ShardEvent {
+ n := flatbuffers.GetUOffsetT(buf[offset:])
+ x := &ShardEvent{}
+ x.Init(buf, n+offset)
+ return x
+}
+
+func (rcv *ShardEvent) Init(buf []byte, i flatbuffers.UOffsetT) {
+ rcv._tab.Bytes = buf
+ rcv._tab.Pos = i
+}
+
+func (rcv *ShardEvent) Table() flatbuffers.Table {
+ return rcv._tab
+}
+
+func (rcv *ShardEvent) Shard(obj *Shard) *Shard {
+ o := flatbuffers.UOffsetT(rcv._tab.Offset(4))
+ if o != 0 {
+ x := rcv._tab.Indirect(o + rcv._tab.Pos)
+ if obj == nil {
+ obj = new(Shard)
+ }
+ obj.Init(rcv._tab.Bytes, x)
+ return obj
+ }
+ return nil
+}
+
+func (rcv *ShardEvent) Action() Aciton {
+ o := flatbuffers.UOffsetT(rcv._tab.Offset(6))
+ if o != 0 {
+ return Aciton(rcv._tab.GetInt8(o + rcv._tab.Pos))
+ }
+ return 0
+}
+
+func (rcv *ShardEvent) MutateAction(n Aciton) bool {
+ return rcv._tab.MutateInt8Slot(6, int8(n))
+}
+
+func (rcv *ShardEvent) Time() int64 {
+ o := flatbuffers.UOffsetT(rcv._tab.Offset(8))
+ if o != 0 {
+ return rcv._tab.GetInt64(o + rcv._tab.Pos)
+ }
+ return 0
+}
+
+func (rcv *ShardEvent) MutateTime(n int64) bool {
+ return rcv._tab.MutateInt64Slot(8, n)
+}
+
+func ShardEventStart(builder *flatbuffers.Builder) {
+ builder.StartObject(3)
+}
+func ShardEventAddShard(builder *flatbuffers.Builder, shard flatbuffers.UOffsetT) {
+ builder.PrependUOffsetTSlot(0, flatbuffers.UOffsetT(shard), 0)
+}
+func ShardEventAddAction(builder *flatbuffers.Builder, action Aciton) {
+ builder.PrependInt8Slot(1, int8(action), 0)
+}
+func ShardEventAddTime(builder *flatbuffers.Builder, time int64) {
+ builder.PrependInt64Slot(2, time, 0)
+}
+func ShardEventEnd(builder *flatbuffers.Builder) flatbuffers.UOffsetT {
+ return builder.EndObject()
+}
diff --git a/api/fbs/v1/trace.fbs b/api/fbs/v1/trace.fbs
new file mode 100644
index 0000000..eaef6a0
--- /dev/null
+++ b/api/fbs/v1/trace.fbs
@@ -0,0 +1,20 @@
+// Licensed to Apache Software Foundation (ASF) under one or more contributor
+// license agreements. See the NOTICE file distributed with
+// this work for additional information regarding copyright
+// ownership. Apache Software Foundation (ASF) licenses this file to you under
+// the Apache License, Version 2.0 (the "License"); you may
+// not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+table Trace {
+
+}
\ No newline at end of file
diff --git a/banyand/index/index.go b/api/fbs/v1/trace_generated.go
similarity index 51%
copy from banyand/index/index.go
copy to api/fbs/v1/trace_generated.go
index 496e145..eb43af7 100644
--- a/banyand/index/index.go
+++ b/api/fbs/v1/trace_generated.go
@@ -1,3 +1,4 @@
+//
// Licensed to Apache Software Foundation (ASF) under one or more contributor
// license agreements. See the NOTICE file distributed with
// this work for additional information regarding copyright
@@ -14,45 +15,37 @@
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
+// Code generated by the FlatBuffers compiler. DO NOT EDIT.
-package index
+package v1
import (
- "github.com/apache/skywalking-banyandb/banyand/internal/bus"
- "github.com/apache/skywalking-banyandb/banyand/storage"
- "github.com/apache/skywalking-banyandb/pkg/logger"
- "github.com/apache/skywalking-banyandb/pkg/run"
+ flatbuffers "github.com/google/flatbuffers/go"
)
-const name = "index"
-
-var (
- _ bus.MessageListener = (*Index)(nil)
- _ run.PreRunner = (*Index)(nil)
- _ storage.DataSubscriber = (*Index)(nil)
-)
-
-type Index struct {
- log *logger.Logger
+type Trace struct {
+ _tab flatbuffers.Table
}
-func (s *Index) ComponentName() string {
- return name
+func GetRootAsTrace(buf []byte, offset flatbuffers.UOffsetT) *Trace {
+ n := flatbuffers.GetUOffsetT(buf[offset:])
+ x := &Trace{}
+ x.Init(buf, n+offset)
+ return x
}
-func (s *Index) Sub(subscriber bus.Subscriber) error {
- return subscriber.Subscribe(storage.TraceIndex, s)
+func (rcv *Trace) Init(buf []byte, i flatbuffers.UOffsetT) {
+ rcv._tab.Bytes = buf
+ rcv._tab.Pos = i
}
-func (s Index) Name() string {
- return name
+func (rcv *Trace) Table() flatbuffers.Table {
+ return rcv._tab
}
-func (s Index) PreRun() error {
- s.log = logger.GetLogger(name)
- return nil
+func TraceStart(builder *flatbuffers.Builder) {
+ builder.StartObject(0)
}
-
-func (s Index) Rev(message bus.Message) {
- s.log.Info("rev", logger.Any("msg", message.Data()))
+func TraceEnd(builder *flatbuffers.Builder) flatbuffers.UOffsetT {
+ return builder.EndObject()
}
diff --git a/banyand/index/index.go b/banyand/discovery/discovery.go
similarity index 57%
copy from banyand/index/index.go
copy to banyand/discovery/discovery.go
index 496e145..9e7197c 100644
--- a/banyand/index/index.go
+++ b/banyand/discovery/discovery.go
@@ -15,44 +15,22 @@
// specific language governing permissions and limitations
// under the License.
-package index
+package discovery
import (
+ "context"
+
"github.com/apache/skywalking-banyandb/banyand/internal/bus"
- "github.com/apache/skywalking-banyandb/banyand/storage"
- "github.com/apache/skywalking-banyandb/pkg/logger"
"github.com/apache/skywalking-banyandb/pkg/run"
)
-const name = "index"
-
-var (
- _ bus.MessageListener = (*Index)(nil)
- _ run.PreRunner = (*Index)(nil)
- _ storage.DataSubscriber = (*Index)(nil)
-)
-
-type Index struct {
- log *logger.Logger
-}
-
-func (s *Index) ComponentName() string {
- return name
-}
-
-func (s *Index) Sub(subscriber bus.Subscriber) error {
- return subscriber.Subscribe(storage.TraceIndex, s)
-}
-
-func (s Index) Name() string {
- return name
-}
-
-func (s Index) PreRun() error {
- s.log = logger.GetLogger(name)
- return nil
+type ServiceRepo interface {
+ run.Config
+ run.Service
+ bus.Subscriber
+ bus.Publisher
}
-func (s Index) Rev(message bus.Message) {
- s.log.Info("rev", logger.Any("msg", message.Data()))
+func NewServiceRepo(ctx context.Context) (ServiceRepo, error) {
+ return nil, nil
}
diff --git a/banyand/doc.go b/banyand/doc.go
new file mode 100644
index 0000000..94f961d
--- /dev/null
+++ b/banyand/doc.go
@@ -0,0 +1,52 @@
+// Licensed to Apache Software Foundation (ASF) under one or more contributor
+// license agreements. See the NOTICE file distributed with
+// this work for additional information regarding copyright
+// ownership. Apache Software Foundation (ASF) licenses this file to you under
+// the Apache License, Version 2.0 (the "License"); you may
+// not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package banyand
+
+/*
+ ┌────────────────────────────────────────────────────┐
+ │ Storage │
+ ┌────────────────┐ │ │
+ │ │ │ ┌────────────────┐ ┌────────────────┐ │
+ │ Discovery │◄────────────────────────────┤ │ │ │ │ │
+ │ │ │ ┌─►│ Series ├────────►│ │ │
+ └───────┬────────┘ │ │ │ │ │ │ │
+ │ │ │ │ │ │ │ │
+ │ │ │ └────────────────┘ │ │ │
+ │ │ │ ▲ │ │ │
+ │ │ │ │ │ │ │
+ ▼ │ │ │ │ │ │
+┌──────────────────────────────────────────────────────────┐ │ │ │ │ │ │
+│ │ │ │ │ │ │ │
+│ ┌────────────────┐ │ │ │ ┌──────┴─────────┐ │ │ │
+│ │ │ ┌───────────────────────────┐ │ │ │ │ │ │ │ │
+│ │ Endpoint ├─────►│ Remote / Local Queue ├─┼──────┼───┼──┤ Query │ │ KV Engine │ │
+│ │ │ └───────────────────────────┘ │ │ │ │ │ │ │ │
+│ └────────────────┘ │ │ │ │ │ │ │ │
+│ Liaison │ │ │ └──────┬─────────┘ │ │ │
+│ │ │ │ │ │ │ │
+└──────────────────────────────────────────────────────────┘ │ │ │ │ │ │
+ │ │ ▼ │ │ │
+ │ │ ┌────────────────┐ │ │ │
+ │ │ │ │ │ │ │
+ │ │ │ Index │ │ │ │
+ │ └─►│ ├────────►│ │ │
+ │ │ │ │ │ │
+ │ └────────────────┘ └────────────────┘ │
+ │ │
+ └────────────────────────────────────────────────────┘
+*/
diff --git a/banyand/executor/executor.go b/banyand/executor/executor.go
deleted file mode 100644
index bedc415..0000000
--- a/banyand/executor/executor.go
+++ /dev/null
@@ -1,69 +0,0 @@
-// Licensed to Apache Software Foundation (ASF) under one or more contributor
-// license agreements. See the NOTICE file distributed with
-// this work for additional information regarding copyright
-// ownership. Apache Software Foundation (ASF) licenses this file to you under
-// the Apache License, Version 2.0 (the "License"); you may
-// not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-
-package executor
-
-import (
- "time"
-
- "github.com/apache/skywalking-banyandb/banyand/internal/bus"
- "github.com/apache/skywalking-banyandb/banyand/storage"
- "github.com/apache/skywalking-banyandb/pkg/logger"
- "github.com/apache/skywalking-banyandb/pkg/run"
-)
-
-const name = "executor"
-
-var (
- _ bus.MessageListener = (*Executor)(nil)
- _ run.PreRunner = (*Executor)(nil)
- _ storage.DataSubscriber = (*Executor)(nil)
- _ storage.DataPublisher = (*Executor)(nil)
-)
-
-type Executor struct {
- log *logger.Logger
- publisher bus.Publisher
-}
-
-func (s *Executor) Pub(publisher bus.Publisher) error {
- s.publisher = publisher
- return nil
-}
-
-func (s *Executor) ComponentName() string {
- return name
-}
-
-func (s *Executor) Sub(subscriber bus.Subscriber) error {
- return subscriber.Subscribe(storage.TraceRaw, s)
-}
-
-func (s *Executor) Name() string {
- return name
-}
-
-func (s *Executor) PreRun() error {
- s.log = logger.GetLogger(name)
- return nil
-}
-
-func (s Executor) Rev(message bus.Message) {
- s.log.Info("rev", logger.Any("msg", message.Data()))
- _ = s.publisher.Publish(storage.TraceIndex, bus.NewMessage(bus.MessageID(time.Now().UnixNano()), "index message"))
- _ = s.publisher.Publish(storage.TraceData, bus.NewMessage(bus.MessageID(time.Now().UnixNano()), "data message"))
-}
diff --git a/banyand/index/index.go b/banyand/index/index.go
index 496e145..717f71e 100644
--- a/banyand/index/index.go
+++ b/banyand/index/index.go
@@ -18,41 +18,18 @@
package index
import (
- "github.com/apache/skywalking-banyandb/banyand/internal/bus"
- "github.com/apache/skywalking-banyandb/banyand/storage"
- "github.com/apache/skywalking-banyandb/pkg/logger"
- "github.com/apache/skywalking-banyandb/pkg/run"
-)
-
-const name = "index"
+ "context"
-var (
- _ bus.MessageListener = (*Index)(nil)
- _ run.PreRunner = (*Index)(nil)
- _ storage.DataSubscriber = (*Index)(nil)
+ "github.com/apache/skywalking-banyandb/banyand/discovery"
+ "github.com/apache/skywalking-banyandb/banyand/queue"
+ "github.com/apache/skywalking-banyandb/pkg/run"
)
-type Index struct {
- log *logger.Logger
-}
-
-func (s *Index) ComponentName() string {
- return name
-}
-
-func (s *Index) Sub(subscriber bus.Subscriber) error {
- return subscriber.Subscribe(storage.TraceIndex, s)
-}
-
-func (s Index) Name() string {
- return name
-}
-
-func (s Index) PreRun() error {
- s.log = logger.GetLogger(name)
- return nil
+type Builder interface {
+ run.Config
+ run.PreRunner
}
-func (s Index) Rev(message bus.Message) {
- s.log.Info("rev", logger.Any("msg", message.Data()))
+func NewBuilder(ctx context.Context, repo discovery.ServiceRepo, pipeline queue.Pipeline) (Builder, error) {
+ return nil, nil
}
diff --git a/banyand/internal/bus/bus.go b/banyand/internal/bus/bus.go
index 05f2065..4dac157 100644
--- a/banyand/internal/bus/bus.go
+++ b/banyand/internal/bus/bus.go
@@ -32,6 +32,10 @@ type Message struct {
payload Payload
}
+func (m Message) ID() MessageID {
+ return m.id
+}
+
func (m Message) Data() interface{} {
return m.payload
}
diff --git a/banyand/internal/cmd/standalone.go b/banyand/internal/cmd/standalone.go
index 60653cc..5f3ac30 100644
--- a/banyand/internal/cmd/standalone.go
+++ b/banyand/internal/cmd/standalone.go
@@ -18,15 +18,17 @@
package cmd
import (
+ "context"
"os"
"github.com/spf13/cobra"
"go.uber.org/zap"
- executor2 "github.com/apache/skywalking-banyandb/banyand/executor"
- index2 "github.com/apache/skywalking-banyandb/banyand/index"
- series2 "github.com/apache/skywalking-banyandb/banyand/series"
- shard2 "github.com/apache/skywalking-banyandb/banyand/shard"
+ "github.com/apache/skywalking-banyandb/banyand/discovery"
+ "github.com/apache/skywalking-banyandb/banyand/index"
+ "github.com/apache/skywalking-banyandb/banyand/liaison"
+ "github.com/apache/skywalking-banyandb/banyand/query"
+ "github.com/apache/skywalking-banyandb/banyand/queue"
"github.com/apache/skywalking-banyandb/banyand/storage"
"github.com/apache/skywalking-banyandb/pkg/config"
"github.com/apache/skywalking-banyandb/pkg/logger"
@@ -41,28 +43,41 @@ var (
func newStandaloneCmd() *cobra.Command {
_ = logger.Bootstrap()
- engine := new(storage.Pipeline)
- shard := new(shard2.Shard)
- executor := new(executor2.Executor)
- index := new(index2.Index)
- series := new(series2.Series)
-
- // Register the storage engine components.
- engine.Register(
- shard,
- executor,
- index,
- series,
- )
+ l := logger.GetLogger("bootstrap")
+ ctx := context.Background()
+ repo, err := discovery.NewServiceRepo(ctx)
+ if err != nil {
+ l.Fatal("failed to initiate service repository", logger.Error(err))
+ }
+ pipeline, err := queue.NewPipeline(ctx, repo)
+ if err != nil {
+ l.Fatal("failed to initiate data pipeline", logger.Error(err))
+ }
+ db, err := storage.NewDB(ctx, repo)
+ if err != nil {
+ l.Fatal("failed to initiate database", logger.Error(err))
+ }
+ idxBuilder, err := index.NewBuilder(ctx, repo, pipeline)
+ if err != nil {
+ l.Fatal("failed to initiate index builder", logger.Error(err))
+ }
+ composer, err := query.NewPlanComposer(ctx, repo)
+ if err != nil {
+ l.Fatal("failed to initiate execution plan composer", logger.Error(err))
+ }
+ tcp, err := liaison.NewEndpoint(ctx, pipeline)
+ if err != nil {
+ l.Fatal("failed to initiate Endpoint transport layer", logger.Error(err))
+ }
// Register the run Group units.
g.Register(
new(signal.Handler),
- engine,
- shard,
- executor,
- index,
- series,
+ repo,
+ db,
+ idxBuilder,
+ composer,
+ tcp,
)
logging := logger.Logging{}
standaloneCmd := &cobra.Command{
diff --git a/banyand/liaison/grpc/grpc.go b/banyand/liaison/grpc/grpc.go
new file mode 100644
index 0000000..f19dce3
--- /dev/null
+++ b/banyand/liaison/grpc/grpc.go
@@ -0,0 +1,74 @@
+// Licensed to Apache Software Foundation (ASF) under one or more contributor
+// license agreements. See the NOTICE file distributed with
+// this work for additional information regarding copyright
+// ownership. Apache Software Foundation (ASF) licenses this file to you under
+// the Apache License, Version 2.0 (the "License"); you may
+// not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package grpc
+
+import (
+ "context"
+ "net"
+
+ flatbuffers "github.com/google/flatbuffers/go"
+ grpclib "google.golang.org/grpc"
+ "google.golang.org/grpc/encoding"
+
+ "github.com/apache/skywalking-banyandb/banyand/queue"
+ "github.com/apache/skywalking-banyandb/pkg/logger"
+ "github.com/apache/skywalking-banyandb/pkg/run"
+)
+
+type Server struct {
+ addr string
+ log *logger.Logger
+ ser *grpclib.Server
+ pipeline queue.Pipeline
+}
+
+func NewServer(ctx context.Context, pipeline queue.Pipeline) *Server {
+ return &Server{pipeline: pipeline}
+}
+
+func (s *Server) Name() string {
+ return "grpc"
+}
+
+func (s *Server) FlagSet() *run.FlagSet {
+ fs := run.NewFlagSet("grpc")
+ fs.StringVarP(&s.addr, "addr", "", ":17912", "the address of banyand listens")
+ return fs
+}
+
+func (s *Server) Validate() error {
+ return nil
+}
+
+func (s *Server) Serve() error {
+ s.log = logger.GetLogger("grpc")
+ lis, err := net.Listen("tcp", s.addr)
+ if err != nil {
+ s.log.Fatal("Failed to listen", logger.Error(err))
+ }
+
+ encoding.RegisterCodec(flatbuffers.FlatbuffersCodec{})
+ s.ser = grpclib.NewServer()
+
+ return s.ser.Serve(lis)
+}
+
+func (s *Server) GracefulStop() {
+ s.log.Info("stopping")
+ s.ser.GracefulStop()
+}
diff --git a/banyand/index/index.go b/banyand/liaison/liaison.go
similarity index 53%
copy from banyand/index/index.go
copy to banyand/liaison/liaison.go
index 496e145..e13a83f 100644
--- a/banyand/index/index.go
+++ b/banyand/liaison/liaison.go
@@ -15,44 +15,21 @@
// specific language governing permissions and limitations
// under the License.
-package index
+package liaison
import (
- "github.com/apache/skywalking-banyandb/banyand/internal/bus"
- "github.com/apache/skywalking-banyandb/banyand/storage"
- "github.com/apache/skywalking-banyandb/pkg/logger"
- "github.com/apache/skywalking-banyandb/pkg/run"
-)
-
-const name = "index"
+ "context"
-var (
- _ bus.MessageListener = (*Index)(nil)
- _ run.PreRunner = (*Index)(nil)
- _ storage.DataSubscriber = (*Index)(nil)
+ "github.com/apache/skywalking-banyandb/banyand/liaison/grpc"
+ "github.com/apache/skywalking-banyandb/banyand/queue"
+ "github.com/apache/skywalking-banyandb/pkg/run"
)
-type Index struct {
- log *logger.Logger
-}
-
-func (s *Index) ComponentName() string {
- return name
-}
-
-func (s *Index) Sub(subscriber bus.Subscriber) error {
- return subscriber.Subscribe(storage.TraceIndex, s)
-}
-
-func (s Index) Name() string {
- return name
-}
-
-func (s Index) PreRun() error {
- s.log = logger.GetLogger(name)
- return nil
+type Endpoint interface {
+ run.Config
+ run.Service
}
-func (s Index) Rev(message bus.Message) {
- s.log.Info("rev", logger.Any("msg", message.Data()))
+func NewEndpoint(ctx context.Context, pipeline queue.Pipeline) (Endpoint, error) {
+ return grpc.NewServer(ctx, pipeline), nil
}
diff --git a/banyand/index/index.go b/banyand/query/query.go
similarity index 53%
copy from banyand/index/index.go
copy to banyand/query/query.go
index 496e145..b9a2091 100644
--- a/banyand/index/index.go
+++ b/banyand/query/query.go
@@ -15,44 +15,19 @@
// specific language governing permissions and limitations
// under the License.
-package index
+package query
import (
- "github.com/apache/skywalking-banyandb/banyand/internal/bus"
- "github.com/apache/skywalking-banyandb/banyand/storage"
- "github.com/apache/skywalking-banyandb/pkg/logger"
- "github.com/apache/skywalking-banyandb/pkg/run"
-)
-
-const name = "index"
+ "context"
-var (
- _ bus.MessageListener = (*Index)(nil)
- _ run.PreRunner = (*Index)(nil)
- _ storage.DataSubscriber = (*Index)(nil)
+ "github.com/apache/skywalking-banyandb/banyand/discovery"
+ "github.com/apache/skywalking-banyandb/pkg/run"
)
-type Index struct {
- log *logger.Logger
-}
-
-func (s *Index) ComponentName() string {
- return name
-}
-
-func (s *Index) Sub(subscriber bus.Subscriber) error {
- return subscriber.Subscribe(storage.TraceIndex, s)
-}
-
-func (s Index) Name() string {
- return name
-}
-
-func (s Index) PreRun() error {
- s.log = logger.GetLogger(name)
- return nil
+type PlanComposer interface {
+ run.PreRunner
}
-func (s Index) Rev(message bus.Message) {
- s.log.Info("rev", logger.Any("msg", message.Data()))
+func NewPlanComposer(ctx context.Context, repo discovery.ServiceRepo) (PlanComposer, error) {
+ return nil, nil
}
diff --git a/banyand/storage/pipeline.go b/banyand/queue/local.go
similarity index 81%
rename from banyand/storage/pipeline.go
rename to banyand/queue/local.go
index 494f34f..0e99b90 100644
--- a/banyand/storage/pipeline.go
+++ b/banyand/queue/local.go
@@ -15,23 +15,17 @@
// specific language governing permissions and limitations
// under the License.
-package storage
+package queue
import (
"go.uber.org/multierr"
+ "github.com/apache/skywalking-banyandb/banyand/discovery"
"github.com/apache/skywalking-banyandb/banyand/internal/bus"
"github.com/apache/skywalking-banyandb/pkg/logger"
"github.com/apache/skywalking-banyandb/pkg/run"
)
-const (
- TraceRaw = "trace-raw"
- TraceSharded = "trace-sharded"
- TraceIndex = "trace-index"
- TraceData = "trace-data"
-)
-
const name = "storage-engine"
type Component interface {
@@ -48,34 +42,35 @@ type DataPublisher interface {
Pub(publisher bus.Publisher) error
}
-var _ run.PreRunner = (*Pipeline)(nil)
-var _ run.Config = (*Pipeline)(nil)
+var _ run.PreRunner = (*Local)(nil)
+var _ run.Config = (*Local)(nil)
-type Pipeline struct {
+type Local struct {
logger *logger.Logger
test string
dataBus *bus.Bus
dps []DataPublisher
dss []DataSubscriber
+ repo discovery.ServiceRepo
}
-func (e *Pipeline) FlagSet() *run.FlagSet {
+func (e *Local) FlagSet() *run.FlagSet {
e.logger = logger.GetLogger(name)
fs := run.NewFlagSet("storage")
fs.StringVarP(&e.test, "storage.test", "", "a", "test config")
return fs
}
-func (e *Pipeline) Validate() error {
+func (e *Local) Validate() error {
e.logger.Info("test", logger.String("val", e.test))
return nil
}
-func (e Pipeline) Name() string {
+func (e Local) Name() string {
return name
}
-func (e *Pipeline) PreRun() error {
+func (e *Local) PreRun() error {
var err error
e.dataBus = bus.NewBus()
for _, dp := range e.dps {
@@ -87,7 +82,7 @@ func (e *Pipeline) PreRun() error {
return err
}
-func (e *Pipeline) Register(component ...Component) {
+func (e *Local) Register(component ...Component) {
for _, c := range component {
if ds, ok := c.(DataSubscriber); ok {
e.dss = append(e.dss, ds)
diff --git a/banyand/index/index.go b/banyand/queue/queue.go
similarity index 53%
copy from banyand/index/index.go
copy to banyand/queue/queue.go
index 496e145..43b0ebc 100644
--- a/banyand/index/index.go
+++ b/banyand/queue/queue.go
@@ -15,44 +15,20 @@
// specific language governing permissions and limitations
// under the License.
-package index
+package queue
import (
- "github.com/apache/skywalking-banyandb/banyand/internal/bus"
- "github.com/apache/skywalking-banyandb/banyand/storage"
- "github.com/apache/skywalking-banyandb/pkg/logger"
- "github.com/apache/skywalking-banyandb/pkg/run"
-)
-
-const name = "index"
+ "context"
-var (
- _ bus.MessageListener = (*Index)(nil)
- _ run.PreRunner = (*Index)(nil)
- _ storage.DataSubscriber = (*Index)(nil)
+ "github.com/apache/skywalking-banyandb/banyand/discovery"
+ "github.com/apache/skywalking-banyandb/pkg/run"
)
-type Index struct {
- log *logger.Logger
-}
-
-func (s *Index) ComponentName() string {
- return name
-}
-
-func (s *Index) Sub(subscriber bus.Subscriber) error {
- return subscriber.Subscribe(storage.TraceIndex, s)
-}
-
-func (s Index) Name() string {
- return name
-}
-
-func (s Index) PreRun() error {
- s.log = logger.GetLogger(name)
- return nil
+type Pipeline interface {
+ run.Config
+ run.PreRunner
}
-func (s Index) Rev(message bus.Message) {
- s.log.Info("rev", logger.Any("msg", message.Data()))
+func NewPipeline(ctx context.Context, repo discovery.ServiceRepo) (Pipeline, error) {
+ return &Local{repo: repo}, nil
}
diff --git a/banyand/shard/shard.go b/banyand/shard/shard.go
deleted file mode 100644
index 24c191c..0000000
--- a/banyand/shard/shard.go
+++ /dev/null
@@ -1,67 +0,0 @@
-// Licensed to Apache Software Foundation (ASF) under one or more contributor
-// license agreements. See the NOTICE file distributed with
-// this work for additional information regarding copyright
-// ownership. Apache Software Foundation (ASF) licenses this file to you under
-// the Apache License, Version 2.0 (the "License"); you may
-// not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-
-package shard
-
-import (
- "time"
-
- "github.com/apache/skywalking-banyandb/banyand/internal/bus"
- "github.com/apache/skywalking-banyandb/banyand/storage"
- "github.com/apache/skywalking-banyandb/pkg/logger"
- "github.com/apache/skywalking-banyandb/pkg/run"
-)
-
-var (
- _ bus.MessageListener = (*Shard)(nil)
- _ run.PreRunner = (*Shard)(nil)
- _ storage.DataSubscriber = (*Shard)(nil)
- _ storage.DataPublisher = (*Shard)(nil)
-)
-
-type Shard struct {
- log *logger.Logger
- publisher bus.Publisher
-}
-
-func (s Shard) ComponentName() string {
- return "shard"
-}
-
-func (s *Shard) Pub(publisher bus.Publisher) error {
- s.publisher = publisher
- return nil
-}
-
-func (s *Shard) Sub(subscriber bus.Subscriber) error {
- return subscriber.Subscribe(storage.TraceRaw, s)
-}
-
-func (s *Shard) PreRun() error {
- s.log = logger.GetLogger("shard")
- s.log.Info("pre running")
- return nil
-}
-
-func (s *Shard) Name() string {
- return "shard"
-}
-
-func (s Shard) Rev(message bus.Message) {
- s.log.Info("rev", logger.Any("msg", message.Data()))
- _ = s.publisher.Publish(storage.TraceSharded, bus.NewMessage(bus.MessageID(time.Now().UnixNano()), "sharded message"))
-}
diff --git a/banyand/series/series.go b/banyand/storage/database.go
similarity index 58%
rename from banyand/series/series.go
rename to banyand/storage/database.go
index 850e9b1..7cba5da 100644
--- a/banyand/series/series.go
+++ b/banyand/storage/database.go
@@ -15,44 +15,33 @@
// specific language governing permissions and limitations
// under the License.
-package series
+package storage
import (
+ "github.com/apache/skywalking-banyandb/api/event"
+ "github.com/apache/skywalking-banyandb/banyand/discovery"
"github.com/apache/skywalking-banyandb/banyand/internal/bus"
- "github.com/apache/skywalking-banyandb/banyand/storage"
- "github.com/apache/skywalking-banyandb/pkg/logger"
"github.com/apache/skywalking-banyandb/pkg/run"
)
-const name = "series"
+var _ Database = (*DB)(nil)
-var (
- _ bus.MessageListener = (*Series)(nil)
- _ run.PreRunner = (*Series)(nil)
- _ storage.DataSubscriber = (*Series)(nil)
-)
-
-type Series struct {
- log *logger.Logger
+type DB struct {
+ repo discovery.ServiceRepo
}
-func (s Series) ComponentName() string {
- return name
+func (d *DB) Name() string {
+ return "database"
}
-func (s *Series) Sub(subscriber bus.Subscriber) error {
- return subscriber.Subscribe(storage.TraceData, s)
-}
-
-func (s Series) Name() string {
- return name
+func (d *DB) FlagSet() *run.FlagSet {
+ return nil
}
-func (s *Series) PreRun() error {
- s.log = logger.GetLogger(name)
+func (d *DB) Validate() error {
return nil
}
-func (s Series) Rev(message bus.Message) {
- s.log.Info("rev", logger.Any("msg", message.Data()))
+func (d *DB) PreRun() error {
+ return d.repo.Publish(bus.Topic(event.ShardEventKindVersion.String()), bus.NewMessage(1, event.NewShard()))
}
diff --git a/banyand/storage/query.go b/banyand/storage/query.go
deleted file mode 100644
index 4545869..0000000
--- a/banyand/storage/query.go
+++ /dev/null
@@ -1,87 +0,0 @@
-// Licensed to Apache Software Foundation (ASF) under one or more contributor
-// license agreements. See the NOTICE file distributed with
-// this work for additional information regarding copyright
-// ownership. Apache Software Foundation (ASF) licenses this file to you under
-// the Apache License, Version 2.0 (the "License"); you may
-// not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-
-package storage
-
-import (
- "context"
- "errors"
- "sync"
-
- "github.com/apache/skywalking-banyandb/pkg/run"
-)
-
-var (
- ErrInterrupted = errors.New("the query is interrupted by context")
- ErrNoServiceExist = errors.New("the service does not exist")
- globalRegister SvcRegister
-
- _ run.Unit = (*SvcRegister)(nil)
-)
-
-type Service interface {
- Name() string
- Query(ctx context.Context, param interface{}) (interface{}, error)
-}
-
-type SvcRegister struct {
- mutex sync.RWMutex
- lst map[string]Service
-}
-
-func (r *SvcRegister) Name() string {
- return "service-register"
-}
-
-func (r *SvcRegister) Register(svc ...Service) {
- r.mutex.Lock()
- defer r.mutex.Unlock()
- for _, s := range svc {
- r.lst[s.Name()] = s
- }
-}
-
-type result struct {
- err error
- result interface{}
-}
-
-func InitRegister() *SvcRegister {
- once := sync.Once{}
- once.Do(func() {
- globalRegister = SvcRegister{}
- })
- return &globalRegister
-}
-
-func Async(ctx context.Context, svc string, param interface{}) (interface{}, error) {
- if s, ok := globalRegister.lst[svc]; ok {
- ch := make(chan result)
- go func(ctx context.Context, param interface{}, ch chan result) {
- r, err := s.Query(ctx, param)
- ch <- result{err: err, result: r}
- }(ctx, param, ch)
-
- select {
- case res := <-ch:
- return res.result, res.err
- case <-ctx.Done():
- return nil, ErrInterrupted
- }
- }
- return nil, ErrNoServiceExist
-}
diff --git a/banyand/index/index.go b/banyand/storage/storage.go
similarity index 53%
copy from banyand/index/index.go
copy to banyand/storage/storage.go
index 496e145..c78cde5 100644
--- a/banyand/index/index.go
+++ b/banyand/storage/storage.go
@@ -15,44 +15,20 @@
// specific language governing permissions and limitations
// under the License.
-package index
+package storage
import (
- "github.com/apache/skywalking-banyandb/banyand/internal/bus"
- "github.com/apache/skywalking-banyandb/banyand/storage"
- "github.com/apache/skywalking-banyandb/pkg/logger"
- "github.com/apache/skywalking-banyandb/pkg/run"
-)
-
-const name = "index"
+ "context"
-var (
- _ bus.MessageListener = (*Index)(nil)
- _ run.PreRunner = (*Index)(nil)
- _ storage.DataSubscriber = (*Index)(nil)
+ "github.com/apache/skywalking-banyandb/banyand/discovery"
+ "github.com/apache/skywalking-banyandb/pkg/run"
)
-type Index struct {
- log *logger.Logger
-}
-
-func (s *Index) ComponentName() string {
- return name
-}
-
-func (s *Index) Sub(subscriber bus.Subscriber) error {
- return subscriber.Subscribe(storage.TraceIndex, s)
-}
-
-func (s Index) Name() string {
- return name
-}
-
-func (s Index) PreRun() error {
- s.log = logger.GetLogger(name)
- return nil
+type Database interface {
+ run.Config
+ run.PreRunner
}
-func (s Index) Rev(message bus.Message) {
- s.log.Info("rev", logger.Any("msg", message.Data()))
+func NewDB(ctx context.Context, repo discovery.ServiceRepo) (Database, error) {
+ return &DB{repo: repo}, nil
}
diff --git a/go.mod b/go.mod
index 0927f71..77dcde2 100644
--- a/go.mod
+++ b/go.mod
@@ -3,11 +3,12 @@ module github.com/apache/skywalking-banyandb
go 1.16
require (
+ github.com/google/flatbuffers v1.12.0
github.com/oklog/run v1.1.0
github.com/spf13/cobra v1.1.3
github.com/spf13/pflag v1.0.5
github.com/spf13/viper v1.7.1
- github.com/stretchr/testify v1.4.0
go.uber.org/multierr v1.6.0
go.uber.org/zap v1.16.0
+ google.golang.org/grpc v1.37.0
)
diff --git a/go.sum b/go.sum
index e426a98..444ebce 100644
--- a/go.sum
+++ b/go.sum
@@ -24,8 +24,10 @@ github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24
github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8=
github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs=
github.com/bketelsen/crypt v0.0.3-0.20200106085610-5cbc8cc4026c/go.mod h1:MKsuJmJgSg28kpZDP6UIiPt0e0Oz0kqKNGyRaWEPv84=
+github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc=
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
+github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk=
github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk=
github.com/coreos/etcd v3.3.13+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE=
github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk=
@@ -37,6 +39,10 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=
github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no=
+github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
+github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
+github.com/envoyproxy/go-control-plane v0.9.9-0.20210217033140-668b12f5399d/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk=
+github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I=
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
@@ -56,14 +62,29 @@ github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFU
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
+github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8=
+github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA=
+github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs=
+github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w=
+github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0=
+github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8=
+github.com/golang/protobuf v1.4.2 h1:+Z5KGCizgyZCbGh1KZqA0fcLLkwbsjIzS4aV2v7wJX0=
+github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
+github.com/google/flatbuffers v1.12.0 h1:/PtAHvnBY4Kqnx/xCQ3OIV9uYcSFGScBsWI3Oogeh6w=
+github.com/google/flatbuffers v1.12.0/go.mod h1:1AeVuKshWv4vARoZatz6mlQ0JxURH0Kv5+zNeJKJCa8=
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
+github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
+github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
+github.com/google/go-cmp v0.5.0 h1:/QaMHBdZ26BB3SSst0Iwl10Epc+xhTquomWX0oZEB6w=
+github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs=
github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc=
github.com/google/pprof v0.0.0-20190515194954-54271f7e092f/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc=
github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
+github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg=
github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk=
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 h1:EGx4pi6eqNxGaHF6qqu48+N2wcFQ5qg5FXgOdqsJ5d8=
@@ -144,6 +165,7 @@ github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXP
github.com/prometheus/client_golang v0.9.3/go.mod h1:/TN21ttK/J9q6uSwhBd54HahCDft0ttaMvbicHlPoso=
github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
+github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
github.com/prometheus/common v0.0.0-20181113130724-41aa239b4cce/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro=
github.com/prometheus/common v0.4.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4=
github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
@@ -180,8 +202,9 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
-github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
+github.com/stretchr/testify v1.5.1 h1:nOGnQDM7FYENwehXlg/kFVnos3rEvtKTjRvOWSzb6H4=
+github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
github.com/subosito/gotenv v1.2.0 h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s=
github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw=
github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U=
@@ -238,6 +261,7 @@ golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn
golang.org/x/net v0.0.0-20190501004415-9ce7a6920f09/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks=
+golang.org/x/net v0.0.0-20190620200207-3b0461eec859 h1:R/3boaszxrf1GEUWTVDzSKVwLmSJpwZ1yqXm8j0v2QI=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
@@ -277,6 +301,7 @@ golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3
golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
golang.org/x/tools v0.0.0-20190506145303-2d16b83fe98c/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
+golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
golang.org/x/tools v0.0.0-20190606124116-d0a3d012864b/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
golang.org/x/tools v0.0.0-20190628153133-6cdbf07be9d0/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
@@ -288,6 +313,8 @@ golang.org/x/tools v0.0.0-20191029190741-b9c20aec41a5/go.mod h1:b+2E5dAYhXwXZwtn
golang.org/x/tools v0.0.0-20191112195655-aa38f8e97acc h1:NCy3Ohtk6Iny5V/reW2Ktypo4zIpWBdRJ1uFMjBxdg8=
golang.org/x/tools v0.0.0-20191112195655-aa38f8e97acc/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
+golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
+golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE=
google.golang.org/api v0.7.0/go.mod h1:WtwebWUNSVBH/HAw79HIFXZNqEvBhG+Ra+ax0hx3E3M=
google.golang.org/api v0.8.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg=
@@ -306,9 +333,26 @@ google.golang.org/genproto v0.0.0-20190801165951-fa694d86fc64/go.mod h1:DMBHOl98
google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc=
google.golang.org/genproto v0.0.0-20190911173649-1774047e7e51/go.mod h1:IbNlFCBrqXvoKpeg0TB2l7cyZUmoaFKYIwrEpbDKLA8=
google.golang.org/genproto v0.0.0-20191108220845-16a3f7862a1a/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc=
+google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013 h1:+kGHl1aib/qcwaRi1CbqBZ1rk19r85MNUf8HaBghugY=
+google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo=
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38=
google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM=
+google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg=
+google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY=
+google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
+google.golang.org/grpc v1.37.0 h1:uSZWeQJX5j11bIQ4AJoj+McDBo29cY1MCoC1wO3ts+c=
+google.golang.org/grpc v1.37.0/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM=
+google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
+google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
+google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=
+google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE=
+google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo=
+google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
+google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
+google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
+google.golang.org/protobuf v1.25.0 h1:Ejskq+SyPohKW+1uil0JJMtmHCgJPJ/qWTxr8qp+R4c=
+google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c=
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY=
@@ -326,6 +370,7 @@ gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
+honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
honnef.co/go/tools v0.0.1-2019.2.3 h1:3JgtbtFHMiCmsznwGVTUWbgGov+pVqnlf1dEJTNAXeM=
honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg=
rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8=
diff --git a/pkg/logger/setting_test.go b/pkg/logger/setting_test.go
deleted file mode 100644
index 784ef4a..0000000
--- a/pkg/logger/setting_test.go
+++ /dev/null
@@ -1,91 +0,0 @@
-// Licensed to Apache Software Foundation (ASF) under one or more contributor
-// license agreements. See the NOTICE file distributed with
-// this work for additional information regarding copyright
-// ownership. Apache Software Foundation (ASF) licenses this file to you under
-// the Apache License, Version 2.0 (the "License"); you may
-// not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-
-package logger
-
-import (
- "reflect"
- "testing"
-
- "github.com/stretchr/testify/assert"
- "go.uber.org/zap/zapcore"
-
- "github.com/apache/skywalking-banyandb/pkg/config"
-)
-
-func TestInitLogger(t *testing.T) {
- type args struct {
- cfg config.Logging
- }
- type want struct {
- isDev bool
- level zapcore.Level
- }
- tests := []struct {
- name string
- args args
- want want
- wantErr bool
- }{
- {
- name: "golden path",
- args: args{config.Logging{Env: "prod", Level: "info"}},
- want: want{level: zapcore.InfoLevel},
- },
- {
- name: "empty config",
- args: args{config.Logging{}},
- want: want{level: zapcore.InfoLevel},
- },
- {
- name: "development mode",
- args: args{config.Logging{Env: "dev"}},
- want: want{isDev: true, level: zapcore.InfoLevel},
- },
- {
- name: "debug level",
- args: args{config.Logging{Level: "debug"}},
- want: want{level: zapcore.DebugLevel},
- },
- {
- name: "invalid env",
- args: args{config.Logging{Env: "invalid"}},
- want: want{level: zapcore.InfoLevel},
- },
- {
- name: "invalid level",
- args: args{config.Logging{Level: "invalid"}},
- wantErr: true,
- },
- }
- for _, tt := range tests {
- t.Run(tt.name, func(t *testing.T) {
- var err error
- var logger *Logger
- if logger, err = getLogger(tt.args.cfg); (err != nil) != tt.wantErr {
- t.Errorf("InitLogger() error = %v, wantErr %v", err, tt.wantErr)
- }
- if err == nil {
- assert.NotNil(t, logger)
- assert.NotNil(t, logger.Logger)
- assert.NotEmpty(t, logger.module)
- assert.Equal(t, tt.want.isDev, reflect.ValueOf(*logger.Logger).FieldByName("development").Bool())
- assert.NotNil(t, logger.Logger.Check(tt.want.level, "foo"))
- }
- })
- }
-}
diff --git a/scripts/ci/instal_fb.sh b/scripts/ci/instal_fb.sh
new file mode 100644
index 0000000..ece6be6
--- /dev/null
+++ b/scripts/ci/instal_fb.sh
@@ -0,0 +1,46 @@
+#!/usr/bin/env bash
+
+# Licensed to Apache Software Foundation (ASF) under one or more contributor
+# license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright
+# ownership. Apache Software Foundation (ASF) licenses this file to you under
+# the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+set -e
+
+FB_VERSION=${FB_VERSION:=v1.12.0}
+
+for CMD in curl cmake g++ make; do
+ command -v $CMD > /dev/null || \
+ { echo "[ERROR]: '$CMD' command not not found. Exiting" 1>&2; exit 1; }
+done
+
+## Create Temp Build Directory
+BUILD_DIR=$(mktemp -d)
+pushd $BUILD_DIR
+
+## Fetch Tarball
+curl -sLO https://github.com/google/flatbuffers/archive/$FB_VERSION.tar.gz
+tar xf $FB_VERSION.tar.gz
+
+## Build Binaries
+cd flatbuffers-${FB_VERSION#v}
+cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release
+make
+./flattests
+cp flatc /usr/local/bin/flatc
+
+## Cleanup Temp Build Directory
+popd
+rm -rf $BUILD_DIR