Documentation
¶
Overview ¶
cloud/directory/cache.go
cloud/directory/handler.go
cloud/directory/migration.go
cloud/directory/store.go
Index ¶
Constants ¶
View Source
const DefaultCacheTTL = 90 * time.Second
DefaultCacheTTL is the Redis key TTL for online status.
View Source
const MigrationSQL = `` /* 352-byte string literal not displayed */
MigrationSQL creates the agents table.
Variables ¶
View Source
var ErrAgentNotFound = errors.New("agent not found")
Functions ¶
This section is empty.
Types ¶
type AgentRecord ¶
type AgentRecord struct {
AgentID string `json:"agent_id" db:"agent_id"`
AgentName string `json:"agent_name" db:"agent_name"`
PublicKey []byte `json:"public_key" db:"public_key"`
Endpoint string `json:"endpoint" db:"endpoint"`
CreatedAt time.Time `json:"created_at" db:"created_at"`
LastSeenAt time.Time `json:"last_seen_at" db:"last_seen_at"`
}
AgentRecord represents a registered agent in the directory.
type AgentResponse ¶
type AgentStore ¶
type AgentStore interface {
UpsertAgent(ctx context.Context, agent *AgentRecord) error
GetAgent(ctx context.Context, agentID string) (*AgentRecord, error)
DeleteAgent(ctx context.Context, agentID string) error
GetPublicKey(ctx context.Context, agentID string) ([]byte, error)
}
AgentStore is the persistence interface for agent records.
func NewPostgresStore ¶
func NewPostgresStore(db *sql.DB) AgentStore
NewPostgresStore creates a PostgreSQL-backed AgentStore.
type DeleteRequest ¶
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
func NewHandler ¶
func NewHandler(store AgentStore, cache OnlineCache) *Handler
type HeartbeatRequest ¶
type OnlineCache ¶
type OnlineCache interface {
MarkOnline(ctx context.Context, agentID, endpoint string) error
IsOnline(ctx context.Context, agentID string) (bool, string, error)
MarkOffline(ctx context.Context, agentID string) error
}
OnlineCache tracks agent online status.
func NewRedisCache ¶
func NewRedisCache(redisURL string) OnlineCache
NewRedisCache creates a Redis-backed OnlineCache.
type PublicKeyResponse ¶
Click to show internal directories.
Click to hide internal directories.