Skip to content

Commit

Permalink
temp
Browse files Browse the repository at this point in the history
  • Loading branch information
TremblingV5 committed May 8, 2024
1 parent cfe64b5 commit a630312
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 47 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"github.com/TremblingV5/DouTok/applications/comment/infra/model"
"github.com/TremblingV5/DouTok/pkg/hbaseHandle"
tools "github.com/TremblingV5/DouTok/pkg/misc"
"github.com/tsuna/gohbase"
"github.com/tsuna/gohbase/hrpc"
)

Expand All @@ -16,10 +17,10 @@ type Repository interface {
}

type PersistRepository struct {
hbClient *hbaseHandle.HBaseClient
hbClient gohbase.Client
}

func New(hbClient *hbaseHandle.HBaseClient) *PersistRepository {
func New(hbClient gohbase.Client) *PersistRepository {
return &PersistRepository{
hbClient: hbClient,
}
Expand All @@ -39,7 +40,7 @@ func (r *PersistRepository) Save(ctx context.Context, comment *model.CommentInHB
},
}

if err := r.hbClient.Put(
if _, err := r.hbClient.Put(
"comment", misc.GetCommentRowKey(
comment.GetVideoId(), "0",
comment.GetConversationId(),
Expand Down
47 changes: 5 additions & 42 deletions applications/comment/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ import (
"github.com/TremblingV5/DouTok/pkg/dlog"
"github.com/TremblingV5/DouTok/pkg/hbaseHandle"
"github.com/TremblingV5/DouTok/pkg/initHelper"
"github.com/TremblingV5/DouTok/pkg/mysqlIniter"
redishandle "github.com/TremblingV5/DouTok/pkg/redisHandle"
"github.com/TremblingV5/box/components/hbasex"
"github.com/TremblingV5/box/components/mysqlx"
"github.com/TremblingV5/box/components/redisx"
"github.com/TremblingV5/box/configx"
Expand All @@ -28,45 +27,6 @@ var (
Logger = dlog.InitLog(3)
)

func initDb(
username, password, host, port, database string,
) {
db, err := mysqlIniter.InitDb(
username,
password,
host,
port,
database,
)

if err != nil {
panic(err)
}

query.SetDefault(db)

dbtx.Init(func() dbtx.TX {
return query.Q.Begin()
})
}

func initRedis(
dest, password string,
dbs map[string]int,
) map[string]*redishandle.RedisClient {
redisClients, err := redishandle.InitRedis(
dest,
password,
dbs,
)

if err != nil {
panic(err)
}

return redisClients
}

func initHb(host string) hbaseHandle.HBaseClient {
return hbaseHandle.InitHB(host)
}
Expand All @@ -79,13 +39,16 @@ func Init() comment.CommentService {
query.SetDefault(
mysqlx.GetDBClient(context.Background(), "default"),
)
dbtx.Init(func() dbtx.TX {
return query.Q.Begin()
})

hbaseClient := initHb(misc.GetConfig("HBase.Host"))

service := comment_service.New(
cache.NewCountMapCache(),
cache.NewCountMapCache(),
comment_hb_repo.New(&hbaseClient),
comment_hb_repo.New(hbasex.GetClient(ctx, "default")),
redisx.GetClient(ctx, "default", misc.ComCntCache),
redisx.GetClient(ctx, "default", misc.ComTotalCntCache),
)
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.21
require (
bou.ke/monkey v1.0.2
github.com/IBM/sarama v1.43.1
github.com/TremblingV5/box v0.0.5
github.com/TremblingV5/box v0.0.7
github.com/aliyun/aliyun-oss-go-sdk v2.2.6+incompatible
github.com/bwmarrin/snowflake v0.3.0
github.com/caarlos0/env/v9 v9.0.0
Expand Down Expand Up @@ -40,7 +40,7 @@ require (
github.com/stretchr/testify v1.9.0
github.com/swaggo/files v1.0.1
github.com/swaggo/swag v1.16.3
github.com/tsuna/gohbase v0.0.0-20221118171731-ee78e2db30c3
github.com/tsuna/gohbase v0.0.0-20240425232423-fa78846cafc9
go.mongodb.org/mongo-driver v1.14.0
go.uber.org/zap v1.27.0
golang.org/x/net v0.24.0
Expand Down

0 comments on commit a630312

Please sign in to comment.