Documentation
¶
Index ¶
- Constants
- func GetErrorCode(err error) string
- func GetErrorContext(err error) map[string]interface{}
- func IsBusinessError(err error) bool
- func ParseAPIError(err error, context map[string]interface{}) error
- type BusinessError
- type GetLogsRequest
- type LogLine
- type LogsManager
- type LogsResponse
- type Run
Constants ¶
const ( ErrorCodeServiceNotFound = "SERVICE_NOT_FOUND" ErrorCodeEnvironmentNotFound = "ENVIRONMENT_NOT_FOUND" ErrorCodeK8sConnectionFailed = "K8S_CONNECTION_FAILED" ErrorCodeLogsNotAvailable = "LOGS_NOT_AVAILABLE" ErrorCodeInvalidToken = "INVALID_TOKEN" ErrorCodeUnknown = "UNKNOWN_ERROR" )
Error codes for common logs service scenarios
Variables ¶
This section is empty.
Functions ¶
func GetErrorCode ¶
GetErrorCode extracts the error code from a BusinessError, or returns UNKNOWN for other errors
func GetErrorContext ¶
GetErrorContext extracts the context from a BusinessError
func IsBusinessError ¶
IsBusinessError checks if an error is a BusinessError
func ParseAPIError ¶
ParseAPIError analyzes an API error and converts it to a BusinessError if possible
Types ¶
type BusinessError ¶
type BusinessError struct {
Code string `json:"code"`
Message string `json:"message"`
Context map[string]interface{} `json:"context,omitempty"`
}
BusinessError represents a structured business logic error
func (*BusinessError) Error ¶
func (e *BusinessError) Error() string
type GetLogsRequest ¶
type GetLogsRequest struct {
EnvironmentID string
ServiceName string
Follow bool
TailLines int64
Page int
PageSize int
// Previous reads the crashed container's previous run, from the pod most likely to explain
// the crash (see k8s.Service.UseCrashedPod), or its current run if it never restarted
Previous bool
}
GetLogsRequest contains parameters for getting logs
type LogLine ¶
type LogLine struct {
Timestamp time.Time `json:"timestamp"`
Content string `json:"content"`
Service string `json:"service"`
}
LogLine represents a single log line with metadata
type LogsManager ¶
type LogsManager struct {
// contains filtered or unexported fields
}
LogsManager handles logs business operations
func NewLogsManager ¶
func NewLogsManager(client client.Client) *LogsManager
NewLogsManager creates a new logs manager
func (*LogsManager) FormatLogsAsText ¶
func (s *LogsManager) FormatLogsAsText(logs []LogLine) string
FormatLogsAsText formats logs for text display
func (*LogsManager) GetLogs ¶
func (s *LogsManager) GetLogs(ctx context.Context, req GetLogsRequest) (*LogsResponse, error)
GetLogs retrieves logs for a service in an environment
func (*LogsManager) GetLogsReader ¶
func (s *LogsManager) GetLogsReader(ctx context.Context, req GetLogsRequest) (io.Reader, error)
GetLogsReader returns an io.Reader for logs (useful for MCP resources)
type LogsResponse ¶
type LogsResponse struct {
Lines []LogLine `json:"lines"`
Service string `json:"service"`
EnvID string `json:"environment_id"`
HasNext bool `json:"has_next"`
NextPage int `json:"next_page"`
Page int `json:"page"`
PageSize int `json:"page_size"`
// State is set for Previous requests: the container's restarts and how it last stopped
State *k8s.ContainerState `json:"state,omitempty"`
// Run is set for Previous requests: which run of the container Lines come from
Run Run `json:"run,omitempty"`
}
LogsResponse contains the result of log retrieval
type Run ¶ added in v1.10.0
type Run string
Run is which run of a container a Previous request returned.
const ( // RunPrevious is the run before the container's last restart. RunPrevious Run = "previous" // RunCurrent is the container's only run: it never restarted, so it has no previous one. RunCurrent Run = "current" // RunGone means the container restarted, but Kubernetes no longer keeps its previous run's logs. RunGone Run = "gone" )