core

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ValidatePort

func ValidatePort(port int) error

ValidatePort validates that a port number is valid

func ValidateRequired

func ValidateRequired(value, fieldName string) error

ValidateRequired validates that a string field is not empty

Types

type HealthStatus

type HealthStatus struct {
	Healthy   bool                   `json:"healthy"`
	Message   string                 `json:"message"`
	Timestamp time.Time              `json:"timestamp"`
	Details   map[string]interface{} `json:"details,omitempty"`
}

HealthStatus represents the health status of a service or component

func NewHealthStatus

func NewHealthStatus(healthy bool, message string) *HealthStatus

NewHealthStatus creates a new HealthStatus instance

func NewHealthStatusWithDetails

func NewHealthStatusWithDetails(healthy bool, message string, details map[string]interface{}) *HealthStatus

NewHealthStatusWithDetails creates a new HealthStatus instance with details

type Result

type Result struct {
	Success   bool        `json:"success"`
	Data      interface{} `json:"data,omitempty"`
	Error     string      `json:"error,omitempty"`
	Timestamp time.Time   `json:"timestamp"`
}

Result represents the result of an operation

func Error

func Error(message string) *Result

Error creates an error result

func ErrorFromErr

func ErrorFromErr(err error) *Result

ErrorFromErr creates an error result from a Go error

func Success

func Success(data interface{}) *Result

Success creates a successful result

type ServiceInfo

type ServiceInfo struct {
	Name            string        `json:"name"`
	Version         string        `json:"version"`
	Port            int           `json:"port"`
	Status          ServiceStatus `json:"status"`
	StartTime       time.Time     `json:"start_time"`
	LastHealthCheck time.Time     `json:"last_health_check"`
}

ServiceInfo contains information about a service

func NewServiceInfo

func NewServiceInfo(name, version string, port int) *ServiceInfo

NewServiceInfo creates a new ServiceInfo instance

func (*ServiceInfo) SetStatus

func (s *ServiceInfo) SetStatus(status ServiceStatus)

SetStatus updates the service status and health check timestamp

func (*ServiceInfo) Uptime

func (s *ServiceInfo) Uptime() time.Duration

Uptime returns the duration since the service started

type ServiceStatus

type ServiceStatus int

ServiceStatus represents the current status of a service

const (
	ServiceStatusStarting ServiceStatus = iota
	ServiceStatusHealthy
	ServiceStatusUnhealthy
	ServiceStatusStopping
	ServiceStatusStopped
)

func (ServiceStatus) String

func (s ServiceStatus) String() string

String returns the string representation of ServiceStatus

Jump to

Keyboard shortcuts

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