slogo

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2025 License: Apache-2.0 Imports: 6 Imported by: 0

README

Build Status Lint Status Go Report Card Docs License

Go utilities for working with OpenSLO (Service Level Objectives) specifications.

Overview

slogo is a Go library that provides convenient utilities for reading, writing, and validating OpenSLO specification files. It builds on top of the OpenSLO Go SDK to provide a simpler interface for working with SLO definitions in JSON and YAML formats.

Features

  • Read OpenSLO objects from files or readers (auto-detects JSON/YAML format)
  • Write OpenSLO objects to files in JSON or YAML format
  • Validate SLO definitions against the OpenSLO specification
  • Type-safe Go representations of SLO objects
  • Predefined severity and attribute constants

Installation

go get github.com/grokify/slogo

Usage

Reading SLO Files
import "github.com/grokify/slogo"

// Read from file (auto-detects JSON or YAML)
objs, err := slogo.ReadFile("slo-definition.yaml")
if err != nil {
    log.Fatal(err)
}

// Read from io.Reader
objs, err := slogo.Read(reader)
if err != nil {
    log.Fatal(err)
}
Validating SLO Objects
// Validate all objects
if err := objs.Validate(); err != nil {
    log.Fatal(err)
}
Writing SLO Files
// Write as YAML
err := objs.WriteFileYAML("output.yaml")
if err != nil {
    log.Fatal(err)
}

// Write as JSON
err := objs.WriteFileJSON("output.json")
if err != nil {
    log.Fatal(err)
}
Using Predefined Constants
import "github.com/grokify/slogo"

// Severity levels
severity := slogo.SeverityCritical // "critical"
severity := slogo.SeverityHigh     // "high"
severity := slogo.SeverityMedium   // "medium"
severity := slogo.SeverityLow      // "low"
severity := slogo.SeverityInfo     // "info"

// Attributes
attr := slogo.AttrQuery // "query"

Examples

The examples directory contains real-world examples of SLO definitions with detailed explanations:

Budgeting Methods

Compares different budgeting methods (Occurrences, Timeslices, and RatioTimeslices) with practical examples:

  • Availability SLO (timeslices-slo.go) - Reflects an SLA for internet provider availability (99% uptime)
  • Occurrences SLO (occurences-slo.go) - Measures search latency treating all searches equally
  • Ratio Timeslices SLO (ratio-timeslices.go) - Tracks main page availability based on response codes
Treat Low Traffic as Equally Important

Demonstrates how to maintain high reliability regardless of traffic volume, ensuring that services with low usage receive the same attention as high-traffic services.

Each example includes:

  • Complete, working Go code
  • Detailed descriptions of what is being measured
  • Explanations of why specific budgeting methods are chosen
  • Automated tests to validate the SLO definitions

Dependencies

License

This project is licensed under the Apache License 2.0 - see the LICENSE file for details.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Resources

Documentation

Index

Constants

View Source
const (
	AttrQuery = "query"

	SeverityCritical = "critical"
	SeverityHigh     = "high"
	SeverityMedium   = "medium"
	SeverityLow      = "low"
	SeverityInfo     = "info"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Objects

type Objects []openslo.Object

func Read

func Read(r io.Reader) (Objects, error)

func ReadFile

func ReadFile(filename string) (Objects, error)

func (Objects) Validate

func (objs Objects) Validate() error

func (Objects) WriteFile

func (objs Objects) WriteFile(filename string, format openslosdk.ObjectFormat) error

func (Objects) WriteFileJSON

func (objs Objects) WriteFileJSON(filename string) error

func (Objects) WriteFileYAML

func (objs Objects) WriteFileYAML(filename string) error

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

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