Repository: lf-edge/ekuiper
Pull request #2964 (2024-07-01 02:12:53)

refactor(io): move extended plugins
- Make it easier to register on demand in a wrapper project

codecov[bot]: ## [Codecov](https://app.codecov.io/gh/lf-edge/ekuiper/pull/2964?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=lf-edge) Report
All modified and coverable lines are covered by tests :white_check_mark:
> Please [upload](https://docs.codecov.com/docs/codecov-uploader) report for BASE (`master-v2@6c74ec8`). [Learn more](https://docs.codecov.io/docs/error-reference?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=lf-edge#section-missing-base-commit) about missing BASE report.

<details><summary>Additional details and impacted files</summary>


```diff
@@             Coverage Diff              @@
##             master-v2    #2964   +/-   ##
============================================
  Coverage             ?   69.32%           
============================================
  Files                ?      314           
  Lines                ?    30245           
  Branches             ?        0           
============================================
  Hits                 ?    20965           
  Misses               ?     7431           
  Partials             ?     1849           
```

</details>

[:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/lf-edge/ekuiper/pull/2964?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=lf-edge).   
:loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=lf-edge).


Patch:
diff --git a/internal/io/sql/client/dburl.go b/extension/sql/client/dburl.go
similarity index 100%
rename from internal/io/sql/client/dburl.go
rename to extension/sql/client/dburl.go
diff --git a/internal/io/sql/sink.go b/extension/sql/sink.go
similarity index 98%
rename from internal/io/sql/sink.go
rename to extension/sql/sink.go
index 3ac421a8..39f3e56a 100644
--- a/internal/io/sql/sink.go
+++ b/extension/sql/sink.go
@@ -12,9 +12,6 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
-//go:build full
-// +build full
-
 package sql
 
 import (
@@ -23,7 +20,7 @@ import (
 	"strings"
 
 	"github.com/lf-edge/ekuiper/contract/v2/api"
-	"github.com/lf-edge/ekuiper/v2/internal/io/sql/client"
+	"github.com/lf-edge/ekuiper/v2/extension/sql/client"
 	"github.com/lf-edge/ekuiper/v2/pkg/ast"
 	"github.com/lf-edge/ekuiper/v2/pkg/cast"
 	"github.com/lf-edge/ekuiper/v2/pkg/connection"
diff --git a/internal/io/sql/source.go b/extension/sql/source.go
similarity index 98%
rename from internal/io/sql/source.go
rename to extension/sql/source.go
index 5ff91f9d..7c45a023 100644
--- a/internal/io/sql/source.go
+++ b/extension/sql/source.go
@@ -12,9 +12,6 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
-//go:build full
-// +build full
-
 package sql
 
 import (
@@ -28,7 +25,7 @@ import (
 	"github.com/pingcap/failpoint"
 
 	"github.com/lf-edge/ekuiper/contract/v2/api"
-	"github.com/lf-edge/ekuiper/v2/internal/io/sql/client"
+	"github.com/lf-edge/ekuiper/v2/extension/sql/client"
 	"github.com/lf-edge/ekuiper/v2/pkg/cast"
 	"github.com/lf-edge/ekuiper/v2/pkg/connection"
 	"github.com/lf-edge/ekuiper/v2/pkg/sqldatabase/sqlgen"
diff --git a/internal/io/sql/testx/mysql_server.go b/extension/sql/testx/mysql_server.go
similarity index 100%
rename from internal/io/sql/testx/mysql_server.go
rename to extension/sql/testx/mysql_server.go
diff --git a/internal/io/video/source.go b/extension/video/source.go
similarity index 100%
rename from internal/io/video/source.go
rename to extension/video/source.go
diff --git a/internal/io/video/source_test.go b/extension/video/source_test.go
similarity index 100%
rename from internal/io/video/source_test.go
rename to extension/video/source_test.go
diff --git a/internal/binder/io/ext_full.go b/internal/binder/io/ext_full.go
index 8d84478a..6f79423d 100644
--- a/internal/binder/io/ext_full.go
+++ b/internal/binder/io/ext_full.go
@@ -18,9 +18,9 @@ package io
 
 import (
 	"github.com/lf-edge/ekuiper/contract/v2/api"
-	"github.com/lf-edge/ekuiper/v2/internal/io/sql"
-	"github.com/lf-edge/ekuiper/v2/internal/io/sql/client"
-	"github.com/lf-edge/ekuiper/v2/internal/io/video"
+	"github.com/lf-edge/ekuiper/v2/extension/sql"
+	"github.com/lf-edge/ekuiper/v2/extension/sql/client"
+	"github.com/lf-edge/ekuiper/v2/extension/video"
 	"github.com/lf-edge/ekuiper/v2/pkg/modules"
 )
 
diff --git a/internal/io/connection.go b/internal/io/connection.go
deleted file mode 100644
index f366cd7e..00000000
--- a/internal/io/connection.go
+++ /dev/null
@@ -1,41 +0,0 @@
-// Copyright 2024 EMQ Technologies Co., Ltd.
-//
-// Licensed 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 io
-
-import "github.com/lf-edge/ekuiper/contract/v2/api"
-
-type ConnStatus int
-
-const (
-	Connecting ConnStatus = iota
-	Connected
-	Disconnect
-	Subscribed
-	SubError
-)
-
-type MessageClient interface {
-	Subscribe(c api.StreamContext, subChan []TopicChannel, messageErrors chan error, params map[string]interface{}) error
-	Publish(c api.StreamContext, topic string, message []byte, params map[string]interface{}) error
-	Ping() error
-}
-
-// TopicChannel is the data structure for subscriber
-type TopicChannel struct {
-	// Topic for subscriber to filter on if any
-	Topic string
-	// Messages is the returned message channel for the subscriber
-	Messages chan<- interface{}
-}


Test patch:
diff --git a/internal/io/sql/client/client.go b/extension/sql/client/client.go
similarity index 100%
rename from internal/io/sql/client/client.go
rename to extension/sql/client/client.go
diff --git a/internal/io/sql/client/client_test.go b/extension/sql/client/client_test.go
similarity index 96%
rename from internal/io/sql/client/client_test.go
rename to extension/sql/client/client_test.go
index e69cf981..1a0cd272 100644
--- a/internal/io/sql/client/client_test.go
+++ b/extension/sql/client/client_test.go
@@ -20,7 +20,7 @@ import (
 
 	"github.com/stretchr/testify/require"
 
-	"github.com/lf-edge/ekuiper/v2/internal/io/sql/testx"
+	"github.com/lf-edge/ekuiper/v2/extension/sql/testx"
 	mockContext "github.com/lf-edge/ekuiper/v2/pkg/mock/context"
 )
 
diff --git a/internal/io/sql/sink_test.go b/extension/sql/sink_test.go
similarity index 99%
rename from internal/io/sql/sink_test.go
rename to extension/sql/sink_test.go
index 07957d80..56d51a1a 100644
--- a/internal/io/sql/sink_test.go
+++ b/extension/sql/sink_test.go
@@ -24,6 +24,7 @@ import (
 	"github.com/stretchr/testify/require"
 
 	"github.com/lf-edge/ekuiper/v2/internal/io/sql/testx"
+
 	"github.com/lf-edge/ekuiper/v2/pkg/connection"
 	mockContext "github.com/lf-edge/ekuiper/v2/pkg/mock/context"
 )
diff --git a/internal/io/sql/source_test.go b/extension/sql/source_test.go
similarity index 98%
rename from internal/io/sql/source_test.go
rename to extension/sql/source_test.go
index e69d3596..c6d55da1 100644
--- a/internal/io/sql/source_test.go
+++ b/extension/sql/source_test.go
@@ -12,9 +12,6 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
-//go:build full
-// +build full
-
 package sql
 
 import (
@@ -27,8 +24,8 @@ import (
 	"github.com/stretchr/testify/require"
 
 	"github.com/lf-edge/ekuiper/contract/v2/api"
-	"github.com/lf-edge/ekuiper/v2/internal/io/sql/client"
-	"github.com/lf-edge/ekuiper/v2/internal/io/sql/testx"
+	"github.com/lf-edge/ekuiper/v2/extension/sql/client"
+	"github.com/lf-edge/ekuiper/v2/extension/sql/testx"
 	"github.com/lf-edge/ekuiper/v2/internal/topo/context"
 	"github.com/lf-edge/ekuiper/v2/pkg/connection"
 	mockContext "github.com/lf-edge/ekuiper/v2/pkg/mock/context"