You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@devlake.apache.org by wa...@apache.org on 2022/09/08 05:21:09 UTC
[incubator-devlake] branch release-v0.12 updated (d584ab9d -> 93941d78)
This is an automated email from the ASF dual-hosted git repository.
warren pushed a change to branch release-v0.12
in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git
from d584ab9d fix: support jira server collect users
new b3d6483e feat: support source dsn
new 93941d78 fix: source_type shorthand
The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
.../src/data/pipeline-config-samples/starrocks.js | 6 ++-
plugins/starrocks/api/connection.go | 52 ++++++++++++++++++++++
plugins/starrocks/starrocks.go | 24 +++++-----
plugins/starrocks/task_data.go | 2 +
plugins/starrocks/tasks.go | 31 +++++++++++--
plugins/starrocks/utils.go | 2 +
6 files changed, 101 insertions(+), 16 deletions(-)
create mode 100644 plugins/starrocks/api/connection.go
[incubator-devlake] 02/02: fix: source_type shorthand
Posted by wa...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
warren pushed a commit to branch release-v0.12
in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git
commit 93941d78ead526eef809f2a4284d9dc8b902d90e
Author: Jinlong Peng <ji...@merico.dev>
AuthorDate: Thu Sep 1 20:18:50 2022 +0800
fix: source_type shorthand
---
plugins/starrocks/starrocks.go | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/plugins/starrocks/starrocks.go b/plugins/starrocks/starrocks.go
index 03887cb9..10af99b9 100644
--- a/plugins/starrocks/starrocks.go
+++ b/plugins/starrocks/starrocks.go
@@ -55,7 +55,7 @@ var PluginEntry StarRocks
func main() {
cmd := &cobra.Command{Use: "StarRocks"}
- sourceType := cmd.Flags().StringP("source_type", "sp", "", "Source type")
+ sourceType := cmd.Flags().StringP("source_type", "st", "", "Source type")
sourceDsn := cmd.Flags().StringP("source_dsn", "sd", "", "Source dsn")
_ = cmd.MarkFlagRequired("host")
host := cmd.Flags().StringP("host", "h", "", "StarRocks host")
[incubator-devlake] 01/02: feat: support source dsn
Posted by wa...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
warren pushed a commit to branch release-v0.12
in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git
commit b3d6483e65a80241283127bfe42ea128f57b1196
Author: Jinlong Peng <ji...@merico.dev>
AuthorDate: Thu Sep 1 16:58:01 2022 +0800
feat: support source dsn
---
.../src/data/pipeline-config-samples/starrocks.js | 6 ++-
plugins/starrocks/api/connection.go | 52 ++++++++++++++++++++++
plugins/starrocks/starrocks.go | 24 +++++-----
plugins/starrocks/task_data.go | 2 +
plugins/starrocks/tasks.go | 31 +++++++++++--
plugins/starrocks/utils.go | 2 +
6 files changed, 101 insertions(+), 16 deletions(-)
diff --git a/config-ui/src/data/pipeline-config-samples/starrocks.js b/config-ui/src/data/pipeline-config-samples/starrocks.js
index 40631d2b..dc8cde08 100644
--- a/config-ui/src/data/pipeline-config-samples/starrocks.js
+++ b/config-ui/src/data/pipeline-config-samples/starrocks.js
@@ -18,8 +18,10 @@
const starRocksConfig = [
[
{
- Plugin: 'starrocks',
- Options: {
+ plugin: 'starrocks',
+ options: {
+ source_type: '', // mysql or postgres
+ source_dsn: '', // gorm dsn
host: '127.0.0.1',
port: 9030,
user: 'root',
diff --git a/plugins/starrocks/api/connection.go b/plugins/starrocks/api/connection.go
new file mode 100644
index 00000000..21daaddd
--- /dev/null
+++ b/plugins/starrocks/api/connection.go
@@ -0,0 +1,52 @@
+/*
+Licensed to the 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.
+The 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 api
+
+import (
+ "github.com/apache/incubator-devlake/plugins/core"
+ "net/http"
+)
+
+// @Summary pipelines plan for starrocks
+// @Description pipelines plan for starrocks
+// @Tags plugins/starrocks
+// @Accept application/json
+// @Param blueprint body StarRocksPipelinePlan true "json"
+// @Router /pipelines/starrocks/pipeline-plan [post]
+func PostStarRocksPipeline(input *core.ApiResourceInput) (*core.ApiResourceOutput, error) {
+ blueprint := &StarRocksPipelinePlan{}
+ return &core.ApiResourceOutput{Body: blueprint, Status: http.StatusOK}, nil
+}
+
+type StarRocksPipelinePlan [][]struct {
+ Plugin string `json:"plugin"`
+ Options struct {
+ SourceType string `json:"source_type"`
+ SourceDsn string `json:"source_dsn"`
+ Host string `json:"host"`
+ Port int `json:"port"`
+ User string `json:"user"`
+ Password string `json:"password"`
+ Database string `json:"database"`
+ BePort int `json:"be_port"`
+ Tables []string `json:"tables"`
+ BatchSize int `json:"batch_size"`
+ Extra string `json:"extra"`
+ DomainLayer string `json:"domain_layer"`
+ } `json:"options"`
+}
diff --git a/plugins/starrocks/starrocks.go b/plugins/starrocks/starrocks.go
index 199d21c3..03887cb9 100644
--- a/plugins/starrocks/starrocks.go
+++ b/plugins/starrocks/starrocks.go
@@ -55,6 +55,8 @@ var PluginEntry StarRocks
func main() {
cmd := &cobra.Command{Use: "StarRocks"}
+ sourceType := cmd.Flags().StringP("source_type", "sp", "", "Source type")
+ sourceDsn := cmd.Flags().StringP("source_dsn", "sd", "", "Source dsn")
_ = cmd.MarkFlagRequired("host")
host := cmd.Flags().StringP("host", "h", "", "StarRocks host")
_ = cmd.MarkFlagRequired("port")
@@ -76,16 +78,18 @@ func main() {
extra := cmd.Flags().StringP("extra", "e", "", "StarRocks create table sql extra")
cmd.Run = func(cmd *cobra.Command, args []string) {
runner.DirectRun(cmd, args, PluginEntry, map[string]interface{}{
- "host": host,
- "port": port,
- "user": user,
- "password": password,
- "database": database,
- "be_host": beHost,
- "be_port": bePort,
- "tables": tables,
- "batch_size": batchSize,
- "extra": extra,
+ "source_type": sourceType,
+ "source_dsn": sourceDsn,
+ "host": host,
+ "port": port,
+ "user": user,
+ "password": password,
+ "database": database,
+ "be_host": beHost,
+ "be_port": bePort,
+ "tables": tables,
+ "batch_size": batchSize,
+ "extra": extra,
})
}
runner.RunCmd(cmd)
diff --git a/plugins/starrocks/task_data.go b/plugins/starrocks/task_data.go
index 76f4b1b4..bb0879b8 100644
--- a/plugins/starrocks/task_data.go
+++ b/plugins/starrocks/task_data.go
@@ -17,6 +17,8 @@ limitations under the License.
package main
type StarRocksConfig struct {
+ SourceType string `mapstructure:"source_type"`
+ SourceDsn string `mapstructure:"source_dsn"`
Host string
Port int
User string
diff --git a/plugins/starrocks/tasks.go b/plugins/starrocks/tasks.go
index 61d4989a..ece4131c 100644
--- a/plugins/starrocks/tasks.go
+++ b/plugins/starrocks/tasks.go
@@ -21,14 +21,17 @@ import (
"database/sql"
"encoding/json"
"fmt"
+ "github.com/apache/incubator-devlake/impl/dalgorm"
+ "github.com/apache/incubator-devlake/plugins/core"
+ "github.com/apache/incubator-devlake/plugins/core/dal"
+ "gorm.io/driver/mysql"
+ "gorm.io/driver/postgres"
+ "gorm.io/gorm"
"io"
"net/http"
"net/url"
"regexp"
"strings"
-
- "github.com/apache/incubator-devlake/plugins/core"
- "github.com/apache/incubator-devlake/plugins/core/dal"
)
type Table struct {
@@ -40,8 +43,28 @@ func (t *Table) TableName() string {
}
func LoadData(c core.SubTaskContext) error {
+ var db dal.Dal
config := c.GetData().(*StarRocksConfig)
- db := c.GetDal()
+ if config.SourceDsn != "" && config.SourceType != "" {
+ var o *gorm.DB
+ var err error
+ if config.SourceType == "mysql" {
+ o, err = gorm.Open(mysql.Open(config.SourceDsn))
+ if err != nil {
+ return err
+ }
+ } else if config.SourceType == "postgres" {
+ o, err = gorm.Open(postgres.Open(config.SourceDsn))
+ if err != nil {
+ return err
+ }
+ } else {
+ return fmt.Errorf("unsupported source type %s", config.SourceType)
+ }
+ db = dalgorm.NewDalgorm(o)
+ } else {
+ db = c.GetDal()
+ }
var starrocksTables []string
if config.DomainLayer != "" {
starrocksTables = getTablesByDomainLayer(config.DomainLayer)
diff --git a/plugins/starrocks/utils.go b/plugins/starrocks/utils.go
index 0306ec3a..a68c79e5 100644
--- a/plugins/starrocks/utils.go
+++ b/plugins/starrocks/utils.go
@@ -99,6 +99,8 @@ func getDataType(dataType string) string {
starrocksDatatype = "double"
} else if stringIn(dataType, "json", "jsonb") {
starrocksDatatype = "json"
+ } else if dataType == "uuid" {
+ starrocksDatatype = "char(36)"
}
return starrocksDatatype
}