devflag 분리 / gocommon으로 패키지 변경
This commit is contained in:
@ -7,8 +7,6 @@ import (
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
"unsafe"
|
||||
|
||||
common "repositories.action2quare.com/ayo/gocommon"
|
||||
)
|
||||
|
||||
type ApiCaller interface {
|
||||
@ -201,10 +199,6 @@ func (ac apiCaller) callByServer() bool {
|
||||
}
|
||||
|
||||
func (ac apiCaller) HasAuthority(authPath string) bool {
|
||||
if *common.Devflag {
|
||||
return true
|
||||
}
|
||||
|
||||
if ac.callByServer() {
|
||||
return true
|
||||
}
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
package common
|
||||
package gocommon
|
||||
|
||||
import (
|
||||
"context"
|
||||
@ -110,7 +110,7 @@ func newAuthCollectionWithRedis(redisClient *redis.Client, subctx context.Contex
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
if !*Devflag {
|
||||
if !*devflag {
|
||||
logger.Error("get maingate config failed :", err)
|
||||
return nil
|
||||
}
|
||||
@ -131,7 +131,7 @@ func newAuthCollectionWithRedis(redisClient *redis.Client, subctx context.Contex
|
||||
if ttl, ok := config["maingate_session_ttl"].(float64); ok {
|
||||
sessionTTL = int64(ttl)
|
||||
}
|
||||
} else if !*Devflag {
|
||||
} else if !*devflag {
|
||||
logger.Error("get maingate config failed :", err)
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
package common
|
||||
package gocommon
|
||||
|
||||
import (
|
||||
"archive/tar"
|
||||
|
||||
6
flags.go
Normal file
6
flags.go
Normal file
@ -0,0 +1,6 @@
|
||||
package gocommon
|
||||
|
||||
import "flag"
|
||||
|
||||
var commandLine = flag.NewFlagSet("gocommon", flag.ExitOnError)
|
||||
var devflag = commandLine.Bool("dev", false, "")
|
||||
@ -1,4 +1,4 @@
|
||||
package common
|
||||
package gocommon
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
7
mongo.go
7
mongo.go
@ -1,10 +1,9 @@
|
||||
package common
|
||||
package gocommon
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"flag"
|
||||
"os"
|
||||
"time"
|
||||
|
||||
@ -28,8 +27,6 @@ type ConnectionInfo struct {
|
||||
Database string
|
||||
}
|
||||
|
||||
var Devflag = flag.Bool("dev", false, "")
|
||||
|
||||
type CollectionName string
|
||||
|
||||
func ParseObjectID(hexstr string) (out primitive.ObjectID) {
|
||||
@ -42,7 +39,7 @@ func NewMongoConnectionInfo(url string, dbname string) *ConnectionInfo {
|
||||
panic("dbname is empty")
|
||||
}
|
||||
|
||||
if *Devflag {
|
||||
if *devflag {
|
||||
hostname, _ := os.Hostname()
|
||||
dbname = hostname + "-" + dbname
|
||||
}
|
||||
|
||||
4
redis.go
4
redis.go
@ -1,4 +1,4 @@
|
||||
package common
|
||||
package gocommon
|
||||
|
||||
import (
|
||||
"context"
|
||||
@ -20,7 +20,7 @@ func newRedisClient(uri string, dbidxoffset int) *redis.Client {
|
||||
}
|
||||
|
||||
func NewRedisClient(uri string, dbidx int) (*redis.Client, error) {
|
||||
if !*Devflag {
|
||||
if !*devflag {
|
||||
return newRedisClient(uri, dbidx), nil
|
||||
}
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
package common
|
||||
package gocommon
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
Reference in New Issue
Block a user