Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
959901fcad | ||
|
|
83c1e36469 |
8
cache/cache.go
vendored
8
cache/cache.go
vendored
@@ -1,14 +1,14 @@
|
||||
package cache
|
||||
|
||||
import (
|
||||
"code.infininov.com/Infini/unitech-golib/tlog"
|
||||
"errors"
|
||||
"github.com/MAN00K/unitech_golib/tlog"
|
||||
"github.com/creachadair/cityhash"
|
||||
"sync"
|
||||
"time"
|
||||
)
|
||||
|
||||
//API
|
||||
// API
|
||||
var Nil error = errors.New("cache: nil")
|
||||
|
||||
func Set(key string, value interface{}) error {
|
||||
@@ -27,7 +27,7 @@ func Del(key string) error {
|
||||
return del(key)
|
||||
}
|
||||
|
||||
//internal
|
||||
// internal
|
||||
var dbs map[byte]*db
|
||||
|
||||
type db struct {
|
||||
@@ -59,7 +59,7 @@ func newdb(t time.Duration) *db {
|
||||
return ret
|
||||
}
|
||||
|
||||
//定期扫描过期的key
|
||||
// 定期扫描过期的key
|
||||
func (this *db) flush() {
|
||||
for range time.NewTicker(this.t).C {
|
||||
this.doflush()
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package gfetcd
|
||||
|
||||
import (
|
||||
"code.infininov.com/Infini/unitech-golib/tlog"
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/MAN00K/unitech_golib/tlog"
|
||||
"os"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/MAN00K/unitech_golib/tlog"
|
||||
"code.infininov.com/Infini/unitech-golib/tlog"
|
||||
|
||||
"github.com/coreos/etcd/clientv3"
|
||||
etcdnaming "github.com/coreos/etcd/clientv3/naming"
|
||||
@@ -31,7 +31,7 @@ func (self *NameConfig) GetAddr() string {
|
||||
return self.Addr
|
||||
}
|
||||
|
||||
//获取本机的内网Ip, 如果发现对方的ip 和自己的ip 相同,用127.0.0.1 替代
|
||||
// 获取本机的内网Ip, 如果发现对方的ip 和自己的ip 相同,用127.0.0.1 替代
|
||||
func getLocalIP() string {
|
||||
ifaces, _ := net.Interfaces()
|
||||
for _, i := range ifaces {
|
||||
|
||||
2
go.mod
2
go.mod
@@ -1,4 +1,4 @@
|
||||
module github.com/MAN00K/unitech_golib
|
||||
module code.infininov.com/Infini/unitech-golib
|
||||
|
||||
go 1.16
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
"github.com/MAN00K/unitech_golib/tlog"
|
||||
"code.infininov.com/Infini/unitech-golib/tlog"
|
||||
|
||||
"github.com/Shopify/sarama"
|
||||
cluster "github.com/bsm/sarama-cluster"
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package lrucache
|
||||
|
||||
import (
|
||||
"code.infininov.com/Infini/unitech-golib/tlog"
|
||||
"errors"
|
||||
"github.com/MAN00K/unitech_golib/tlog"
|
||||
"github.com/creachadair/cityhash"
|
||||
"github.com/hashicorp/golang-lru"
|
||||
"time"
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"code.infininov.com/Infini/unitech-golib/metric"
|
||||
"fmt"
|
||||
"github.com/MAN00K/unitech_golib/metric"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"code.infininov.com/Infini/unitech-golib/metric"
|
||||
"fmt"
|
||||
"github.com/MAN00K/unitech_golib/metric"
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
"time"
|
||||
)
|
||||
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/MAN00K/unitech_golib/tlog"
|
||||
"code.infininov.com/Infini/unitech-golib/tlog"
|
||||
consulapi "github.com/hashicorp/consul/api"
|
||||
"github.com/prometheus/client_golang/prometheus/promhttp"
|
||||
)
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"code.infininov.com/Infini/unitech-golib/metrics"
|
||||
"code.infininov.com/Infini/unitech-golib/metrics/prometheus"
|
||||
"code.infininov.com/Infini/unitech-golib/tlog"
|
||||
"flag"
|
||||
"github.com/MAN00K/unitech_golib/metrics"
|
||||
"github.com/MAN00K/unitech_golib/metrics/prometheus"
|
||||
"github.com/MAN00K/unitech_golib/tlog"
|
||||
"math/rand"
|
||||
"os"
|
||||
"os/signal"
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
package metrics
|
||||
|
||||
import (
|
||||
"code.infininov.com/Infini/unitech-golib/tlog"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/MAN00K/unitech_golib/tlog"
|
||||
"net/http"
|
||||
"os"
|
||||
"strconv"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package prometheus
|
||||
|
||||
import (
|
||||
"github.com/MAN00K/unitech_golib/metrics"
|
||||
"code.infininov.com/Infini/unitech-golib/metrics"
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
)
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package prometheus
|
||||
|
||||
import (
|
||||
"code.infininov.com/Infini/unitech-golib/metrics"
|
||||
"fmt"
|
||||
"github.com/MAN00K/unitech_golib/metrics"
|
||||
stdprometheus "github.com/prometheus/client_golang/prometheus"
|
||||
"github.com/prometheus/client_golang/prometheus/promhttp"
|
||||
"io/ioutil"
|
||||
|
||||
10
qgrpc/op.go
10
qgrpc/op.go
@@ -1,10 +1,10 @@
|
||||
package qgrpc
|
||||
|
||||
import (
|
||||
"code.infininov.com/Infini/unitech-golib/qgrpc/ping"
|
||||
"code.infininov.com/Infini/unitech-golib/tlog"
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/MAN00K/unitech_golib/qgrpc/ping"
|
||||
"github.com/MAN00K/unitech_golib/tlog"
|
||||
"github.com/coreos/etcd/clientv3"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/keepalive"
|
||||
@@ -87,7 +87,7 @@ func NewClient(cfg *ClientConfig) (client *Client, err error) {
|
||||
return
|
||||
}
|
||||
|
||||
//user.User|127.0.0.1:9011 -> Server{Name: user.User Addrs: []string{127.0.0.1:9011}}
|
||||
// user.User|127.0.0.1:9011 -> Server{Name: user.User Addrs: []string{127.0.0.1:9011}}
|
||||
func ParseServerName(serverName string) *RpcServer {
|
||||
ss := strings.Split(serverName, "|")
|
||||
s := &RpcServer{Name: ss[0]}
|
||||
@@ -101,12 +101,12 @@ func ParseServerName(serverName string) *RpcServer {
|
||||
return s
|
||||
}
|
||||
|
||||
//根据server-name 获得对应的连接池
|
||||
// 根据server-name 获得对应的连接池
|
||||
func (self *Client) GetConn(serverName string) *grpc.ClientConn {
|
||||
return self.rpcServers[serverName]
|
||||
}
|
||||
|
||||
//从etcd注销
|
||||
// 从etcd注销
|
||||
func (self *Server) Revoke() error {
|
||||
_, err := self.etcdCli.Revoke(context.Background(), self.etcdId)
|
||||
return err
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package qgrpc
|
||||
|
||||
import (
|
||||
"code.infininov.com/Infini/unitech-golib/tlog"
|
||||
"context"
|
||||
"github.com/MAN00K/unitech_golib/tlog"
|
||||
"github.com/coreos/etcd/clientv3"
|
||||
"path"
|
||||
"time"
|
||||
|
||||
Reference in New Issue
Block a user