2 Commits
v1.1.0 ... main

Author SHA1 Message Date
man00k
959901fcad update 2026-01-30 16:49:29 +08:00
man00k
83c1e36469 udpate 2026-01-30 16:18:48 +08:00
16 changed files with 25 additions and 1595 deletions

8
cache/cache.go vendored
View File

@@ -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()

View File

@@ -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"

View File

@@ -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
View File

@@ -1,4 +1,4 @@
module github.com/MAN00K/unitech_golib
module code.infininov.com/Infini/unitech-golib
go 1.16

1570
go.sum

File diff suppressed because it is too large Load Diff

View File

@@ -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"

View File

@@ -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"

View File

@@ -1,8 +1,8 @@
package main
import (
"code.infininov.com/Infini/unitech-golib/metric"
"fmt"
"github.com/MAN00K/unitech_golib/metric"
)
func main() {

View File

@@ -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"
)

View File

@@ -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"
)

View File

@@ -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"

View File

@@ -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"

View File

@@ -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"
)

View File

@@ -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"

View File

@@ -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

View File

@@ -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"