Repository: dragonflyoss/Dragonfly2
Pull request #436 (2021-07-08 07:24:35)

Move internal/rpc to pkg/rpc
Signed-off-by: Jim Ma <majinjing3@gmail.com>

<!--- Provide a general summary of your changes in the Title above -->

## Description

<!--- Describe your changes in detail -->

## Related Issue

<!--- This project only accepts pull requests related to open issues -->
<!--- If suggesting a new feature or change, please discuss it in an issue first -->
<!--- If fixing a bug, there should be an issue describing it with steps to reproduce -->
<!--- Please link to the issue here: -->

## Motivation and Context

<!--- Why is this change required? What problem does it solve? -->

## Screenshots (if appropriate):

## Types of changes

<!--- What types of changes does your code introduce? Put an `x` in all the boxes that apply: -->

- [ ] Bug fix (non-breaking change which fixes an issue)
- [x] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to change)
- [ ] Documentation Update (if none of the other choices apply)

## Checklist:

<!--- Go over all the following points, and put an `x` in all the boxes that apply. -->
<!--- If you're unsure about any of these, don't hesitate to ask. We're here to help! -->

- [x] Code compiles correctly.
- [ ] My code follows the code style of this project.
- [ ] My change requires a change to the documentation.
- [ ] I have updated the documentation accordingly.
- [ ] I have read the **CONTRIBUTING** document.
- [ ] I have added tests to cover my changes.
- [x] All new and existing tests passed.


