up
This commit is contained in:
1 parent
c1da3c89ad
commit
8a0ebe803a
7 files changed
+25
-17
No files matched your search
@@ -1,3 +1,5 @@
|
||||
### v2.0.0
|
||||
* update to new isp-lib & config service
|
||||
### v1.1.3
|
||||
* update to new log
|
||||
* migrate to new db client
|
||||
|
||||
@@ -4,7 +4,6 @@ import (
|
||||
"isp-system-service/entity"
|
||||
"isp-system-service/model"
|
||||
|
||||
"github.com/integration-system/isp-lib/database"
|
||||
_ "github.com/integration-system/isp-lib/structure"
|
||||
"github.com/integration-system/isp-lib/utils"
|
||||
"google.golang.org/grpc/codes"
|
||||
@@ -146,7 +145,7 @@ func DeleteApplications(list []int32) (DeleteResponse, error) {
|
||||
return DeleteResponse{}, status.Errorf(codes.InvalidArgument, "At least one id are required")
|
||||
}
|
||||
var count = 0
|
||||
err := database.RunInTransaction(func(appRep model.AppRepository, tokenRep model.TokenRepository) error {
|
||||
err := model.DbClient.RunInTransaction(func(appRep model.AppRepository, tokenRep model.TokenRepository) error {
|
||||
for _, appId := range list {
|
||||
_, err := revokeTokensForApp(Identity{appId}, &tokenRep)
|
||||
if err != nil {
|
||||
|
||||
+5
-7
@@ -1,6 +1,7 @@
|
||||
package controller
|
||||
|
||||
import (
|
||||
"isp-system-service/invoker"
|
||||
"time"
|
||||
|
||||
"isp-system-service/conf"
|
||||
@@ -10,7 +11,7 @@ import (
|
||||
"fmt"
|
||||
"github.com/go-redis/redis"
|
||||
"github.com/integration-system/isp-lib/config"
|
||||
"github.com/integration-system/isp-lib/redis"
|
||||
rd "github.com/integration-system/isp-lib/redis"
|
||||
"github.com/integration-system/isp-lib/token-gen"
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/status"
|
||||
@@ -71,7 +72,6 @@ func CreateToken(req CreateTokenRequest) (*AppWithToken, error) {
|
||||
CreatedAt: time.Now(),
|
||||
}
|
||||
|
||||
c := rd.GetClient()
|
||||
err = SetIdentityMapForToken(token, m)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -79,7 +79,7 @@ func CreateToken(req CreateTokenRequest) (*AppWithToken, error) {
|
||||
|
||||
token, err = model.TokenRep.SaveToken(token)
|
||||
if err != nil {
|
||||
c.Del(token.Token)
|
||||
invoker.RedisClient.Del(token.Token)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -146,9 +146,8 @@ func GetTokensByAppId(identity Identity) ([]entity.Token, error) {
|
||||
}
|
||||
|
||||
func SetIdentityMapForTokenV2(token string, expireTime int64, idMap map[string]interface{}) error {
|
||||
c := rd.GetClient()
|
||||
cfg := config.Get().(*conf.Configuration)
|
||||
_, e := c.UseDbTx(rd.ApplicationTokenDb, func(p redis.Pipeliner) error {
|
||||
_, e := invoker.RedisClient.UseDbTx(rd.ApplicationTokenDb, func(p redis.Pipeliner) error {
|
||||
t := fmt.Sprintf("%s|%s", token, cfg.InstanceUuid)
|
||||
stat := p.HMSet(t, idMap)
|
||||
err := stat.Err()
|
||||
@@ -229,8 +228,7 @@ func revokeTokens(tokens []string, tokenRep *model.TokenRepository) (*DeleteResp
|
||||
if len(tokens) == 0 {
|
||||
return &DeleteResponse{0}, nil
|
||||
}
|
||||
c := rd.GetClient()
|
||||
_, e := c.UseDbTx(rd.ApplicationTokenDb, func(p redis.Pipeliner) error {
|
||||
_, e := invoker.RedisClient.UseDbTx(rd.ApplicationTokenDb, func(p redis.Pipeliner) error {
|
||||
deleted, err := tokenRep.DeleteTokens(tokens)
|
||||
count = deleted
|
||||
if err != nil {
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
package invoker
|
||||
|
||||
import (
|
||||
"github.com/integration-system/isp-lib/redis"
|
||||
)
|
||||
|
||||
var (
|
||||
RedisClient = redis.NewRxClient()
|
||||
)
|
||||
@@ -3,6 +3,7 @@ package main
|
||||
import (
|
||||
"github.com/integration-system/isp-lib/config/schema"
|
||||
"github.com/integration-system/isp-lib/structure"
|
||||
"isp-system-service/invoker"
|
||||
"os"
|
||||
|
||||
"isp-system-service/conf"
|
||||
@@ -82,15 +83,14 @@ func socketConfiguration(cfg interface{}) structure.SocketConfiguration {
|
||||
func onShutdown(_ context.Context, _ os.Signal) {
|
||||
backend.StopGrpcServer()
|
||||
_ = model.DbClient.Close()
|
||||
_ = invoker.RedisClient.Close()
|
||||
}
|
||||
|
||||
func onRemoteConfigReceive(remoteConfig, oldConfig *conf.RemoteConfig) {
|
||||
if remoteConfig.RedisAddress.GetAddress() != oldConfig.RedisAddress.GetAddress() {
|
||||
rd.InitClient(structure.RedisConfiguration{
|
||||
Address: remoteConfig.RedisAddress,
|
||||
DefaultDB: int(rd.ApplicationTokenDb),
|
||||
})
|
||||
}
|
||||
invoker.RedisClient.ReceiveConfiguration(structure.RedisConfiguration{
|
||||
Address: remoteConfig.RedisAddress,
|
||||
DefaultDB: int(redis.ApplicationTokenDb),
|
||||
})
|
||||
model.DbClient.ReceiveConfiguration(remoteConfig.DB)
|
||||
metric.InitCollectors(remoteConfig.Metrics, oldConfig.Metrics)
|
||||
metric.InitHttpServer(remoteConfig.Metrics)
|
||||
|
||||
@@ -29,7 +29,7 @@ func init() {
|
||||
}
|
||||
|
||||
func Up(tx *sql.Tx) error {
|
||||
path := path2.Join(database.ResolveMigrationsDirectrory(), initFile)
|
||||
path := path2.Join(database.ResolveMigrationsDirectory(), initFile)
|
||||
bytes, err := ioutil.ReadFile(path)
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
Reference in new issue
Block a user