// Package registry provides service registry interface for service discovery.
package registry

import (
	"context"
)

// ServiceRegistry is the interface for service discovery and registration.
type ServiceRegistry interface {
	// Register registers a service instance with the registry.
	Register(ctx context.Context, service *ServiceInstance) error

	// Deregister removes a service instance from the registry.
	Deregister(ctx context.Context, serviceID string) error

	// Discover returns all healthy instances of a service.
	Discover(ctx context.Context, serviceName string) ([]*ServiceInstance, error)

	// Watch returns a channel that receives updates when service instances change.
	Watch(ctx context.Context, serviceName string) (<-chan []*ServiceInstance, error)

	// Health returns the health status of a service instance.
	Health(ctx context.Context, serviceID string) (*HealthStatus, error)
}

// ServiceInstance represents a service instance in the registry.
type ServiceInstance struct {
	ID       string            // Unique instance ID
	Name     string            // Service name (e.g., "auth-service", "identity-service")
	Address  string            // Service address (IP or hostname)
	Port     int               // Service port
	Tags     []string          // Service tags for filtering
	Metadata map[string]string // Additional metadata
}

// HealthStatus represents the health status of a service instance.
type HealthStatus struct {
	ServiceID string // Service instance ID
	Status    string // Health status: "healthy", "unhealthy", "critical"
	Message   string // Optional status message
}
