directory

package
v0.0.0-...-8155ea7 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2026 License: GPL-2.0, GPL-3.0 Imports: 14 Imported by: 0

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 AgentResponse struct {
	AgentID              string `json:"agentID"`
	AgentName            string `json:"agentName"`
	Online               bool   `json:"online"`
	PublicKeyFingerprint string `json:"publicKeyFingerprint"`
	RelayEndpoint        string `json:"relayEndpoint,omitempty"`
}

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 DeleteRequest struct {
	Timestamp int64  `json:"timestamp"`
	Signature string `json:"signature"`
}

type Handler

type Handler struct {
	// contains filtered or unexported fields
}

func NewHandler

func NewHandler(store AgentStore, cache OnlineCache) *Handler

func (*Handler) ServeHTTP

func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request)

type HeartbeatRequest

type HeartbeatRequest struct {
	Timestamp int64  `json:"timestamp"`
	Signature string `json:"signature"`
}

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

type PublicKeyResponse struct {
	AgentID   string `json:"agentID"`
	PublicKey string `json:"publicKey"`
}

type RegisterRequest

type RegisterRequest struct {
	AgentID   string `json:"agentID"`
	AgentName string `json:"agentName"`
	PublicKey string `json:"publicKey"`
	Endpoint  string `json:"endpoint"`
	Timestamp int64  `json:"timestamp"`
	Signature string `json:"signature"`
}

Jump to

Keyboard shortcuts

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