package ops

import (
	"context"
	"time"

	"github.com/tech/sendico/pkg/api/routers/health"
	"github.com/tech/sendico/pkg/mlogger"
)

// Observer records service metrics.
type Observer interface {
	ObserveIngest(result string, duration time.Duration)
	ObserveDelivery(result string, statusCode int, duration time.Duration)
}

// HTTPServer exposes /metrics and /health.
type HTTPServer interface {
	SetStatus(status health.ServiceStatus)
	Close(ctx context.Context)
}

// HTTPServerConfig configures observability endpoint.
type HTTPServerConfig struct {
	Address string
}

// NewObserver creates process metrics observer.
func NewObserver() Observer {
	return newObserver()
}

// NewHTTPServer creates observability HTTP server.
func NewHTTPServer(logger mlogger.Logger, cfg HTTPServerConfig) (HTTPServer, error) {
	return newHTTPServer(logger, cfg)
}
