registry

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2026 License: MIT Imports: 7 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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