refract(container/gtype): rename package gtype to gatomic (#4274)

This commit is contained in:
John Guo
2025-05-07 19:11:44 +08:00
committed by GitHub
parent f52b7de1cf
commit 1f2fcd39b1
69 changed files with 312 additions and 312 deletions

View File

@ -15,8 +15,8 @@ import (
"github.com/gorilla/websocket"
"github.com/gogf/gf/v3/container/gatomic"
"github.com/gogf/gf/v3/container/gmap"
"github.com/gogf/gf/v3/container/gtype"
"github.com/gogf/gf/v3/errors/gcode"
"github.com/gogf/gf/v3/errors/gerror"
"github.com/gogf/gf/v3/net/ghttp/internal/graceful"
@ -36,7 +36,7 @@ type (
config ServerConfig // Server configuration.
plugins []Plugin // Plugin array to extend server functionality.
servers []*graceful.Server // Underlying http.Server array.
serverCount *gtype.Int // Underlying http.Server number for internal usage.
serverCount *gatomic.Int // Underlying http.Server number for internal usage.
closeChan chan struct{} // Used for underlying server closing event notification.
serveTree map[string]interface{} // The route maps tree.
serveCache *gcache.Cache // Server caches for internal usage.
@ -182,7 +182,7 @@ var (
// serverRunning marks the running server counts.
// If there is no successful server running or all servers' shutdown, this value is 0.
serverRunning = gtype.NewInt()
serverRunning = gatomic.NewInt()
// wsUpGrader is the default up-grader configuration for websocket.
wsUpGrader = websocket.Upgrader{
@ -197,7 +197,7 @@ var (
// serverProcessInitialized is used for lazy initialization for server.
// The process can only be initialized once.
serverProcessInitialized = gtype.NewBool()
serverProcessInitialized = gatomic.NewBool()
// gracefulEnabled is used for a graceful reload feature, which is false in default.
gracefulEnabled = false

View File

@ -20,8 +20,8 @@ import (
"github.com/olekukonko/tablewriter"
"github.com/gogf/gf/v3/container/garray"
"github.com/gogf/gf/v3/container/gatomic"
"github.com/gogf/gf/v3/container/gset"
"github.com/gogf/gf/v3/container/gtype"
"github.com/gogf/gf/v3/debug/gdebug"
"github.com/gogf/gf/v3/errors/gcode"
"github.com/gogf/gf/v3/errors/gerror"
@ -100,7 +100,7 @@ func GetServer(name ...interface{}) *Server {
plugins: make([]Plugin, 0),
servers: make([]*graceful.Server, 0),
closeChan: make(chan struct{}, 10000),
serverCount: gtype.NewInt(),
serverCount: gatomic.NewInt(),
statusHandlerMap: make(map[string][]HandlerFunc),
serveTree: make(map[string]interface{}),
serveCache: gcache.New(),

View File

@ -16,7 +16,7 @@ import (
"sync"
"time"
"github.com/gogf/gf/v3/container/gtype"
"github.com/gogf/gf/v3/container/gatomic"
"github.com/gogf/gf/v3/encoding/gjson"
"github.com/gogf/gf/v3/errors/gcode"
"github.com/gogf/gf/v3/errors/gerror"
@ -46,10 +46,10 @@ var (
serverActionLocker sync.Mutex
// serverActionLastTime is timestamp in milliseconds of last administration operation.
serverActionLastTime = gtype.NewInt64(gtime.TimestampMilli())
serverActionLastTime = gatomic.NewInt64(gtime.TimestampMilli())
// serverProcessStatus is the server status for operation of current process.
serverProcessStatus = gtype.NewInt()
serverProcessStatus = gatomic.NewInt()
)
// RestartAllServer restarts all the servers of the process gracefully.

View File

@ -13,8 +13,8 @@ import (
"runtime"
"strings"
"github.com/gogf/gf/v3/container/gatomic"
"github.com/gogf/gf/v3/container/glist"
"github.com/gogf/gf/v3/container/gtype"
"github.com/gogf/gf/v3/debug/gdebug"
"github.com/gogf/gf/v3/errors/gcode"
"github.com/gogf/gf/v3/errors/gerror"
@ -27,7 +27,7 @@ import (
var (
// handlerIdGenerator is handler item id generator.
handlerIdGenerator = gtype.NewInt()
handlerIdGenerator = gatomic.NewInt()
)
// routerMapKey creates and returns a unique router key for given parameters.

View File

@ -30,7 +30,7 @@ import (
"sync"
"time"
"github.com/gogf/gf/v3/container/gtype"
"github.com/gogf/gf/v3/container/gatomic"
"github.com/gogf/gf/v3/errors/gcode"
"github.com/gogf/gf/v3/errors/gerror"
"github.com/gogf/gf/v3/os/glog"
@ -60,7 +60,7 @@ type Server struct {
rawLnMu sync.RWMutex // Concurrent safety mutex for rawListener.
listener net.Listener // Wrapped net.Listener with TLS support if necessary.
isHttps bool // Whether server is running in HTTPS mode.
status *gtype.Int // Server status using gtype for concurrent safety.
status *gatomic.Int // Server status using gtype for concurrent safety.
config ServerConfig // Server configuration.
}
@ -127,7 +127,7 @@ func New(
gs := &Server{
address: address,
httpServer: newHttpServer(address, loggerWriter, config),
status: gtype.NewInt(),
status: gatomic.NewInt(),
config: config,
}
if fd != 0 {

View File

@ -10,7 +10,7 @@ import (
"context"
"sync"
"github.com/gogf/gf/v3/container/gtype"
"github.com/gogf/gf/v3/container/gatomic"
"github.com/gogf/gf/v3/internal/intlog"
)
@ -21,7 +21,7 @@ type selectorLeastConnection struct {
type leastConnectionNode struct {
Node
inflight *gtype.Int
inflight *gatomic.Int
}
func NewSelectorLeastConnection() Selector {
@ -37,7 +37,7 @@ func (s *selectorLeastConnection) Update(ctx context.Context, nodes Nodes) error
node := v
newNodes = append(newNodes, &leastConnectionNode{
Node: node,
inflight: gtype.NewInt(),
inflight: gatomic.NewInt(),
})
}
s.mu.Lock()