codecov-commenter: # [Codecov](https://codecov.io/gh/dragonflyoss/Dragonfly2/pull/436?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=dragonflyoss) Report
> Merging [#436](https://codecov.io/gh/dragonflyoss/Dragonfly2/pull/436?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=dragonflyoss) (c11ccc7) into [main](https://codecov.io/gh/dragonflyoss/Dragonfly2/commit/71efb221565ad6a031ff6b22869c961363d84c63?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=dragonflyoss) (71efb22) will **not change** coverage.
> The diff coverage is `n/a`.

[![Impacted file tree graph](https://codecov.io/gh/dragonflyoss/Dragonfly2/pull/436/graphs/tree.svg?width=650&height=150&src=pr&token=PUICJYSAT7&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=dragonflyoss)](https://codecov.io/gh/dragonflyoss/Dragonfly2/pull/436?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=dragonflyoss)

```diff
@@           Coverage Diff           @@
##             main     #436   +/-   ##
=======================================
  Coverage   37.96%   37.96%           
=======================================
  Files          80       80           
  Lines        6279     6279           
=======================================
  Hits         2384     2384           
  Misses       3558     3558           
  Partials      337      337           
```

| Flag | Coverage Δ | |
|---|---|---|
| unittests | `37.96% <ø> (ø)` | |

Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=dragonflyoss#carryforward-flags-in-the-pull-request-comment) to find out more.

| [Impacted Files](https://codecov.io/gh/dragonflyoss/Dragonfly2/pull/436?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=dragonflyoss) | Coverage Δ | |
|---|---|---|
| [cdnsystem/daemon/cdn/manager.go](https://codecov.io/gh/dragonflyoss/Dragonfly2/pull/436/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=dragonflyoss#diff-Y2Ruc3lzdGVtL2RhZW1vbi9jZG4vbWFuYWdlci5nbw==) | `56.43% <ø> (ø)` | |
| [cdnsystem/server/service/cdn\_seed\_server.go](https://codecov.io/gh/dragonflyoss/Dragonfly2/pull/436/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=dragonflyoss#diff-Y2Ruc3lzdGVtL3NlcnZlci9zZXJ2aWNlL2Nkbl9zZWVkX3NlcnZlci5nbw==) | `0.00% <ø> (ø)` | |
| [client/clientutil/peer.go](https://codecov.io/gh/dragonflyoss/Dragonfly2/pull/436/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=dragonflyoss#diff-Y2xpZW50L2NsaWVudHV0aWwvcGVlci5nbw==) | `0.00% <ø> (ø)` | |
| [client/daemon/peer/peertask\_base.go](https://codecov.io/gh/dragonflyoss/Dragonfly2/pull/436/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=dragonflyoss#diff-Y2xpZW50L2RhZW1vbi9wZWVyL3BlZXJ0YXNrX2Jhc2UuZ28=) | `32.76% <ø> (ø)` | |
| [client/daemon/peer/peertask\_file.go](https://codecov.io/gh/dragonflyoss/Dragonfly2/pull/436/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=dragonflyoss#diff-Y2xpZW50L2RhZW1vbi9wZWVyL3BlZXJ0YXNrX2ZpbGUuZ28=) | `53.65% <ø> (ø)` | |
| [client/daemon/peer/peertask\_file\_callback.go](https://codecov.io/gh/dragonflyoss/Dragonfly2/pull/436/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=dragonflyoss#diff-Y2xpZW50L2RhZW1vbi9wZWVyL3BlZXJ0YXNrX2ZpbGVfY2FsbGJhY2suZ28=) | `62.96% <ø> (ø)` | |
| [client/daemon/peer/peertask\_manager.go](https://codecov.io/gh/dragonflyoss/Dragonfly2/pull/436/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=dragonflyoss#diff-Y2xpZW50L2RhZW1vbi9wZWVyL3BlZXJ0YXNrX21hbmFnZXIuZ28=) | `19.40% <ø> (ø)` | |
| [client/daemon/peer/peertask\_reuse.go](https://codecov.io/gh/dragonflyoss/Dragonfly2/pull/436/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=dragonflyoss#diff-Y2xpZW50L2RhZW1vbi9wZWVyL3BlZXJ0YXNrX3JldXNlLmdv) | `0.00% <ø> (ø)` | |
| [client/daemon/peer/peertask\_stream.go](https://codecov.io/gh/dragonflyoss/Dragonfly2/pull/436/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=dragonflyoss#diff-Y2xpZW50L2RhZW1vbi9wZWVyL3BlZXJ0YXNrX3N0cmVhbS5nbw==) | `54.61% <ø> (ø)` | |
| [client/daemon/peer/peertask\_stream\_callback.go](https://codecov.io/gh/dragonflyoss/Dragonfly2/pull/436/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=dragonflyoss#diff-Y2xpZW50L2RhZW1vbi9wZWVyL3BlZXJ0YXNrX3N0cmVhbV9jYWxsYmFjay5nbw==) | `64.55% <ø> (ø)` | |
| ... and [12 more](https://codecov.io/gh/dragonflyoss/Dragonfly2/pull/436/diff?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=dragonflyoss) | |


Patch:
diff --git a/cdnsystem/daemon/cdn/manager.go b/cdnsystem/daemon/cdn/manager.go
index d6e25db0..2b939c51 100644
--- a/cdnsystem/daemon/cdn/manager.go
+++ b/cdnsystem/daemon/cdn/manager.go
@@ -26,7 +26,7 @@ import (
 	"d7y.io/dragonfly/v2/cdnsystem/daemon"
 	_ "d7y.io/dragonfly/v2/cdnsystem/daemon/cdn/storage/disk"   // To register diskStorage
 	_ "d7y.io/dragonfly/v2/cdnsystem/daemon/cdn/storage/hybrid" // To register hybridStorage
-	"d7y.io/dragonfly/v2/internal/rpc/cdnsystem/server"
+	"d7y.io/dragonfly/v2/pkg/rpc/cdnsystem/server"
 	"d7y.io/dragonfly/v2/pkg/synclock"
 	"d7y.io/dragonfly/v2/pkg/util/timeutils"
 
diff --git a/cdnsystem/server/server.go b/cdnsystem/server/server.go
index d5fafde1..0b99453d 100644
--- a/cdnsystem/server/server.go
+++ b/cdnsystem/server/server.go
@@ -32,10 +32,10 @@ import (
 	"d7y.io/dragonfly/v2/cdnsystem/plugins"
 	"d7y.io/dragonfly/v2/cdnsystem/server/service"
 	logger "d7y.io/dragonfly/v2/internal/dflog"
-	"d7y.io/dragonfly/v2/internal/rpc"
-	"d7y.io/dragonfly/v2/internal/rpc/cdnsystem/server"
-	"d7y.io/dragonfly/v2/internal/rpc/manager"
 	"d7y.io/dragonfly/v2/pkg/retry"
+	"d7y.io/dragonfly/v2/pkg/rpc"
+	"d7y.io/dragonfly/v2/pkg/rpc/cdnsystem/server"
+	"d7y.io/dragonfly/v2/pkg/rpc/manager"
 	"d7y.io/dragonfly/v2/pkg/util/net/iputils"
 	"github.com/pkg/errors"
 	"google.golang.org/grpc"
diff --git a/cdnsystem/server/service/cdn_seed_server.go b/cdnsystem/server/service/cdn_seed_server.go
index 61a35860..f9253d60 100644
--- a/cdnsystem/server/service/cdn_seed_server.go
+++ b/cdnsystem/server/service/cdn_seed_server.go
@@ -29,8 +29,8 @@ import (
 	"d7y.io/dragonfly/v2/internal/dfcodes"
 	"d7y.io/dragonfly/v2/internal/dferrors"
 	logger "d7y.io/dragonfly/v2/internal/dflog"
-	"d7y.io/dragonfly/v2/internal/rpc/base"
-	"d7y.io/dragonfly/v2/internal/rpc/cdnsystem"
+	"d7y.io/dragonfly/v2/pkg/rpc/base"
+	"d7y.io/dragonfly/v2/pkg/rpc/cdnsystem"
 	"d7y.io/dragonfly/v2/pkg/util/net/iputils"
 	"d7y.io/dragonfly/v2/pkg/util/net/urlutils"
 	"d7y.io/dragonfly/v2/pkg/util/stringutils"
diff --git a/client/clientutil/peer.go b/client/clientutil/peer.go
index a4f1dbc0..8d0749f0 100644
--- a/client/clientutil/peer.go
+++ b/client/clientutil/peer.go
@@ -22,7 +22,7 @@ import (
 
 	"github.com/pborman/uuid"
 
-	"d7y.io/dragonfly/v2/internal/rpc/scheduler"
+	"d7y.io/dragonfly/v2/pkg/rpc/scheduler"
 )
 
 func GenPeerID(peerHost *scheduler.PeerHost) string {
diff --git a/client/daemon/peer/peertask_base.go b/client/daemon/peer/peertask_base.go
index f7c69979..98b38ce2 100644
--- a/client/daemon/peer/peertask_base.go
+++ b/client/daemon/peer/peertask_base.go
@@ -36,11 +36,11 @@ import (
 	"d7y.io/dragonfly/v2/internal/dfcodes"
 	"d7y.io/dragonfly/v2/internal/dferrors"
 	logger "d7y.io/dragonfly/v2/internal/dflog"
-	"d7y.io/dragonfly/v2/internal/rpc/base"
-	dfclient "d7y.io/dragonfly/v2/internal/rpc/dfdaemon/client"
-	"d7y.io/dragonfly/v2/internal/rpc/scheduler"
-	schedulerclient "d7y.io/dragonfly/v2/internal/rpc/scheduler/client"
 	"d7y.io/dragonfly/v2/pkg/retry"
+	"d7y.io/dragonfly/v2/pkg/rpc/base"
+	dfclient "d7y.io/dragonfly/v2/pkg/rpc/dfdaemon/client"
+	"d7y.io/dragonfly/v2/pkg/rpc/scheduler"
+	schedulerclient "d7y.io/dragonfly/v2/pkg/rpc/scheduler/client"
 )
 
 const (
diff --git a/client/daemon/peer/peertask_file.go b/client/daemon/peer/peertask_file.go
index 1ea0bf1a..966c94b0 100644
--- a/client/daemon/peer/peertask_file.go
+++ b/client/daemon/peer/peertask_file.go
@@ -30,9 +30,9 @@ import (
 	"d7y.io/dragonfly/v2/client/config"
 	"d7y.io/dragonfly/v2/internal/dfcodes"
 	logger "d7y.io/dragonfly/v2/internal/dflog"
-	"d7y.io/dragonfly/v2/internal/rpc/base"
-	"d7y.io/dragonfly/v2/internal/rpc/scheduler"
-	schedulerclient "d7y.io/dragonfly/v2/internal/rpc/scheduler/client"
+	"d7y.io/dragonfly/v2/pkg/rpc/base"
+	"d7y.io/dragonfly/v2/pkg/rpc/scheduler"
+	schedulerclient "d7y.io/dragonfly/v2/pkg/rpc/scheduler/client"
 )
 
 type FilePeerTaskRequest struct {
diff --git a/client/daemon/peer/peertask_file_callback.go b/client/daemon/peer/peertask_file_callback.go
index a0ff01ef..db94b9b9 100644
--- a/client/daemon/peer/peertask_file_callback.go
+++ b/client/daemon/peer/peertask_file_callback.go
@@ -22,8 +22,8 @@ import (
 
 	"d7y.io/dragonfly/v2/client/daemon/storage"
 	"d7y.io/dragonfly/v2/internal/dfcodes"
-	"d7y.io/dragonfly/v2/internal/rpc/base"
-	"d7y.io/dragonfly/v2/internal/rpc/scheduler"
+	"d7y.io/dragonfly/v2/pkg/rpc/base"
+	"d7y.io/dragonfly/v2/pkg/rpc/scheduler"
 )
 
 type filePeerTaskCallback struct {
diff --git a/client/daemon/peer/peertask_manager.go b/client/daemon/peer/peertask_manager.go
index 9b1b0bc3..bbfba5b0 100644
--- a/client/daemon/peer/peertask_manager.go
+++ b/client/daemon/peer/peertask_manager.go
@@ -35,9 +35,9 @@ import (
 	"d7y.io/dragonfly/v2/client/config"
 	"d7y.io/dragonfly/v2/client/daemon/storage"
 	logger "d7y.io/dragonfly/v2/internal/dflog"
-	"d7y.io/dragonfly/v2/internal/rpc/base"
-	"d7y.io/dragonfly/v2/internal/rpc/scheduler"
-	schedulerclient "d7y.io/dragonfly/v2/internal/rpc/scheduler/client"
+	"d7y.io/dragonfly/v2/pkg/rpc/base"
+	"d7y.io/dragonfly/v2/pkg/rpc/scheduler"
+	schedulerclient "d7y.io/dragonfly/v2/pkg/rpc/scheduler/client"
 )
 
 // TaskManager processes all peer tasks request
diff --git a/client/daemon/peer/peertask_reuse.go b/client/daemon/peer/peertask_reuse.go
index accd8805..85b10075 100644
--- a/client/daemon/peer/peertask_reuse.go
+++ b/client/daemon/peer/peertask_reuse.go
@@ -27,7 +27,7 @@ import (
 	"d7y.io/dragonfly/v2/internal/dfcodes"
 	logger "d7y.io/dragonfly/v2/internal/dflog"
 	"d7y.io/dragonfly/v2/internal/idgen"
-	"d7y.io/dragonfly/v2/internal/rpc/scheduler"
+	"d7y.io/dragonfly/v2/pkg/rpc/scheduler"
 	"github.com/go-http-utils/headers"
 	"go.opentelemetry.io/otel/semconv"
 	"go.opentelemetry.io/otel/trace"
diff --git a/client/daemon/peer/peertask_stream.go b/client/daemon/peer/peertask_stream.go
index c9fc88ef..ab28b42b 100644
--- a/client/daemon/peer/peertask_stream.go
+++ b/client/daemon/peer/peertask_stream.go
@@ -33,9 +33,9 @@ import (
 	"d7y.io/dragonfly/v2/client/daemon/storage"
 	"d7y.io/dragonfly/v2/internal/dfcodes"
 	logger "d7y.io/dragonfly/v2/internal/dflog"
-	"d7y.io/dragonfly/v2/internal/rpc/base"
-	"d7y.io/dragonfly/v2/internal/rpc/scheduler"
-	schedulerclient "d7y.io/dragonfly/v2/internal/rpc/scheduler/client"
+	"d7y.io/dragonfly/v2/pkg/rpc/base"
+	"d7y.io/dragonfly/v2/pkg/rpc/scheduler"
+	schedulerclient "d7y.io/dragonfly/v2/pkg/rpc/scheduler/client"
 )
 
 // StreamPeerTask represents a peer task with stream io for reading directly without once more disk io
diff --git a/client/daemon/peer/peertask_stream_callback.go b/client/daemon/peer/peertask_stream_callback.go
index 07b00c0f..5455575c 100644
--- a/client/daemon/peer/peertask_stream_callback.go
+++ b/client/daemon/peer/peertask_stream_callback.go
@@ -22,8 +22,8 @@ import (
 
 	"d7y.io/dragonfly/v2/client/daemon/storage"
 	"d7y.io/dragonfly/v2/internal/dfcodes"
-	"d7y.io/dragonfly/v2/internal/rpc/base"
-	"d7y.io/dragonfly/v2/internal/rpc/scheduler"
+	"d7y.io/dragonfly/v2/pkg/rpc/base"
+	"d7y.io/dragonfly/v2/pkg/rpc/scheduler"
 )
 
 type streamPeerTaskCallback struct {
diff --git a/client/daemon/peer/piece_downloader.go b/client/daemon/peer/piece_downloader.go
index 10ea5ffb..794d6a52 100644
--- a/client/daemon/peer/piece_downloader.go
+++ b/client/daemon/peer/piece_downloader.go
@@ -28,7 +28,7 @@ import (
 
 	"d7y.io/dragonfly/v2/client/daemon/upload"
 	logger "d7y.io/dragonfly/v2/internal/dflog"
-	"d7y.io/dragonfly/v2/internal/rpc/base"
+	"d7y.io/dragonfly/v2/pkg/rpc/base"
 	"d7y.io/dragonfly/v2/pkg/util/digestutils"
 )
 
diff --git a/client/daemon/peer/piece_manager.go b/client/daemon/peer/piece_manager.go
index d87886fb..0f6a00a5 100644
--- a/client/daemon/peer/piece_manager.go
+++ b/client/daemon/peer/piece_manager.go
@@ -32,8 +32,8 @@ import (
 	"d7y.io/dragonfly/v2/client/daemon/storage"
 	"d7y.io/dragonfly/v2/internal/dfcodes"
 	logger "d7y.io/dragonfly/v2/internal/dflog"
-	"d7y.io/dragonfly/v2/internal/rpc/base"
-	"d7y.io/dragonfly/v2/internal/rpc/scheduler"
+	"d7y.io/dragonfly/v2/pkg/rpc/base"
+	"d7y.io/dragonfly/v2/pkg/rpc/scheduler"
 	"d7y.io/dragonfly/v2/pkg/util/digestutils"
 )
 
diff --git a/client/daemon/peerhost.go b/client/daemon/peerhost.go
index 41b2c30f..90a72c31 100644
--- a/client/daemon/peerhost.go
+++ b/client/daemon/peerhost.go
@@ -47,10 +47,10 @@ import (
 	"d7y.io/dragonfly/v2/client/daemon/storage"
 	"d7y.io/dragonfly/v2/client/daemon/upload"
 	logger "d7y.io/dragonfly/v2/internal/dflog"
-	"d7y.io/dragonfly/v2/internal/rpc"
-	"d7y.io/dragonfly/v2/internal/rpc/scheduler"
-	schedulerclient "d7y.io/dragonfly/v2/internal/rpc/scheduler/client"
 	"d7y.io/dragonfly/v2/pkg/basic/dfnet"
+	"d7y.io/dragonfly/v2/pkg/rpc"
+	"d7y.io/dragonfly/v2/pkg/rpc/scheduler"
+	schedulerclient "d7y.io/dragonfly/v2/pkg/rpc/scheduler/client"
 )
 
 type PeerHost interface {
diff --git a/client/daemon/proxy/proxy.go b/client/daemon/proxy/proxy.go
index 02011232..23cea454 100644
--- a/client/daemon/proxy/proxy.go
+++ b/client/daemon/proxy/proxy.go
@@ -32,7 +32,7 @@ import (
 	"d7y.io/dragonfly/v2/client/daemon/peer"
 	"d7y.io/dragonfly/v2/client/daemon/transport"
 	logger "d7y.io/dragonfly/v2/internal/dflog"
-	"d7y.io/dragonfly/v2/internal/rpc/scheduler"
+	"d7y.io/dragonfly/v2/pkg/rpc/scheduler"
 	"d7y.io/dragonfly/v2/pkg/util/stringutils"
 	"github.com/go-http-utils/headers"
 	"github.com/golang/groupcache/lru"
diff --git a/client/daemon/proxy/proxy_manager.go b/client/daemon/proxy/proxy_manager.go
index deff20b9..178a1e2f 100644
--- a/client/daemon/proxy/proxy_manager.go
+++ b/client/daemon/proxy/proxy_manager.go
@@ -33,7 +33,7 @@ import (
 	"d7y.io/dragonfly/v2/client/config"
 	"d7y.io/dragonfly/v2/client/daemon/peer"
 	logger "d7y.io/dragonfly/v2/internal/dflog"
-	"d7y.io/dragonfly/v2/internal/rpc/scheduler"
+	"d7y.io/dragonfly/v2/pkg/rpc/scheduler"
 )
 
 type Manager interface {
diff --git a/client/daemon/service/manager.go b/client/daemon/service/manager.go
index f223771c..eea3ce9f 100644
--- a/client/daemon/service/manager.go
+++ b/client/daemon/service/manager.go
@@ -33,11 +33,11 @@ import (
 	"d7y.io/dragonfly/v2/internal/dfcodes"
 	"d7y.io/dragonfly/v2/internal/dferrors"
 	logger "d7y.io/dragonfly/v2/internal/dflog"
-	"d7y.io/dragonfly/v2/internal/rpc"
-	"d7y.io/dragonfly/v2/internal/rpc/base"
-	dfdaemongrpc "d7y.io/dragonfly/v2/internal/rpc/dfdaemon"
-	dfdaemonserver "d7y.io/dragonfly/v2/internal/rpc/dfdaemon/server"
-	"d7y.io/dragonfly/v2/internal/rpc/scheduler"
+	"d7y.io/dragonfly/v2/pkg/rpc"
+	"d7y.io/dragonfly/v2/pkg/rpc/base"
+	dfdaemongrpc "d7y.io/dragonfly/v2/pkg/rpc/dfdaemon"
+	dfdaemonserver "d7y.io/dragonfly/v2/pkg/rpc/dfdaemon/server"
+	"d7y.io/dragonfly/v2/pkg/rpc/scheduler"
 )
 
 type Manager interface {
diff --git a/client/daemon/storage/local_storage.go b/client/daemon/storage/local_storage.go
index 0c44aa1f..c862c1f1 100644
--- a/client/daemon/storage/local_storage.go
+++ b/client/daemon/storage/local_storage.go
@@ -29,7 +29,7 @@ import (
 	"d7y.io/dragonfly/v2/client/clientutil"
 	"d7y.io/dragonfly/v2/internal/dferrors"
 	logger "d7y.io/dragonfly/v2/internal/dflog"
-	"d7y.io/dragonfly/v2/internal/rpc/base"
+	"d7y.io/dragonfly/v2/pkg/rpc/base"
 	"d7y.io/dragonfly/v2/pkg/util/digestutils"
 	"go.uber.org/atomic"
 )
diff --git a/client/daemon/storage/metadata.go b/client/daemon/storage/metadata.go
index 64e6427f..b584b2fc 100644
--- a/client/daemon/storage/metadata.go
+++ b/client/daemon/storage/metadata.go
@@ -20,7 +20,7 @@ import (
 	"io"
 
 	"d7y.io/dragonfly/v2/client/clientutil"
-	"d7y.io/dragonfly/v2/internal/rpc/base"
+	"d7y.io/dragonfly/v2/pkg/rpc/base"
 )
 
 type persistentMetadata struct {
diff --git a/client/daemon/storage/storage_manager.go b/client/daemon/storage/storage_manager.go
index a9fe6f13..1acbe169 100644
--- a/client/daemon/storage/storage_manager.go
+++ b/client/daemon/storage/storage_manager.go
@@ -40,7 +40,7 @@ import (
 	"d7y.io/dragonfly/v2/client/config"
 	"d7y.io/dragonfly/v2/client/daemon/gc"
 	logger "d7y.io/dragonfly/v2/internal/dflog"
-	"d7y.io/dragonfly/v2/internal/rpc/base"
+	"d7y.io/dragonfly/v2/pkg/rpc/base"
 )
 
 type TaskStorageDriver interface {
diff --git a/client/daemon/transport/transport.go b/client/daemon/transport/transport.go
index 891619ba..0556e240 100644
--- a/client/daemon/transport/transport.go
+++ b/client/daemon/transport/transport.go
@@ -28,8 +28,8 @@ import (
 	"d7y.io/dragonfly/v2/client/config"
 	"d7y.io/dragonfly/v2/client/daemon/peer"
 	logger "d7y.io/dragonfly/v2/internal/dflog"
-	"d7y.io/dragonfly/v2/internal/rpc/base"
-	"d7y.io/dragonfly/v2/internal/rpc/scheduler"
+	"d7y.io/dragonfly/v2/pkg/rpc/base"
+	"d7y.io/dragonfly/v2/pkg/rpc/scheduler"
 )
 
 var (
diff --git a/client/dfget/dfget.go b/client/dfget/dfget.go
index 56c0cd56..fcdf3e02 100644
--- a/client/dfget/dfget.go
+++ b/client/dfget/dfget.go
@@ -29,14 +29,14 @@ import (
 	"d7y.io/dragonfly/v2/client/config"
 	"d7y.io/dragonfly/v2/internal/dferrors"
 	logger "d7y.io/dragonfly/v2/internal/dflog"
-	"d7y.io/dragonfly/v2/internal/rpc/base"
-	dfdaemongrpc "d7y.io/dragonfly/v2/internal/rpc/dfdaemon"
 	"d7y.io/dragonfly/v2/pkg/basic"
+	"d7y.io/dragonfly/v2/pkg/rpc/base"
+	dfdaemongrpc "d7y.io/dragonfly/v2/pkg/rpc/dfdaemon"
 	"d7y.io/dragonfly/v2/pkg/source"
 
 	// Init daemon rpc client
-	_ "d7y.io/dragonfly/v2/internal/rpc/dfdaemon/client"
-	dfclient "d7y.io/dragonfly/v2/internal/rpc/dfdaemon/client"
+	_ "d7y.io/dragonfly/v2/pkg/rpc/dfdaemon/client"
+	dfclient "d7y.io/dragonfly/v2/pkg/rpc/dfdaemon/client"
 	"github.com/go-http-utils/headers"
 )
 
diff --git a/cmd/dfget/cmd/daemon.go b/cmd/dfget/cmd/daemon.go
index 84f6fdfe..60c5ff0e 100644
--- a/cmd/dfget/cmd/daemon.go
+++ b/cmd/dfget/cmd/daemon.go
@@ -27,8 +27,8 @@ import (
 	logger "d7y.io/dragonfly/v2/internal/dflog"
 	"d7y.io/dragonfly/v2/internal/dflog/logcore"
 	"d7y.io/dragonfly/v2/internal/dfpath"
-	"d7y.io/dragonfly/v2/internal/rpc/dfdaemon/client"
 	"d7y.io/dragonfly/v2/pkg/basic/dfnet"
+	"d7y.io/dragonfly/v2/pkg/rpc/dfdaemon/client"
 	"github.com/gofrs/flock"
 	"github.com/pkg/errors"
 	"github.com/spf13/cobra"
diff --git a/cmd/dfget/cmd/root.go b/cmd/dfget/cmd/root.go
index d3a7cb86..7e2bbf3a 100644
--- a/cmd/dfget/cmd/root.go
+++ b/cmd/dfget/cmd/root.go
@@ -32,8 +32,8 @@ import (
 	logger "d7y.io/dragonfly/v2/internal/dflog"
 	"d7y.io/dragonfly/v2/internal/dflog/logcore"
 	"d7y.io/dragonfly/v2/internal/dfpath"
-	"d7y.io/dragonfly/v2/internal/rpc/dfdaemon/client"
 	"d7y.io/dragonfly/v2/pkg/basic/dfnet"
+	"d7y.io/dragonfly/v2/pkg/rpc/dfdaemon/client"
 	"d7y.io/dragonfly/v2/pkg/unit"
 	"github.com/gofrs/flock"
 	"github.com/pkg/errors"
diff --git a/hack/protoc.sh b/hack/protoc.sh
index 23da8a4d..b6118177 100755
--- a/hack/protoc.sh
+++ b/hack/protoc.sh
@@ -6,11 +6,11 @@ echo "work dir:$SRC"
 if protoc -I="$SRC" \
   --go_out "$SRC" --go_opt paths=source_relative \
   --go-grpc_out "$SRC" --go-grpc_opt paths=source_relative \
-  "$SRC"/internal/rpc/base/*.proto \
-  "$SRC"/internal/rpc/cdnsystem/*.proto \
-  "$SRC"/internal/rpc/dfdaemon/*.proto \
-  "$SRC"/internal/rpc/scheduler/*.proto \
-  "$SRC"/internal/rpc/manager/*.proto; then
+  "$SRC"/pkg/rpc/base/*.proto \
+  "$SRC"/pkg/rpc/cdnsystem/*.proto \
+  "$SRC"/pkg/rpc/dfdaemon/*.proto \
+  "$SRC"/pkg/rpc/scheduler/*.proto \
+  "$SRC"/pkg/rpc/manager/*.proto; then
   echo "generate grpc code success"
   if cd "$SRC" && go mod tidy; then
     echo "go mod tidy success"
diff --git a/internal/dfcodes/rpc_code.go b/internal/dfcodes/rpc_code.go
index d564a7ca..1b7564bd 100644
--- a/internal/dfcodes/rpc_code.go
+++ b/internal/dfcodes/rpc_code.go
@@ -16,7 +16,7 @@
 
 package dfcodes
 
-import "d7y.io/dragonfly/v2/internal/rpc/base"
+import "d7y.io/dragonfly/v2/pkg/rpc/base"
 
 // rpc code
 const (
diff --git a/internal/dferrors/error.go b/internal/dferrors/error.go
index 950f55cd..ea418a5c 100644
--- a/internal/dferrors/error.go
+++ b/internal/dferrors/error.go
@@ -19,7 +19,7 @@ package dferrors
 import (
 	"fmt"
 
-	"d7y.io/dragonfly/v2/internal/rpc/base"
+	"d7y.io/dragonfly/v2/pkg/rpc/base"
 	"github.com/pkg/errors"
 )
 
diff --git a/internal/idgen/task_id.go b/internal/idgen/task_id.go
index f9eb86b3..f665b67a 100644
--- a/internal/idgen/task_id.go
+++ b/internal/idgen/task_id.go
@@ -20,7 +20,7 @@ import (
 	"hash/crc32"
 	"strings"
 
-	"d7y.io/dragonfly/v2/internal/rpc/base"
+	"d7y.io/dragonfly/v2/pkg/rpc/base"
 	"d7y.io/dragonfly/v2/pkg/util/digestutils"
 	"d7y.io/dragonfly/v2/pkg/util/net/urlutils"
 )
diff --git a/manager/server/server.go b/manager/server/server.go
index c81efef1..a9a85ede 100644
--- a/manager/server/server.go
+++ b/manager/server/server.go
@@ -21,12 +21,12 @@ import (
 	"net/http"
 
 	logger "d7y.io/dragonfly/v2/internal/dflog"
-	"d7y.io/dragonfly/v2/internal/rpc"
-	"d7y.io/dragonfly/v2/internal/rpc/manager"
 	"d7y.io/dragonfly/v2/manager/cache"
 	"d7y.io/dragonfly/v2/manager/config"
 	"d7y.io/dragonfly/v2/manager/database"
 	"d7y.io/dragonfly/v2/manager/service"
+	"d7y.io/dragonfly/v2/pkg/rpc"
+	"d7y.io/dragonfly/v2/pkg/rpc/manager"
 	"golang.org/x/sync/errgroup"
 	"google.golang.org/grpc"
 )
diff --git a/manager/service/service_grpc.go b/manager/service/service_grpc.go
index 397e4820..75d50aff 100644
--- a/manager/service/service_grpc.go
+++ b/manager/service/service_grpc.go
@@ -5,10 +5,10 @@ import (
 	"io"
 
 	logger "d7y.io/dragonfly/v2/internal/dflog"
-	"d7y.io/dragonfly/v2/internal/rpc/manager"
 	"d7y.io/dragonfly/v2/manager/cache"
 	"d7y.io/dragonfly/v2/manager/database"
 	"d7y.io/dragonfly/v2/manager/model"
+	"d7y.io/dragonfly/v2/pkg/rpc/manager"
 	cachev8 "github.com/go-redis/cache/v8"
 	"github.com/go-redis/redis/v8"
 	"google.golang.org/grpc/codes"
diff --git a/internal/rpc/base/base.pb.go b/pkg/rpc/base/base.pb.go
similarity index 100%
rename from internal/rpc/base/base.pb.go
rename to pkg/rpc/base/base.pb.go
diff --git a/internal/rpc/base/base.proto b/pkg/rpc/base/base.proto
similarity index 100%
rename from internal/rpc/base/base.proto
rename to pkg/rpc/base/base.proto
diff --git a/internal/rpc/base/common/common.go b/pkg/rpc/base/common/common.go
similarity index 97%
rename from internal/rpc/base/common/common.go
rename to pkg/rpc/base/common/common.go
index e5f56a70..41cf88fc 100644
--- a/internal/rpc/base/common/common.go
+++ b/pkg/rpc/base/common/common.go
@@ -20,7 +20,7 @@ import (
 	"reflect"
 
 	"d7y.io/dragonfly/v2/internal/dfcodes"
-	"d7y.io/dragonfly/v2/internal/rpc/base"
+	"d7y.io/dragonfly/v2/pkg/rpc/base"
 	"google.golang.org/grpc/codes"
 	"google.golang.org/grpc/status"
 )
diff --git a/internal/rpc/cdnsystem/cdnsystem.pb.go b/pkg/rpc/cdnsystem/cdnsystem.pb.go
similarity index 99%
rename from internal/rpc/cdnsystem/cdnsystem.pb.go
rename to pkg/rpc/cdnsystem/cdnsystem.pb.go
index 3fa57d91..710c530e 100644
--- a/internal/rpc/cdnsystem/cdnsystem.pb.go
+++ b/pkg/rpc/cdnsystem/cdnsystem.pb.go
@@ -22,7 +22,7 @@
 package cdnsystem
 
 import (
-	base "d7y.io/dragonfly/v2/internal/rpc/base"
+	base "d7y.io/dragonfly/v2/pkg/rpc/base"
 	proto "github.com/golang/protobuf/proto"
 	protoreflect "google.golang.org/protobuf/reflect/protoreflect"
 	protoimpl "google.golang.org/protobuf/runtime/protoimpl"
diff --git a/internal/rpc/cdnsystem/cdnsystem.proto b/pkg/rpc/cdnsystem/cdnsystem.proto
similarity index 100%
rename from internal/rpc/cdnsystem/cdnsystem.proto
rename to pkg/rpc/cdnsystem/cdnsystem.proto
diff --git a/internal/rpc/cdnsystem/cdnsystem_grpc.pb.go b/pkg/rpc/cdnsystem/cdnsystem_grpc.pb.go
similarity index 99%
rename from internal/rpc/cdnsystem/cdnsystem_grpc.pb.go
rename to pkg/rpc/cdnsystem/cdnsystem_grpc.pb.go
index a4ef8a10..1dee9cd9 100644
--- a/internal/rpc/cdnsystem/cdnsystem_grpc.pb.go
+++ b/pkg/rpc/cdnsystem/cdnsystem_grpc.pb.go
@@ -4,7 +4,7 @@ package cdnsystem
 
 import (
 	context "context"
-	base "d7y.io/dragonfly/v2/internal/rpc/base"
+	base "d7y.io/dragonfly/v2/pkg/rpc/base"
 	grpc "google.golang.org/grpc"
 	codes "google.golang.org/grpc/codes"
 	status "google.golang.org/grpc/status"
diff --git a/internal/rpc/cdnsystem/client/client.go b/pkg/rpc/cdnsystem/client/client.go
similarity index 96%
rename from internal/rpc/cdnsystem/client/client.go
rename to pkg/rpc/cdnsystem/client/client.go
index 3bdcce4b..e9d7dd44 100644
--- a/internal/rpc/cdnsystem/client/client.go
+++ b/pkg/rpc/cdnsystem/client/client.go
@@ -22,10 +22,10 @@ import (
 	"time"
 
 	logger "d7y.io/dragonfly/v2/internal/dflog"
-	"d7y.io/dragonfly/v2/internal/rpc"
-	"d7y.io/dragonfly/v2/internal/rpc/base"
-	"d7y.io/dragonfly/v2/internal/rpc/cdnsystem"
 	"d7y.io/dragonfly/v2/pkg/basic/dfnet"
+	"d7y.io/dragonfly/v2/pkg/rpc"
+	"d7y.io/dragonfly/v2/pkg/rpc/base"
+	"d7y.io/dragonfly/v2/pkg/rpc/cdnsystem"
 	"github.com/pkg/errors"
 	"google.golang.org/grpc"
 )
diff --git a/internal/rpc/cdnsystem/client/piece_seed_stream.go b/pkg/rpc/cdnsystem/client/piece_seed_stream.go
similarity index 98%
rename from internal/rpc/cdnsystem/client/piece_seed_stream.go
rename to pkg/rpc/cdnsystem/client/piece_seed_stream.go
index 4743e4df..21fca81c 100644
--- a/internal/rpc/cdnsystem/client/piece_seed_stream.go
+++ b/pkg/rpc/cdnsystem/client/piece_seed_stream.go
@@ -21,8 +21,8 @@ import (
 	"io"
 
 	logger "d7y.io/dragonfly/v2/internal/dflog"
-	"d7y.io/dragonfly/v2/internal/rpc"
-	"d7y.io/dragonfly/v2/internal/rpc/cdnsystem"
+	"d7y.io/dragonfly/v2/pkg/rpc"
+	"d7y.io/dragonfly/v2/pkg/rpc/cdnsystem"
 	"github.com/pkg/errors"
 	"google.golang.org/grpc"
 	"google.golang.org/grpc/codes"
diff --git a/internal/rpc/cdnsystem/server/server.go b/pkg/rpc/cdnsystem/server/server.go
similarity index 96%
rename from internal/rpc/cdnsystem/server/server.go
rename to pkg/rpc/cdnsystem/server/server.go
index 232cc5a8..2d5b6603 100644
--- a/internal/rpc/cdnsystem/server/server.go
+++ b/pkg/rpc/cdnsystem/server/server.go
@@ -22,9 +22,9 @@ import (
 
 	"d7y.io/dragonfly/v2/internal/dferrors"
 	logger "d7y.io/dragonfly/v2/internal/dflog"
-	"d7y.io/dragonfly/v2/internal/rpc"
-	"d7y.io/dragonfly/v2/internal/rpc/base"
-	"d7y.io/dragonfly/v2/internal/rpc/cdnsystem"
+	"d7y.io/dragonfly/v2/pkg/rpc"
+	"d7y.io/dragonfly/v2/pkg/rpc/base"
+	"d7y.io/dragonfly/v2/pkg/rpc/cdnsystem"
 	"d7y.io/dragonfly/v2/pkg/safe"
 	"d7y.io/dragonfly/v2/pkg/util/net/iputils"
 	"go.uber.org/zap"
diff --git a/internal/rpc/client.go b/pkg/rpc/client.go
similarity index 100%
rename from internal/rpc/client.go
rename to pkg/rpc/client.go
diff --git a/internal/rpc/client_util.go b/pkg/rpc/client_util.go
similarity index 99%
rename from internal/rpc/client_util.go
rename to pkg/rpc/client_util.go
index c1893c4e..3c8657f8 100644
--- a/internal/rpc/client_util.go
+++ b/pkg/rpc/client_util.go
@@ -27,7 +27,7 @@ import (
 	"d7y.io/dragonfly/v2/internal/dfcodes"
 	"d7y.io/dragonfly/v2/internal/dferrors"
 	logger "d7y.io/dragonfly/v2/internal/dflog"
-	"d7y.io/dragonfly/v2/internal/rpc/base"
+	"d7y.io/dragonfly/v2/pkg/rpc/base"
 	"d7y.io/dragonfly/v2/pkg/util/mathutils"
 )
 
diff --git a/internal/rpc/dfdaemon/client/client.go b/pkg/rpc/dfdaemon/client/client.go
similarity index 97%
rename from internal/rpc/dfdaemon/client/client.go
rename to pkg/rpc/dfdaemon/client/client.go
index 5cd8b824..827f1a06 100644
--- a/internal/rpc/dfdaemon/client/client.go
+++ b/pkg/rpc/dfdaemon/client/client.go
@@ -23,10 +23,10 @@ import (
 	"time"
 
 	"d7y.io/dragonfly/v2/internal/idgen"
-	"d7y.io/dragonfly/v2/internal/rpc"
-	"d7y.io/dragonfly/v2/internal/rpc/base"
-	"d7y.io/dragonfly/v2/internal/rpc/dfdaemon"
 	"d7y.io/dragonfly/v2/pkg/basic/dfnet"
+	"d7y.io/dragonfly/v2/pkg/rpc"
+	"d7y.io/dragonfly/v2/pkg/rpc/base"
+	"d7y.io/dragonfly/v2/pkg/rpc/dfdaemon"
 	"github.com/golang/protobuf/ptypes/empty"
 	"github.com/google/uuid"
 	"github.com/pkg/errors"
diff --git a/internal/rpc/dfdaemon/client/down_result_stream.go b/pkg/rpc/dfdaemon/client/down_result_stream.go
similarity index 98%
rename from internal/rpc/dfdaemon/client/down_result_stream.go
rename to pkg/rpc/dfdaemon/client/down_result_stream.go
index b49a6090..d62d8f39 100644
--- a/internal/rpc/dfdaemon/client/down_result_stream.go
+++ b/pkg/rpc/dfdaemon/client/down_result_stream.go
@@ -21,8 +21,8 @@ import (
 	"io"
 
 	logger "d7y.io/dragonfly/v2/internal/dflog"
-	"d7y.io/dragonfly/v2/internal/rpc"
-	"d7y.io/dragonfly/v2/internal/rpc/dfdaemon"
+	"d7y.io/dragonfly/v2/pkg/rpc"
+	"d7y.io/dragonfly/v2/pkg/rpc/dfdaemon"
 	"github.com/pkg/errors"
 	"google.golang.org/grpc"
 	"google.golang.org/grpc/codes"
diff --git a/internal/rpc/dfdaemon/client/peer.go b/pkg/rpc/dfdaemon/client/peer.go
similarity index 87%
rename from internal/rpc/dfdaemon/client/peer.go
rename to pkg/rpc/dfdaemon/client/peer.go
index 8e51f18c..f00ec329 100644
--- a/internal/rpc/dfdaemon/client/peer.go
+++ b/pkg/rpc/dfdaemon/client/peer.go
@@ -21,12 +21,12 @@ import (
 	"fmt"
 	"strings"
 
-	"d7y.io/dragonfly/v2/internal/rpc"
-	"d7y.io/dragonfly/v2/internal/rpc/base"
-	"d7y.io/dragonfly/v2/internal/rpc/base/common"
-	cdnclient "d7y.io/dragonfly/v2/internal/rpc/cdnsystem/client"
-	"d7y.io/dragonfly/v2/internal/rpc/scheduler"
 	"d7y.io/dragonfly/v2/pkg/basic/dfnet"
+	"d7y.io/dragonfly/v2/pkg/rpc"
+	"d7y.io/dragonfly/v2/pkg/rpc/base"
+	"d7y.io/dragonfly/v2/pkg/rpc/base/common"
+	cdnclient "d7y.io/dragonfly/v2/pkg/rpc/cdnsystem/client"
+	"d7y.io/dragonfly/v2/pkg/rpc/scheduler"
 	"google.golang.org/grpc"
 )
 
diff --git a/internal/rpc/dfdaemon/dfdaemon.pb.go b/pkg/rpc/dfdaemon/dfdaemon.pb.go
similarity index 99%
rename from internal/rpc/dfdaemon/dfdaemon.pb.go
rename to pkg/rpc/dfdaemon/dfdaemon.pb.go
index 4ac967e0..f1539fb5 100644
--- a/internal/rpc/dfdaemon/dfdaemon.pb.go
+++ b/pkg/rpc/dfdaemon/dfdaemon.pb.go
@@ -22,7 +22,7 @@
 package dfdaemon
 
 import (
-	base "d7y.io/dragonfly/v2/internal/rpc/base"
+	base "d7y.io/dragonfly/v2/pkg/rpc/base"
 	proto "github.com/golang/protobuf/proto"
 	protoreflect "google.golang.org/protobuf/reflect/protoreflect"
 	protoimpl "google.golang.org/protobuf/runtime/protoimpl"
diff --git a/internal/rpc/dfdaemon/dfdaemon.proto b/pkg/rpc/dfdaemon/dfdaemon.proto
similarity index 100%
rename from internal/rpc/dfdaemon/dfdaemon.proto
rename to pkg/rpc/dfdaemon/dfdaemon.proto
diff --git a/internal/rpc/dfdaemon/dfdaemon_grpc.pb.go b/pkg/rpc/dfdaemon/dfdaemon_grpc.pb.go
similarity index 99%
rename from internal/rpc/dfdaemon/dfdaemon_grpc.pb.go
rename to pkg/rpc/dfdaemon/dfdaemon_grpc.pb.go
index c0152c44..fe1895d1 100644
--- a/internal/rpc/dfdaemon/dfdaemon_grpc.pb.go
+++ b/pkg/rpc/dfdaemon/dfdaemon_grpc.pb.go
@@ -4,7 +4,7 @@ package dfdaemon
 
 import (
 	context "context"
-	base "d7y.io/dragonfly/v2/internal/rpc/base"
+	base "d7y.io/dragonfly/v2/pkg/rpc/base"
 	grpc "google.golang.org/grpc"
 	codes "google.golang.org/grpc/codes"
 	status "google.golang.org/grpc/status"
diff --git a/internal/rpc/dfdaemon/server/server.go b/pkg/rpc/dfdaemon/server/server.go
similarity index 96%
rename from internal/rpc/dfdaemon/server/server.go
rename to pkg/rpc/dfdaemon/server/server.go
index 17908c21..b0247798 100644
--- a/internal/rpc/dfdaemon/server/server.go
+++ b/pkg/rpc/dfdaemon/server/server.go
@@ -22,9 +22,9 @@ import (
 
 	"d7y.io/dragonfly/v2/internal/dferrors"
 	logger "d7y.io/dragonfly/v2/internal/dflog"
-	"d7y.io/dragonfly/v2/internal/rpc"
-	"d7y.io/dragonfly/v2/internal/rpc/base"
-	"d7y.io/dragonfly/v2/internal/rpc/dfdaemon"
+	"d7y.io/dragonfly/v2/pkg/rpc"
+	"d7y.io/dragonfly/v2/pkg/rpc/base"
+	"d7y.io/dragonfly/v2/pkg/rpc/dfdaemon"
 	"d7y.io/dragonfly/v2/pkg/safe"
 	"github.com/golang/protobuf/ptypes/empty"
 	"google.golang.org/grpc"
diff --git a/internal/rpc/examples/cdnsystem/client/main.go b/pkg/rpc/examples/cdnsystem/client/main.go
similarity index 91%
rename from internal/rpc/examples/cdnsystem/client/main.go
rename to pkg/rpc/examples/cdnsystem/client/main.go
index 51989e0d..abc72594 100644
--- a/internal/rpc/examples/cdnsystem/client/main.go
+++ b/pkg/rpc/examples/cdnsystem/client/main.go
@@ -20,14 +20,14 @@ import (
 	"sync"
 
 	"d7y.io/dragonfly/v2/internal/dflog/logcore"
-	_ "d7y.io/dragonfly/v2/internal/rpc/scheduler/server"
 	"d7y.io/dragonfly/v2/pkg/basic/dfnet"
+	_ "d7y.io/dragonfly/v2/pkg/rpc/scheduler/server"
 
 	"context"
 	"fmt"
 
-	"d7y.io/dragonfly/v2/internal/rpc/cdnsystem"
-	"d7y.io/dragonfly/v2/internal/rpc/cdnsystem/client"
+	"d7y.io/dragonfly/v2/pkg/rpc/cdnsystem"
+	"d7y.io/dragonfly/v2/pkg/rpc/cdnsystem/client"
 )
 
 func main() {
diff --git a/internal/rpc/examples/cdnsystem/server/main.go b/pkg/rpc/examples/cdnsystem/server/main.go
similarity index 89%
rename from internal/rpc/examples/cdnsystem/server/main.go
rename to pkg/rpc/examples/cdnsystem/server/main.go
index d442b034..1b732f67 100644
--- a/internal/rpc/examples/cdnsystem/server/main.go
+++ b/pkg/rpc/examples/cdnsystem/server/main.go
@@ -22,10 +22,10 @@ import (
 	"time"
 
 	"d7y.io/dragonfly/v2/internal/dflog/logcore"
-	"d7y.io/dragonfly/v2/internal/rpc"
-	"d7y.io/dragonfly/v2/internal/rpc/base"
-	"d7y.io/dragonfly/v2/internal/rpc/cdnsystem"
-	_ "d7y.io/dragonfly/v2/internal/rpc/cdnsystem/server"
+	"d7y.io/dragonfly/v2/pkg/rpc"
+	"d7y.io/dragonfly/v2/pkg/rpc/base"
+	"d7y.io/dragonfly/v2/pkg/rpc/cdnsystem"
+	_ "d7y.io/dragonfly/v2/pkg/rpc/cdnsystem/server"
 	"d7y.io/dragonfly/v2/pkg/safe"
 )
 
diff --git a/internal/rpc/manager/manager.pb.go b/pkg/rpc/manager/manager.pb.go
similarity index 100%
rename from internal/rpc/manager/manager.pb.go
rename to pkg/rpc/manager/manager.pb.go
diff --git a/internal/rpc/manager/manager.pb.validate.go b/pkg/rpc/manager/manager.pb.validate.go
similarity index 100%
rename from internal/rpc/manager/manager.pb.validate.go
rename to pkg/rpc/manager/manager.pb.validate.go
diff --git a/internal/rpc/manager/manager.proto b/pkg/rpc/manager/manager.proto
similarity index 100%
rename from internal/rpc/manager/manager.proto
rename to pkg/rpc/manager/manager.proto
diff --git a/internal/rpc/manager/manager_grpc.pb.go b/pkg/rpc/manager/manager_grpc.pb.go
similarity index 100%
rename from internal/rpc/manager/manager_grpc.pb.go
rename to pkg/rpc/manager/manager_grpc.pb.go
diff --git a/internal/rpc/scheduler/client/client.go b/pkg/rpc/scheduler/client/client.go
similarity index 98%
rename from internal/rpc/scheduler/client/client.go
rename to pkg/rpc/scheduler/client/client.go
index f45e032a..1ac9c338 100644
--- a/internal/rpc/scheduler/client/client.go
+++ b/pkg/rpc/scheduler/client/client.go
@@ -27,10 +27,10 @@ import (
 	"google.golang.org/grpc"
 
 	logger "d7y.io/dragonfly/v2/internal/dflog"
-	"d7y.io/dragonfly/v2/internal/rpc"
-	"d7y.io/dragonfly/v2/internal/rpc/base"
-	"d7y.io/dragonfly/v2/internal/rpc/scheduler"
 	"d7y.io/dragonfly/v2/pkg/basic/dfnet"
+	"d7y.io/dragonfly/v2/pkg/rpc"
+	"d7y.io/dragonfly/v2/pkg/rpc/base"
+	"d7y.io/dragonfly/v2/pkg/rpc/scheduler"
 )
 
 func GetClientByAddr(addrs []dfnet.NetAddr, opts ...grpc.DialOption) (SchedulerClient, error) {
diff --git a/internal/rpc/scheduler/client/peer_packet_stream.go b/pkg/rpc/scheduler/client/peer_packet_stream.go
similarity index 97%
rename from internal/rpc/scheduler/client/peer_packet_stream.go
rename to pkg/rpc/scheduler/client/peer_packet_stream.go
index 140a71e2..a62bbf01 100644
--- a/internal/rpc/scheduler/client/peer_packet_stream.go
+++ b/pkg/rpc/scheduler/client/peer_packet_stream.go
@@ -26,9 +26,9 @@ import (
 	"google.golang.org/grpc/codes"
 	"google.golang.org/grpc/status"
 
-	"d7y.io/dragonfly/v2/internal/rpc"
-	"d7y.io/dragonfly/v2/internal/rpc/base/common"
-	"d7y.io/dragonfly/v2/internal/rpc/scheduler"
+	"d7y.io/dragonfly/v2/pkg/rpc"
+	"d7y.io/dragonfly/v2/pkg/rpc/base/common"
+	"d7y.io/dragonfly/v2/pkg/rpc/scheduler"
 )
 
 type PeerPacketStream interface {
diff --git a/internal/rpc/scheduler/scheduler.go b/pkg/rpc/scheduler/scheduler.go
similarity index 95%
rename from internal/rpc/scheduler/scheduler.go
rename to pkg/rpc/scheduler/scheduler.go
index 053d0d04..8215d10f 100644
--- a/internal/rpc/scheduler/scheduler.go
+++ b/pkg/rpc/scheduler/scheduler.go
@@ -17,7 +17,7 @@
 package scheduler
 
 import (
-	"d7y.io/dragonfly/v2/internal/rpc/base/common"
+	"d7y.io/dragonfly/v2/pkg/rpc/base/common"
 )
 
 func NewZeroPieceResult(taskID, peerID string) *PieceResult {
diff --git a/internal/rpc/scheduler/scheduler.pb.go b/pkg/rpc/scheduler/scheduler.pb.go
similarity index 99%
rename from internal/rpc/scheduler/scheduler.pb.go
rename to pkg/rpc/scheduler/scheduler.pb.go
index bbf1e614..7fa81737 100644
--- a/internal/rpc/scheduler/scheduler.pb.go
+++ b/pkg/rpc/scheduler/scheduler.pb.go
@@ -22,7 +22,7 @@
 package scheduler
 
 import (
-	base "d7y.io/dragonfly/v2/internal/rpc/base"
+	base "d7y.io/dragonfly/v2/pkg/rpc/base"
 	proto "github.com/golang/protobuf/proto"
 	protoreflect "google.golang.org/protobuf/reflect/protoreflect"
 	protoimpl "google.golang.org/protobuf/runtime/protoimpl"
diff --git a/internal/rpc/scheduler/scheduler.proto b/pkg/rpc/scheduler/scheduler.proto
similarity index 100%
rename from internal/rpc/scheduler/scheduler.proto
rename to pkg/rpc/scheduler/scheduler.proto
diff --git a/internal/rpc/scheduler/scheduler_grpc.pb.go b/pkg/rpc/scheduler/scheduler_grpc.pb.go
similarity index 100%
rename from internal/rpc/scheduler/scheduler_grpc.pb.go
rename to pkg/rpc/scheduler/scheduler_grpc.pb.go
diff --git a/internal/rpc/scheduler/server/server.go b/pkg/rpc/scheduler/server/server.go
similarity index 96%
rename from internal/rpc/scheduler/server/server.go
rename to pkg/rpc/scheduler/server/server.go
index cfeece3b..9d55eb5f 100644
--- a/internal/rpc/scheduler/server/server.go
+++ b/pkg/rpc/scheduler/server/server.go
@@ -22,9 +22,9 @@ import (
 	"github.com/golang/protobuf/ptypes/empty"
 
 	logger "d7y.io/dragonfly/v2/internal/dflog"
-	"d7y.io/dragonfly/v2/internal/rpc"
-	"d7y.io/dragonfly/v2/internal/rpc/base"
-	"d7y.io/dragonfly/v2/internal/rpc/scheduler"
+	"d7y.io/dragonfly/v2/pkg/rpc"
+	"d7y.io/dragonfly/v2/pkg/rpc/base"
+	"d7y.io/dragonfly/v2/pkg/rpc/scheduler"
 	"d7y.io/dragonfly/v2/pkg/util/net/iputils"
 	"go.uber.org/zap"
 	"google.golang.org/grpc"
diff --git a/internal/rpc/server.go b/pkg/rpc/server.go
similarity index 99%
rename from internal/rpc/server.go
rename to pkg/rpc/server.go
index 66f9cfa0..1b7ce2cf 100644
--- a/internal/rpc/server.go
+++ b/pkg/rpc/server.go
@@ -35,8 +35,8 @@ import (
 
 	"d7y.io/dragonfly/v2/internal/dferrors"
 	logger "d7y.io/dragonfly/v2/internal/dflog"
-	"d7y.io/dragonfly/v2/internal/rpc/base/common"
 	"d7y.io/dragonfly/v2/pkg/basic/dfnet"
+	"d7y.io/dragonfly/v2/pkg/rpc/base/common"
 	"d7y.io/dragonfly/v2/pkg/util/fileutils"
 	"d7y.io/dragonfly/v2/pkg/util/stringutils"
 )
diff --git a/internal/rpc/server_listen.go b/pkg/rpc/server_listen.go
similarity index 100%
rename from internal/rpc/server_listen.go
rename to pkg/rpc/server_listen.go
diff --git a/scheduler/config/dynconfig.go b/scheduler/config/dynconfig.go
index 7743cf0d..902f7cec 100644
--- a/scheduler/config/dynconfig.go
+++ b/scheduler/config/dynconfig.go
@@ -27,7 +27,7 @@ import (
 	logger "d7y.io/dragonfly/v2/internal/dflog"
 	"d7y.io/dragonfly/v2/internal/dfpath"
 	dc "d7y.io/dragonfly/v2/internal/dynconfig"
-	"d7y.io/dragonfly/v2/internal/rpc/manager"
+	"d7y.io/dragonfly/v2/pkg/rpc/manager"
 	"d7y.io/dragonfly/v2/pkg/util/net/iputils"
 )
 
diff --git a/scheduler/config/mocks/manager_client_mock.go b/scheduler/config/mocks/manager_client_mock.go
index add41389..e758621d 100644
--- a/scheduler/config/mocks/manager_client_mock.go
+++ b/scheduler/config/mocks/manager_client_mock.go
@@ -8,7 +8,7 @@ import (
 	context "context"
 	reflect "reflect"
 
-	manager "d7y.io/dragonfly/v2/internal/rpc/manager"
+	manager "d7y.io/dragonfly/v2/pkg/rpc/manager"
 	gomock "github.com/golang/mock/gomock"
 	grpc "google.golang.org/grpc"
 	metadata "google.golang.org/grpc/metadata"
diff --git a/scheduler/manager/cdn_manager.go b/scheduler/manager/cdn_manager.go
index 988674bf..990f7c7a 100644
--- a/scheduler/manager/cdn_manager.go
+++ b/scheduler/manager/cdn_manager.go
@@ -28,15 +28,15 @@ import (
 	"d7y.io/dragonfly/v2/internal/dfcodes"
 	"d7y.io/dragonfly/v2/internal/dferrors"
 	logger "d7y.io/dragonfly/v2/internal/dflog"
-	"d7y.io/dragonfly/v2/internal/rpc/base"
-	"d7y.io/dragonfly/v2/internal/rpc/manager"
-	"d7y.io/dragonfly/v2/internal/rpc/scheduler"
 	"d7y.io/dragonfly/v2/pkg/basic/dfnet"
+	"d7y.io/dragonfly/v2/pkg/rpc/base"
+	"d7y.io/dragonfly/v2/pkg/rpc/manager"
+	"d7y.io/dragonfly/v2/pkg/rpc/scheduler"
 	"d7y.io/dragonfly/v2/pkg/safe"
 	"d7y.io/dragonfly/v2/scheduler/config"
 
-	"d7y.io/dragonfly/v2/internal/rpc/cdnsystem"
-	"d7y.io/dragonfly/v2/internal/rpc/cdnsystem/client"
+	"d7y.io/dragonfly/v2/pkg/rpc/cdnsystem"
+	"d7y.io/dragonfly/v2/pkg/rpc/cdnsystem/client"
 	"d7y.io/dragonfly/v2/scheduler/types"
 )
 
diff --git a/scheduler/server/scheduler_server.go b/scheduler/server/scheduler_server.go
index 50606ec2..78551a0e 100644
--- a/scheduler/server/scheduler_server.go
+++ b/scheduler/server/scheduler_server.go
@@ -24,8 +24,8 @@ import (
 	"d7y.io/dragonfly/v2/internal/dfcodes"
 	"d7y.io/dragonfly/v2/internal/dferrors"
 	logger "d7y.io/dragonfly/v2/internal/dflog"
-	"d7y.io/dragonfly/v2/internal/rpc/base"
-	"d7y.io/dragonfly/v2/internal/rpc/scheduler"
+	"d7y.io/dragonfly/v2/pkg/rpc/base"
+	"d7y.io/dragonfly/v2/pkg/rpc/scheduler"
 	"d7y.io/dragonfly/v2/scheduler/config"
 	"d7y.io/dragonfly/v2/scheduler/service"
 	"d7y.io/dragonfly/v2/scheduler/service/worker"
diff --git a/scheduler/server/server.go b/scheduler/server/server.go
index b6410f1d..21b3889b 100644
--- a/scheduler/server/server.go
+++ b/scheduler/server/server.go
@@ -22,13 +22,13 @@ import (
 
 	logger "d7y.io/dragonfly/v2/internal/dflog"
 	"d7y.io/dragonfly/v2/internal/dynconfig"
-	"d7y.io/dragonfly/v2/internal/rpc"
-	"d7y.io/dragonfly/v2/internal/rpc/manager"
+	"d7y.io/dragonfly/v2/pkg/rpc"
+	"d7y.io/dragonfly/v2/pkg/rpc/manager"
 	"google.golang.org/grpc"
 
 	// Server registered to grpc
-	_ "d7y.io/dragonfly/v2/internal/rpc/scheduler/server"
 	"d7y.io/dragonfly/v2/pkg/retry"
+	_ "d7y.io/dragonfly/v2/pkg/rpc/scheduler/server" //nolint
 	"d7y.io/dragonfly/v2/pkg/util/net/iputils"
 	"d7y.io/dragonfly/v2/scheduler/config"
 	"d7y.io/dragonfly/v2/scheduler/service"
diff --git a/scheduler/service/service.go b/scheduler/service/service.go
index f19349ce..4c67d542 100644
--- a/scheduler/service/service.go
+++ b/scheduler/service/service.go
@@ -20,7 +20,7 @@ import (
 	"errors"
 
 	"d7y.io/dragonfly/v2/internal/idgen"
-	"d7y.io/dragonfly/v2/internal/rpc/base"
+	"d7y.io/dragonfly/v2/pkg/rpc/base"
 	"d7y.io/dragonfly/v2/scheduler/config"
 	"d7y.io/dragonfly/v2/scheduler/manager"
 	"d7y.io/dragonfly/v2/scheduler/scheduler"
diff --git a/scheduler/service/worker/client.go b/scheduler/service/worker/client.go
index d05466bd..2b2cd4b7 100644
--- a/scheduler/service/worker/client.go
+++ b/scheduler/service/worker/client.go
@@ -20,11 +20,11 @@ import (
 	"io"
 	"time"
 
-	"d7y.io/dragonfly/v2/internal/rpc/base/common"
+	"d7y.io/dragonfly/v2/pkg/rpc/base/common"
 
 	"d7y.io/dragonfly/v2/internal/dfcodes"
 	logger "d7y.io/dragonfly/v2/internal/dflog"
-	"d7y.io/dragonfly/v2/internal/rpc/scheduler"
+	"d7y.io/dragonfly/v2/pkg/rpc/scheduler"
 	"d7y.io/dragonfly/v2/scheduler/service"
 )
 
diff --git a/scheduler/service/worker/woker.go b/scheduler/service/worker/woker.go
index a77af146..77b92a38 100644
--- a/scheduler/service/worker/woker.go
+++ b/scheduler/service/worker/woker.go
@@ -26,7 +26,7 @@ import (
 
 	"d7y.io/dragonfly/v2/internal/dfcodes"
 	logger "d7y.io/dragonfly/v2/internal/dflog"
-	scheduler2 "d7y.io/dragonfly/v2/internal/rpc/scheduler"
+	scheduler2 "d7y.io/dragonfly/v2/pkg/rpc/scheduler"
 	"d7y.io/dragonfly/v2/scheduler/service"
 	"d7y.io/dragonfly/v2/scheduler/types"
 )
diff --git a/scheduler/service/worker/worker_group.go b/scheduler/service/worker/worker_group.go
index be532769..9f383b47 100644
--- a/scheduler/service/worker/worker_group.go
+++ b/scheduler/service/worker/worker_group.go
@@ -20,7 +20,7 @@ import (
 	"hash/crc32"
 
 	logger "d7y.io/dragonfly/v2/internal/dflog"
-	scheduler2 "d7y.io/dragonfly/v2/internal/rpc/scheduler"
+	scheduler2 "d7y.io/dragonfly/v2/pkg/rpc/scheduler"
 	"d7y.io/dragonfly/v2/scheduler/config"
 	"d7y.io/dragonfly/v2/scheduler/service"
 	"d7y.io/dragonfly/v2/scheduler/types"
diff --git a/scheduler/types/client.go b/scheduler/types/client.go
index 0d8ca8dc..db33cf84 100644
--- a/scheduler/types/client.go
+++ b/scheduler/types/client.go
@@ -16,7 +16,7 @@
 
 package types
 
-import "d7y.io/dragonfly/v2/internal/rpc/scheduler"
+import "d7y.io/dragonfly/v2/pkg/rpc/scheduler"
 
 type IClient interface {
 	Send(*scheduler.PeerPacket) error
diff --git a/scheduler/types/host.go b/scheduler/types/host.go
index e2093ef8..4ea706f7 100644
--- a/scheduler/types/host.go
+++ b/scheduler/types/host.go
@@ -20,7 +20,7 @@ import (
 	"sync"
 
 	logger "d7y.io/dragonfly/v2/internal/dflog"
-	"d7y.io/dragonfly/v2/internal/rpc/scheduler"
+	"d7y.io/dragonfly/v2/pkg/rpc/scheduler"
 )
 
 type HostType int
diff --git a/scheduler/types/peer_task.go b/scheduler/types/peer_task.go
index 784f1055..c158cf98 100644
--- a/scheduler/types/peer_task.go
+++ b/scheduler/types/peer_task.go
@@ -24,8 +24,8 @@ import (
 
 	"d7y.io/dragonfly/v2/internal/dfcodes"
 	"d7y.io/dragonfly/v2/internal/dferrors"
-	"d7y.io/dragonfly/v2/internal/rpc/base"
-	"d7y.io/dragonfly/v2/internal/rpc/scheduler"
+	"d7y.io/dragonfly/v2/pkg/rpc/base"
+	"d7y.io/dragonfly/v2/pkg/rpc/scheduler"
 )
 
 type PeerTaskStatus int8
diff --git a/scheduler/types/piece.go b/scheduler/types/piece.go
index 4492cc94..3a3147c2 100644
--- a/scheduler/types/piece.go
+++ b/scheduler/types/piece.go
@@ -17,7 +17,7 @@
 package types
 
 import (
-	"d7y.io/dragonfly/v2/internal/rpc/base"
+	"d7y.io/dragonfly/v2/pkg/rpc/base"
 )
 
 type WaitingType int
diff --git a/scheduler/types/task.go b/scheduler/types/task.go
index a5f15283..4a9b37d3 100644
--- a/scheduler/types/task.go
+++ b/scheduler/types/task.go
@@ -21,8 +21,8 @@ import (
 	"time"
 
 	"d7y.io/dragonfly/v2/internal/dferrors"
-	"d7y.io/dragonfly/v2/internal/rpc/base"
-	"d7y.io/dragonfly/v2/internal/rpc/scheduler"
+	"d7y.io/dragonfly/v2/pkg/rpc/base"
+	"d7y.io/dragonfly/v2/pkg/rpc/scheduler"
 	"d7y.io/dragonfly/v2/scheduler/metrics"
 )
 


Test patch:
diff --git a/cdnsystem/daemon/cdn/manager_test.go b/cdnsystem/daemon/cdn/manager_test.go
index 2d12e1b6..73960158 100644
--- a/cdnsystem/daemon/cdn/manager_test.go
+++ b/cdnsystem/daemon/cdn/manager_test.go
@@ -31,7 +31,7 @@ import (
 	"d7y.io/dragonfly/v2/cdnsystem/plugins"
 	"d7y.io/dragonfly/v2/cdnsystem/types"
 	"d7y.io/dragonfly/v2/internal/idgen"
-	"d7y.io/dragonfly/v2/internal/rpc/base"
+	"d7y.io/dragonfly/v2/pkg/rpc/base"
 	"d7y.io/dragonfly/v2/pkg/source"
 	sourceMock "d7y.io/dragonfly/v2/pkg/source/mock"
 	"d7y.io/dragonfly/v2/pkg/util/net/urlutils"
diff --git a/cdnsystem/daemon/task/manager_test.go b/cdnsystem/daemon/task/manager_test.go
index 20567c77..72bc89ea 100644
--- a/cdnsystem/daemon/task/manager_test.go
+++ b/cdnsystem/daemon/task/manager_test.go
@@ -24,7 +24,7 @@ import (
 	"d7y.io/dragonfly/v2/cdnsystem/daemon/mock"
 	"d7y.io/dragonfly/v2/cdnsystem/types"
 	"d7y.io/dragonfly/v2/internal/idgen"
-	"d7y.io/dragonfly/v2/internal/rpc/base"
+	"d7y.io/dragonfly/v2/pkg/rpc/base"
 	"github.com/golang/mock/gomock"
 	"github.com/stretchr/testify/suite"
 )
diff --git a/cdnsystem/server/service/cdn_seed_server_test.go b/cdnsystem/server/service/cdn_seed_server_test.go
index dfb32898..cb9325b4 100644
--- a/cdnsystem/server/service/cdn_seed_server_test.go
+++ b/cdnsystem/server/service/cdn_seed_server_test.go
@@ -24,8 +24,8 @@ import (
 	"d7y.io/dragonfly/v2/cdnsystem/config"
 	"d7y.io/dragonfly/v2/cdnsystem/daemon"
 	"d7y.io/dragonfly/v2/cdnsystem/types"
-	"d7y.io/dragonfly/v2/internal/rpc/base"
-	"d7y.io/dragonfly/v2/internal/rpc/cdnsystem"
+	"d7y.io/dragonfly/v2/pkg/rpc/base"
+	"d7y.io/dragonfly/v2/pkg/rpc/cdnsystem"
 )
 
 func TestCdnSeedServer_GetPieceTasks(t *testing.T) {
diff --git a/client/daemon/peer/peertask_file_test.go b/client/daemon/peer/peertask_file_test.go
index bcc14c5a..d5148f47 100644
--- a/client/daemon/peer/peertask_file_test.go
+++ b/client/daemon/peer/peertask_file_test.go
@@ -29,7 +29,7 @@ import (
 	"d7y.io/dragonfly/v2/client/clientutil"
 	"d7y.io/dragonfly/v2/client/config"
 	"d7y.io/dragonfly/v2/client/daemon/test"
-	"d7y.io/dragonfly/v2/internal/rpc/scheduler"
+	"d7y.io/dragonfly/v2/pkg/rpc/scheduler"
 	"d7y.io/dragonfly/v2/pkg/source"
 	sourceMock "d7y.io/dragonfly/v2/pkg/source/mock"
 	"github.com/golang/mock/gomock"
diff --git a/client/daemon/peer/peertask_manager_mock_test.go b/client/daemon/peer/peertask_manager_mock_test.go
index 16654381..fd0a0fb2 100644
--- a/client/daemon/peer/peertask_manager_mock_test.go
+++ b/client/daemon/peer/peertask_manager_mock_test.go
@@ -28,8 +28,8 @@ import (
 	gomock "github.com/golang/mock/gomock"
 
 	dflog "d7y.io/dragonfly/v2/internal/dflog"
-	base "d7y.io/dragonfly/v2/internal/rpc/base"
-	scheduler "d7y.io/dragonfly/v2/internal/rpc/scheduler"
+	base "d7y.io/dragonfly/v2/pkg/rpc/base"
+	scheduler "d7y.io/dragonfly/v2/pkg/rpc/scheduler"
 )
 
 // MockPeerTaskManager is a mock of PeerTaskManager interface
diff --git a/client/daemon/peer/peertask_manager_test.go b/client/daemon/peer/peertask_manager_test.go
index 38500aed..29875da8 100644
--- a/client/daemon/peer/peertask_manager_test.go
+++ b/client/daemon/peer/peertask_manager_test.go
@@ -40,12 +40,12 @@ import (
 	mock_daemon "d7y.io/dragonfly/v2/client/daemon/test/mock/daemon"
 	mock_scheduler "d7y.io/dragonfly/v2/client/daemon/test/mock/scheduler"
 	"d7y.io/dragonfly/v2/internal/dfcodes"
-	"d7y.io/dragonfly/v2/internal/rpc"
-	"d7y.io/dragonfly/v2/internal/rpc/base"
-	daemonserver "d7y.io/dragonfly/v2/internal/rpc/dfdaemon/server"
-	"d7y.io/dragonfly/v2/internal/rpc/scheduler"
-	schedulerclient "d7y.io/dragonfly/v2/internal/rpc/scheduler/client"
 	"d7y.io/dragonfly/v2/pkg/basic/dfnet"
+	"d7y.io/dragonfly/v2/pkg/rpc"
+	"d7y.io/dragonfly/v2/pkg/rpc/base"
+	daemonserver "d7y.io/dragonfly/v2/pkg/rpc/dfdaemon/server"
+	"d7y.io/dragonfly/v2/pkg/rpc/scheduler"
+	schedulerclient "d7y.io/dragonfly/v2/pkg/rpc/scheduler/client"
 )
 
 var _ daemonserver.DaemonServer = mock_daemon.NewMockDaemonServer(nil)
diff --git a/client/daemon/peer/peertask_stream_test.go b/client/daemon/peer/peertask_stream_test.go
index 0519d323..0abb40b9 100644
--- a/client/daemon/peer/peertask_stream_test.go
+++ b/client/daemon/peer/peertask_stream_test.go
@@ -33,7 +33,7 @@ import (
 	"d7y.io/dragonfly/v2/client/clientutil"
 	"d7y.io/dragonfly/v2/client/config"
 	"d7y.io/dragonfly/v2/client/daemon/test"
-	"d7y.io/dragonfly/v2/internal/rpc/scheduler"
+	"d7y.io/dragonfly/v2/pkg/rpc/scheduler"
 )
 
 func TestStreamPeerTask_BackSource_WithContentLength(t *testing.T) {
diff --git a/client/daemon/peer/piece_downloader_test.go b/client/daemon/peer/piece_downloader_test.go
index 006443f6..907e96fc 100644
--- a/client/daemon/peer/piece_downloader_test.go
+++ b/client/daemon/peer/piece_downloader_test.go
@@ -34,8 +34,8 @@ import (
 	"d7y.io/dragonfly/v2/client/clientutil"
 	"d7y.io/dragonfly/v2/client/daemon/test"
 	"d7y.io/dragonfly/v2/client/daemon/upload"
-	"d7y.io/dragonfly/v2/internal/rpc/base"
-	_ "d7y.io/dragonfly/v2/internal/rpc/dfdaemon/server"
+	"d7y.io/dragonfly/v2/pkg/rpc/base"
+	_ "d7y.io/dragonfly/v2/pkg/rpc/dfdaemon/server"
 )
 
 func TestPieceDownloader_DownloadPiece(t *testing.T) {
diff --git a/client/daemon/peer/piece_manager_test.go b/client/daemon/peer/piece_manager_test.go
index 7b773e80..63a1b4f3 100644
--- a/client/daemon/peer/piece_manager_test.go
+++ b/client/daemon/peer/piece_manager_test.go
@@ -39,9 +39,9 @@ import (
 	"d7y.io/dragonfly/v2/client/daemon/storage"
 	"d7y.io/dragonfly/v2/client/daemon/test"
 	logger "d7y.io/dragonfly/v2/internal/dflog"
-	"d7y.io/dragonfly/v2/internal/rpc/base"
-	_ "d7y.io/dragonfly/v2/internal/rpc/dfdaemon/server"
-	"d7y.io/dragonfly/v2/internal/rpc/scheduler"
+	"d7y.io/dragonfly/v2/pkg/rpc/base"
+	_ "d7y.io/dragonfly/v2/pkg/rpc/dfdaemon/server"
+	"d7y.io/dragonfly/v2/pkg/rpc/scheduler"
 	"d7y.io/dragonfly/v2/pkg/source/httpprotocol"
 )
 
diff --git a/client/daemon/service/manager_test.go b/client/daemon/service/manager_test.go
index 3ec09224..7bda72f0 100644
--- a/client/daemon/service/manager_test.go
+++ b/client/daemon/service/manager_test.go
@@ -33,13 +33,13 @@ import (
 	"d7y.io/dragonfly/v2/client/daemon/peer"
 	mock_peer "d7y.io/dragonfly/v2/client/daemon/test/mock/peer"
 	mock_storage "d7y.io/dragonfly/v2/client/daemon/test/mock/storage"
-	"d7y.io/dragonfly/v2/internal/rpc"
-	"d7y.io/dragonfly/v2/internal/rpc/base"
-	dfdaemongrpc "d7y.io/dragonfly/v2/internal/rpc/dfdaemon"
-	dfclient "d7y.io/dragonfly/v2/internal/rpc/dfdaemon/client"
-	_ "d7y.io/dragonfly/v2/internal/rpc/dfdaemon/server"
-	"d7y.io/dragonfly/v2/internal/rpc/scheduler"
 	"d7y.io/dragonfly/v2/pkg/basic/dfnet"
+	"d7y.io/dragonfly/v2/pkg/rpc"
+	"d7y.io/dragonfly/v2/pkg/rpc/base"
+	dfdaemongrpc "d7y.io/dragonfly/v2/pkg/rpc/dfdaemon"
+	dfclient "d7y.io/dragonfly/v2/pkg/rpc/dfdaemon/client"
+	_ "d7y.io/dragonfly/v2/pkg/rpc/dfdaemon/server"
+	"d7y.io/dragonfly/v2/pkg/rpc/scheduler"
 )
 
 func TestMain(m *testing.M) {
diff --git a/client/daemon/storage/local_storage_test.go b/client/daemon/storage/local_storage_test.go
index 44a39158..1b4b44ec 100644
--- a/client/daemon/storage/local_storage_test.go
+++ b/client/daemon/storage/local_storage_test.go
@@ -36,8 +36,8 @@ import (
 	"d7y.io/dragonfly/v2/client/config"
 	"d7y.io/dragonfly/v2/client/daemon/test"
 	logger "d7y.io/dragonfly/v2/internal/dflog"
-	"d7y.io/dragonfly/v2/internal/rpc/base"
-	_ "d7y.io/dragonfly/v2/internal/rpc/dfdaemon/server"
+	"d7y.io/dragonfly/v2/pkg/rpc/base"
+	_ "d7y.io/dragonfly/v2/pkg/rpc/dfdaemon/server"
 )
 
 func TestMain(m *testing.M) {
diff --git a/client/daemon/test/mock/daemon/daemon_server.go b/client/daemon/test/mock/daemon/daemon_server.go
index 01a6ebce..d52550d4 100644
--- a/client/daemon/test/mock/daemon/daemon_server.go
+++ b/client/daemon/test/mock/daemon/daemon_server.go
@@ -8,8 +8,8 @@ import (
 	context "context"
 	reflect "reflect"
 
-	base "d7y.io/dragonfly/v2/internal/rpc/base"
-	dfdaemon "d7y.io/dragonfly/v2/internal/rpc/dfdaemon"
+	base "d7y.io/dragonfly/v2/pkg/rpc/base"
+	dfdaemon "d7y.io/dragonfly/v2/pkg/rpc/dfdaemon"
 	gomock "github.com/golang/mock/gomock"
 )
 
diff --git a/client/daemon/test/mock/peer/peertask_manager.go b/client/daemon/test/mock/peer/peertask_manager.go
index 6f7f20e6..4bd4f14d 100644
--- a/client/daemon/test/mock/peer/peertask_manager.go
+++ b/client/daemon/test/mock/peer/peertask_manager.go
@@ -12,8 +12,8 @@ import (
 
 	peer "d7y.io/dragonfly/v2/client/daemon/peer"
 	logger "d7y.io/dragonfly/v2/internal/dflog"
-	base "d7y.io/dragonfly/v2/internal/rpc/base"
-	scheduler "d7y.io/dragonfly/v2/internal/rpc/scheduler"
+	base "d7y.io/dragonfly/v2/pkg/rpc/base"
+	scheduler "d7y.io/dragonfly/v2/pkg/rpc/scheduler"
 	gomock "github.com/golang/mock/gomock"
 )
 
diff --git a/client/daemon/test/mock/scheduler/scheduler_client.go b/client/daemon/test/mock/scheduler/scheduler_client.go
index 269d38ce..703d50ae 100644
--- a/client/daemon/test/mock/scheduler/scheduler_client.go
+++ b/client/daemon/test/mock/scheduler/scheduler_client.go
@@ -8,8 +8,8 @@ import (
 	context "context"
 	reflect "reflect"
 
-	scheduler "d7y.io/dragonfly/v2/internal/rpc/scheduler"
-	client "d7y.io/dragonfly/v2/internal/rpc/scheduler/client"
+	scheduler "d7y.io/dragonfly/v2/pkg/rpc/scheduler"
+	client "d7y.io/dragonfly/v2/pkg/rpc/scheduler/client"
 	gomock "github.com/golang/mock/gomock"
 	grpc "google.golang.org/grpc"
 )
diff --git a/client/daemon/test/mock/scheduler/scheduler_client_peer_packet_stream.go b/client/daemon/test/mock/scheduler/scheduler_client_peer_packet_stream.go
index 156a1fb5..5c3ba22f 100644
--- a/client/daemon/test/mock/scheduler/scheduler_client_peer_packet_stream.go
+++ b/client/daemon/test/mock/scheduler/scheduler_client_peer_packet_stream.go
@@ -7,7 +7,7 @@ package mock_client
 import (
 	reflect "reflect"
 
-	scheduler "d7y.io/dragonfly/v2/internal/rpc/scheduler"
+	scheduler "d7y.io/dragonfly/v2/pkg/rpc/scheduler"
 	gomock "github.com/golang/mock/gomock"
 )
 
diff --git a/client/daemon/test/mock/storage/manager.go b/client/daemon/test/mock/storage/manager.go
index 68742e73..68f26060 100644
--- a/client/daemon/test/mock/storage/manager.go
+++ b/client/daemon/test/mock/storage/manager.go
@@ -11,7 +11,7 @@ import (
 	time "time"
 
 	storage "d7y.io/dragonfly/v2/client/daemon/storage"
-	base "d7y.io/dragonfly/v2/internal/rpc/base"
+	base "d7y.io/dragonfly/v2/pkg/rpc/base"
 	gomock "github.com/golang/mock/gomock"
 )
 
diff --git a/client/daemon/transport/transport_test.go b/client/daemon/transport/transport_test.go
index 2baf6b2b..51d427b7 100644
--- a/client/daemon/transport/transport_test.go
+++ b/client/daemon/transport/transport_test.go
@@ -30,7 +30,7 @@ import (
 
 	"d7y.io/dragonfly/v2/client/daemon/test"
 	mock_peer "d7y.io/dragonfly/v2/client/daemon/test/mock/peer"
-	"d7y.io/dragonfly/v2/internal/rpc/scheduler"
+	"d7y.io/dragonfly/v2/pkg/rpc/scheduler"
 )
 
 func TestMain(m *testing.M) {
diff --git a/client/daemon/upload/upload_manager_test.go b/client/daemon/upload/upload_manager_test.go
index b222af61..55185fd7 100644
--- a/client/daemon/upload/upload_manager_test.go
+++ b/client/daemon/upload/upload_manager_test.go
@@ -34,7 +34,7 @@ import (
 	"d7y.io/dragonfly/v2/client/daemon/storage"
 	"d7y.io/dragonfly/v2/client/daemon/test"
 	mock_storage "d7y.io/dragonfly/v2/client/daemon/test/mock/storage"
-	_ "d7y.io/dragonfly/v2/internal/rpc/dfdaemon/server"
+	_ "d7y.io/dragonfly/v2/pkg/rpc/dfdaemon/server"
 )
 
 func TestMain(m *testing.M) {
diff --git a/internal/idgen/task_id_test.go b/internal/idgen/task_id_test.go
index e2aaa9ec..f0246333 100644
--- a/internal/idgen/task_id_test.go
+++ b/internal/idgen/task_id_test.go
@@ -19,7 +19,7 @@ package idgen
 import (
 	"testing"
 
-	"d7y.io/dragonfly/v2/internal/rpc/base"
+	"d7y.io/dragonfly/v2/pkg/rpc/base"
 	"github.com/stretchr/testify/assert"
 )
 
diff --git a/scheduler/config/dynconfig_test.go b/scheduler/config/dynconfig_test.go
index 07bd816f..ae9e5105 100644
--- a/scheduler/config/dynconfig_test.go
+++ b/scheduler/config/dynconfig_test.go
@@ -23,7 +23,7 @@ import (
 	"time"
 
 	dc "d7y.io/dragonfly/v2/internal/dynconfig"
-	"d7y.io/dragonfly/v2/internal/rpc/manager"
+	"d7y.io/dragonfly/v2/pkg/rpc/manager"
 	"d7y.io/dragonfly/v2/scheduler/config/mocks"
 	"github.com/golang/mock/gomock"
 	"github.com/pkg/errors"
diff --git a/scheduler/manager/cdn_manager_test.go b/scheduler/manager/cdn_manager_test.go
index 33a094b3..876ef1c4 100644
--- a/scheduler/manager/cdn_manager_test.go
+++ b/scheduler/manager/cdn_manager_test.go
@@ -19,8 +19,8 @@ package manager
 import (
 	"testing"
 
-	"d7y.io/dragonfly/v2/internal/rpc/manager"
 	"d7y.io/dragonfly/v2/pkg/basic/dfnet"
+	"d7y.io/dragonfly/v2/pkg/rpc/manager"
 	testifyassert "github.com/stretchr/testify/assert"
 )