fix version 1

This commit is contained in:
2026-09-22 21:15:34 +08:00
parent 9f86366638
commit d63d7e8b3a
277 changed files with 9959 additions and 1514 deletions

View File

@@ -0,0 +1,32 @@
package service
import (
"bsm/full/module/social/feed/internal/impl"
"git.apinb.com/bsm-sdk/core/cache/redis"
cache "github.com/patrickmn/go-cache"
clientv3 "go.etcd.io/etcd/client/v3"
"gorm.io/gorm"
)
// Dependencies 聚合宿主注入的共享基础设施
type Dependencies struct {
Redis *redis.RedisClient
Etcd *clientv3.Client
DB *gorm.DB
Cache *cache.Cache
}
func applyDependencies(deps Dependencies) {
if deps.Redis != nil {
impl.RedisService = deps.Redis
}
if deps.Etcd != nil {
impl.EtcdService = deps.Etcd
}
if deps.DB != nil {
impl.DBService = deps.DB
}
if deps.Cache != nil {
impl.MemorySerice = deps.Cache
}
}

View File

@@ -0,0 +1,26 @@
package service
import (
"context"
"bsm/full/module/social/feed/internal/server"
gwRuntime "github.com/grpc-ecosystem/grpc-gateway/v2/runtime"
"google.golang.org/grpc"
)
type ExposeOptions struct {
Dependencies
GRPC *grpc.Server
Gateway *gwRuntime.ServeMux
}
// Expose 供聚合宿主接入:注册 gRPC service 与网关路由
func Expose(options ExposeOptions) error {
applyDependencies(options.Dependencies)
server.New(options.GRPC)
if options.Gateway == nil {
return nil
}
return server.RegisterGateway(context.Background(), options.Gateway)
}