Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client handles RPC calls to other bots
func (*Client) Call ¶
Call makes an RPC call to a peer (deprecated - use CallWithContext for better timeout control)
func (*Client) CallWithContext ¶
func (c *Client) CallWithContext(ctx context.Context, peerID, action string, payload map[string]interface{}) ([]byte, error)
CallWithContext makes an RPC call to a peer with context support
func (*Client) SetAuthToken ¶
SetAuthToken sets the authentication token for RPC connections
type Cluster ¶
type Cluster interface {
GetRegistry() interface{}
GetNodeID() string
GetAddress() string
GetCapabilities() []string
GetOnlinePeers() []interface{}
GetActionsSchema() []interface{} // Get all available actions with schema
LogRPCInfo(msg string, args ...interface{})
LogRPCError(msg string, args ...interface{})
LogRPCDebug(msg string, args ...interface{})
GetPeer(peerID string) (interface{}, error) // Get peer directly
GetLocalNetworkInterfaces() ([]LocalNetworkInterface, error) // Get local network interfaces
CallWithContext(ctx context.Context, peerID, action string, payload map[string]interface{}) ([]byte, error) // RPC call
GetTaskResultStorer() TaskResultStorer // H4: B-side task result persistence
}
Cluster represents the cluster interface needed by RPC
type LocalNetworkInterface ¶
LocalNetworkInterface represents a local network interface (for RPC interface)
type Logger ¶
type Logger interface {
RPCInfo(format string, args ...interface{})
RPCError(format string, args ...interface{})
RPCDebug(format string, args ...interface{})
}
Logger represents logging functions
type Node ¶
type Node interface {
GetID() string
GetName() string
GetAddress() string
GetAddresses() []string
GetRPCPort() int
GetCapabilities() []string
GetStatus() string
IsOnline() bool
}
Node represents a node in the cluster (minimal interface)
type PeerChatHandler ¶
type PeerChatHandler struct {
// contains filtered or unexported fields
}
PeerChatHandler handles peer-to-peer chat and collaboration requests
func NewPeerChatHandler ¶
func NewPeerChatHandler(cluster Cluster, rpcChannel *channels.RPCChannel) *PeerChatHandler
NewPeerChatHandler creates a new peer chat handler
type PeerChatPayload ¶
type PeerChatPayload struct {
Type string `json:"type"` // chat|request|task|query
Content string `json:"content"` // 对话内容或任务描述
Context map[string]interface{} `json:"context"` // 附加上下文信息
}
PeerChatPayload represents the payload for peer_chat action
type PeerChatResponse ¶
type PeerChatResponse struct {
Response string `json:"response"` // 节点的响应内容
Result map[string]interface{} `json:"result,omitempty"` // 结构化结果
Status string `json:"status"` // success|error|busy
}
PeerChatResponse represents the response from peer_chat action
type RPCHandler ¶
RPCHandler is a function that handles an RPC action
type RateLimiter ¶
type RateLimiter struct {
// contains filtered or unexported fields
}
RateLimiter limits the rate of RPC calls
func NewRateLimiter ¶
func NewRateLimiter(maxTokens int, refillRate time.Duration, maxRequests int, window time.Duration) *RateLimiter
NewRateLimiter creates a new rate limiter
func (*RateLimiter) Acquire ¶
func (rl *RateLimiter) Acquire(ctx context.Context, peerID string) error
Acquire acquires a token for RPC call to peerID
func (*RateLimiter) Release ¶
func (rl *RateLimiter) Release(peerID string)
Release releases a token after RPC call completes
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server handles incoming RPC requests
func (*Server) GetConnectionCount ¶
GetConnectionCount returns the number of active connections
func (*Server) RegisterHandler ¶
func (s *Server) RegisterHandler(action string, handler RPCHandler)
RegisterHandler registers an RPC handler for an action
func (*Server) SetAuthToken ¶
SetAuthToken sets the authentication token for RPC connections