Documentation
¶
Index ¶
- type ClientInfo
- type ClientRegistry
- func (cr *ClientRegistry) GetByKey(key string) (ClientInfo, bool)
- func (cr *ClientRegistry) List() []ClientInfo
- func (cr *ClientRegistry) MarkOfflineByRunID(runID string)
- func (cr *ClientRegistry) MarkOfflineByRunIDAndControlID(runID string, controlID uint64)
- func (cr *ClientRegistry) Register(user, rawClientID, runID, hostname, version, remoteAddr, wireProtocol string) (key string, conflict bool)
- func (cr *ClientRegistry) RegisterWithControlID(user, rawClientID, runID, hostname, version, remoteAddr, wireProtocol string, ...) (key string, conflict bool)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ClientInfo ¶
type ClientInfo struct {
Key string
User string
RawClientID string
RunID string
ControlID uint64
Hostname string
IP string
Version string
WireProtocol string
FirstConnectedAt time.Time
LastConnectedAt time.Time
DisconnectedAt time.Time
Online bool
}
ClientInfo captures metadata about a connected frpc instance.
func (ClientInfo) ClientID ¶
func (info ClientInfo) ClientID() string
ClientID returns the resolved client identifier for external use.
type ClientRegistry ¶
type ClientRegistry struct {
// contains filtered or unexported fields
}
ClientRegistry keeps track of active clients keyed by "{user}.{clientID}" (runID fallback when raw clientID is empty). Entries without an explicit raw clientID are removed on disconnect to avoid stale offline records.
func NewClientRegistry ¶
func NewClientRegistry() *ClientRegistry
func (*ClientRegistry) GetByKey ¶
func (cr *ClientRegistry) GetByKey(key string) (ClientInfo, bool)
GetByKey retrieves a client by its composite key ({user}.{clientID} with runID fallback).
func (*ClientRegistry) List ¶
func (cr *ClientRegistry) List() []ClientInfo
List returns a snapshot of all known clients.
func (*ClientRegistry) MarkOfflineByRunID ¶
func (cr *ClientRegistry) MarkOfflineByRunID(runID string)
MarkOfflineByRunID marks the client as offline when the corresponding control disconnects.
func (*ClientRegistry) MarkOfflineByRunIDAndControlID ¶ added in v0.70.1
func (cr *ClientRegistry) MarkOfflineByRunIDAndControlID(runID string, controlID uint64)
MarkOfflineByRunIDAndControlID marks a client offline only when the registry entry still belongs to the supplied control generation.
func (*ClientRegistry) Register ¶
func (cr *ClientRegistry) Register(user, rawClientID, runID, hostname, version, remoteAddr, wireProtocol string) (key string, conflict bool)
Register stores/updates metadata for a client and returns the registry key plus whether it conflicts with an online client.
func (*ClientRegistry) RegisterWithControlID ¶ added in v0.70.1
func (cr *ClientRegistry) RegisterWithControlID( user, rawClientID, runID, hostname, version, remoteAddr, wireProtocol string, controlID uint64, ) (key string, conflict bool)
RegisterWithControlID is the generation-aware form used by ControlManager. A control ID is process-local and prevents an older control generation from changing the registry entry now owned by a newer generation with the same run ID.