registry

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type OnRegisterFunc

type OnRegisterFunc func(ctx context.Context, serviceID string)

OnRegisterFunc is called after a service registers. Used for retroactive indexer auto-assignment without circular imports.

type Service

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

Service manages the service registry.

func NewService

func NewService(q db.Querier, bus *events.Bus, logger *slog.Logger) *Service

NewService creates a new registry service.

func (*Service) Deregister

func (s *Service) Deregister(ctx context.Context, id string) error

Deregister removes a service from the registry.

func (*Service) Get

func (s *Service) Get(ctx context.Context, id string) (*ServiceInfo, error)

Get returns a single service with its capabilities.

func (*Service) Heartbeat

func (s *Service) Heartbeat(ctx context.Context, id string) error

Heartbeat updates the last_seen timestamp and sets status to online.

func (*Service) List

func (s *Service) List(ctx context.Context) ([]ServiceInfo, error)

List returns all registered services.

func (*Service) ListByCapability

func (s *Service) ListByCapability(ctx context.Context, capability string) ([]ServiceInfo, error)

ListByCapability returns services that declare a specific capability.

func (*Service) ListByType

func (s *Service) ListByType(ctx context.Context, svcType string) ([]ServiceInfo, error)

ListByType returns services filtered by type.

func (*Service) Register

func (s *Service) Register(ctx context.Context, input ServiceInput) (*ServiceInfo, error)

Register adds or updates a service in the registry. If a service with the same name+type exists, it updates; otherwise creates.

func (*Service) SetOnRegister

func (s *Service) SetOnRegister(fn OnRegisterFunc)

SetOnRegister sets a callback that fires after a new service registers.

func (*Service) UpdateStatus

func (s *Service) UpdateStatus(ctx context.Context, id, status string) error

UpdateStatus sets the status for a service.

type ServiceInfo

type ServiceInfo struct {
	db.Service
	Capabilities []string `json:"capabilities"`
}

ServiceInfo is the enriched view returned from queries.

type ServiceInput

type ServiceInput struct {
	Name         string   `json:"name"`
	Type         string   `json:"type"`
	APIURL       string   `json:"api_url"`
	APIKey       string   `json:"api_key"`
	HealthURL    string   `json:"health_url"`
	Version      string   `json:"version"`
	Capabilities []string `json:"capabilities"`
	Metadata     string   `json:"metadata"`
}

ServiceInput is the data required to register or update a service.

Jump to

Keyboard shortcuts

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