storage: register tier backends at the binary composition root (#9989)

The s3 and rclone tiered-storage backends were registered via blank imports
in weed/storage (volume_tier.go and volume_info/volume_info.go). That forced
every library consumer of weed/storage -- weed/shell, and through it external
tools -- to link aws-sdk-go and, under the rclone build tag, the full rclone
backend set and its cloud-storage SDKs, even though those consumers never tier
volumes.

Move the registrations into a new weed/storage/backend/all aggregator and
blank-import it once from weed/command, the binary's composition root. The weed
binary still registers both backends; weed/storage and its library consumers no
longer pull the backend SDKs into their dependency graph.
This commit is contained in:
Chris Lu
2026-06-16 11:47:32 -07:00
committed by GitHub
parent b58e9ac3c4
commit 5e8152b81c
4 changed files with 15 additions and 4 deletions
+5
View File
@@ -0,0 +1,5 @@
package command
// Register the tiered-storage backends here, at the binary's composition root,
// so library consumers of weed/storage don't pull the backend SDKs.
import _ "github.com/seaweedfs/seaweedfs/weed/storage/backend/all"
+10
View File
@@ -0,0 +1,10 @@
// Package all registers every tiered-storage backend factory. Binaries that
// serve or manage tiered volumes blank-import it from their composition root;
// keeping the registrations out of weed/storage lets library consumers avoid
// pulling the backend SDKs into their dependency graph.
package all
import (
_ "github.com/seaweedfs/seaweedfs/weed/storage/backend/rclone_backend"
_ "github.com/seaweedfs/seaweedfs/weed/storage/backend/s3_backend"
)
-2
View File
@@ -6,8 +6,6 @@ import (
"github.com/seaweedfs/seaweedfs/weed/glog"
"github.com/seaweedfs/seaweedfs/weed/pb/volume_server_pb"
_ "github.com/seaweedfs/seaweedfs/weed/storage/backend/rclone_backend"
_ "github.com/seaweedfs/seaweedfs/weed/storage/backend/s3_backend"
"github.com/seaweedfs/seaweedfs/weed/util"
jsonpb "google.golang.org/protobuf/encoding/protojson"
)
-2
View File
@@ -7,8 +7,6 @@ import (
"github.com/seaweedfs/seaweedfs/weed/glog"
"github.com/seaweedfs/seaweedfs/weed/pb/volume_server_pb"
"github.com/seaweedfs/seaweedfs/weed/storage/backend"
_ "github.com/seaweedfs/seaweedfs/weed/storage/backend/rclone_backend"
_ "github.com/seaweedfs/seaweedfs/weed/storage/backend/s3_backend"
"github.com/seaweedfs/seaweedfs/weed/storage/needle"
"github.com/seaweedfs/seaweedfs/weed/storage/types"
"github.com/seaweedfs/seaweedfs/weed/storage/volume_info"