agent

package
v0.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 23, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateRandomID

func GenerateRandomID(prefix string) string

Types

type AddressProbeResult

type AddressProbeResult struct {
	URL       string `json:"url"`
	Tag       string `json:"tag"`
	Reachable bool   `json:"reachable"`
	LatencyMs int    `json:"latency_ms"`
	Error     string `json:"error"`
}

type AgentDetailResponse

type AgentDetailResponse struct {
	models.Agent
	Runtime                 *RuntimeInfo `json:"runtime"`
	ConfiguredHTTPAddresses string       `json:"configured_http_addresses,omitempty"`
	EffectiveHTTPAddresses  string       `json:"effective_http_addresses,omitempty"`
}

type AgentResponse

type AgentResponse struct {
	ID                      uint   `json:"id"`
	AgentID                 string `json:"agent_id"`
	Name                    string `json:"name"`
	Status                  int    `json:"status"`
	LastSeen                int64  `json:"last_seen"`
	CreatedAt               int64  `json:"created_at"`
	HTTPAddresses           string `json:"http_addresses,omitempty"`            // Legacy: effective addresses
	ConfiguredHTTPAddresses string `json:"configured_http_addresses,omitempty"` // DB-configured addresses
	EffectiveHTTPAddresses  string `json:"effective_http_addresses,omitempty"`  // Merged effective addresses
	Tags                    string `json:"tags"`
}

type ConnectivityReport

type ConnectivityReport struct {
	AgentID   string               `json:"agent_id"`
	CheckedAt int64                `json:"checked_at"`
	Results   []ConnectivityResult `json:"results"`
}

type ConnectivityRequest

type ConnectivityRequest struct {
	ID string `uri:"id" binding:"required"`
}

type ConnectivityResult

type ConnectivityResult struct {
	TargetAgentID string               `json:"target_agent_id"`
	TargetName    string               `json:"target_name"`
	Results       []AddressProbeResult `json:"results"`
}

type CreateRequest

type CreateRequest struct {
	AgentID       string `json:"agent_id"`
	Secret        string `json:"secret"`
	Name          string `json:"name" binding:"required"`
	HTTPAddresses string `json:"http_addresses"`
	Tags          string `json:"tags"`
	ProxyURL      string `json:"proxy_url"`
}

type DetailRequest

type DetailRequest struct {
	ID string `uri:"id" binding:"required"`
}

type EnrollRequest

type EnrollRequest struct {
	EnrollmentToken string `json:"enrollment_token" binding:"required"`
	Name            string `json:"name"`
}

type EnrollResponse

type EnrollResponse struct {
	AgentID string `json:"agent_id"`
	Secret  string `json:"secret"`
}

type FullSyncRequest

type FullSyncRequest struct {
	AgentIDs []string `json:"agent_ids"`
	All      bool     `json:"all"`
}

type FullSyncResponse

type FullSyncResponse struct {
	Results []FullSyncResult `json:"results"`
}

type FullSyncResult

type FullSyncResult struct {
	AgentID    string `json:"agent_id"`
	Success    bool   `json:"success"`
	Version    int64  `json:"version,omitempty"`
	DurationMs int64  `json:"duration_ms,omitempty"`
	Error      string `json:"error,omitempty"`
}

type GenerateEnrollmentTokenRequest

type GenerateEnrollmentTokenRequest struct {
	TTL int64 `json:"ttl"`
}

type GenerateEnrollmentTokenResponse

type GenerateEnrollmentTokenResponse struct {
	EnrollmentToken string `json:"enrollment_token"`
	ExpiresAt       int64  `json:"expires_at"`
}

type Handler

type Handler struct {
	GetOnlineAgentIDs func() []string
	GetRuntime        func(agentID string) *msync.AgentRuntime
	HubCall           func(agentID string, method string, params any, timeout time.Duration) (json.RawMessage, error)
	Hub               *msync.Hub // 用于获取合并后的地址
}

func (*Handler) CheckConnectivity

func (h *Handler) CheckConnectivity(c *app.Context, req ConnectivityRequest) (ConnectivityReport, error)

func (*Handler) Create

func (h *Handler) Create(c *app.Context, req CreateRequest) (api.Created[models.Agent], error)

func (*Handler) Delete

func (h *Handler) Delete(c *app.Context, req api.IDPathRequest) (api.StatusResponse, error)

func (*Handler) Detail

func (h *Handler) Detail(c *app.Context, req DetailRequest) (AgentDetailResponse, error)

func (*Handler) Enroll

func (*Handler) FullSync

func (h *Handler) FullSync(c *app.Context, req FullSyncRequest) (FullSyncResponse, error)

func (*Handler) Get

func (h *Handler) Get(c *app.Context, req api.IDPathRequest) (models.Agent, error)

func (*Handler) GetConnectivity

func (h *Handler) GetConnectivity(c *app.Context, req ConnectivityRequest) (*ConnectivityReport, error)

func (*Handler) List

func (*Handler) Online

func (h *Handler) Online(c *app.Context, _ api.EmptyRequest) ([]OnlineAgentInfo, error)

func (*Handler) Update

func (h *Handler) Update(c *app.Context, req UpdateRequest) (models.Agent, error)

type ListRequest

type ListRequest struct {
	api.PaginationQuery
	Search string `form:"search"`
	Status string `form:"status"`
}

type OnlineAgentInfo

type OnlineAgentInfo struct {
	AgentID                 string `json:"agent_id"`
	Name                    string `json:"name"`
	Tags                    string `json:"tags"`
	HTTPAddresses           string `json:"http_addresses,omitempty"`            // Legacy: effective addresses
	ConfiguredHTTPAddresses string `json:"configured_http_addresses,omitempty"` // DB-configured addresses
	EffectiveHTTPAddresses  string `json:"effective_http_addresses,omitempty"`  // Merged effective addresses
	LastSeen                int64  `json:"last_seen"`
}

type RuntimeInfo

type RuntimeInfo struct {
	Uptime            int64                                `json:"uptime"`
	CachedTokens      int                                  `json:"cached_tokens"`
	CachedChannels    int                                  `json:"cached_channels"`
	CachedModels      int                                  `json:"cached_models"`
	ActiveConnections int                                  `json:"active_connections"`
	Version           int64                                `json:"version"`
	MasterVersion     int64                                `json:"master_version"`
	CacheStats        map[string]protocol.CacheEntityStats `json:"cache_stats,omitempty"`
}

type UpdateRequest

type UpdateRequest struct {
	ID     string         `uri:"id" binding:"required"`
	Fields map[string]any `json:"-"`
}

func (*UpdateRequest) SetBodyMap

func (r *UpdateRequest) SetBodyMap(fields map[string]any)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL