service

package
v0.92.0 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2024 License: MPL-2.0 Imports: 4 Imported by: 1

Documentation

Overview

Package service defines Service object definitions.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Metadata

type Metadata struct {
	Name        string                      `json:"name"`
	DisplayName string                      `json:"displayName,omitempty"`
	Project     string                      `json:"project,omitempty"`
	Labels      v1alpha.Labels              `json:"labels,omitempty"`
	Annotations v1alpha.MetadataAnnotations `json:"annotations,omitempty"`
}

Metadata provides identity information for Service.

type Service

type Service struct {
	APIVersion manifest.Version `json:"apiVersion"`
	Kind       manifest.Kind    `json:"kind"`
	Metadata   Metadata         `json:"metadata"`
	Spec       Spec             `json:"spec"`
	Status     *Status          `json:"status,omitempty"`

	Organization   string `json:"organization,omitempty"`
	ManifestSource string `json:"manifestSrc,omitempty"`
}

Service in Nobl9 is a high-level grouping of service level objectives (SLOs). A service can represent a logical service endpoint like an API, a database, an application, or anything else you care about setting an SLO for. Every SLO in Nobl9 is tied to a service, and service can have one or more SLOs.

Example
package main

import (
	"context"
	"log"

	"github.com/nobl9/nobl9-go/internal/examples"
	"github.com/nobl9/nobl9-go/manifest"
	"github.com/nobl9/nobl9-go/manifest/v1alpha"
	"github.com/nobl9/nobl9-go/manifest/v1alpha/service"
)

func main() {
	// Create the object:
	myService := service.New(
		service.Metadata{
			Name:        "my-service",
			DisplayName: "My Service",
			Project:     "default",
			Labels: v1alpha.Labels{
				"team":   []string{"green", "orange"},
				"region": []string{"eu-central-1"},
			},
		},
		service.Spec{
			Description: "Example service",
		},
	)
	// Verify the object:
	if err := myService.Validate(); err != nil {
		log.Fatalf("service validation failed, err: %v", err)
	}
	// Apply the object:
	client := examples.GetOfflineEchoClient()
	if err := client.Objects().V1().Apply(context.Background(), []manifest.Object{myService}); err != nil {
		log.Fatalf("failed to apply service, err: %v", err)
	}
}
Output:

apiVersion: n9/v1alpha
kind: Service
metadata:
  name: my-service
  displayName: My Service
  project: default
  labels:
    region:
    - eu-central-1
    team:
    - green
    - orange
spec:
  description: Example service

func New

func New(metadata Metadata, spec Spec) Service

New creates a new Service based on provided Metadata nad Spec.

func (Service) GetKind

func (s Service) GetKind() manifest.Kind

func (Service) GetManifestSource

func (s Service) GetManifestSource() string

func (Service) GetName

func (s Service) GetName() string

func (Service) GetOrganization

func (s Service) GetOrganization() string

func (Service) GetProject

func (s Service) GetProject() string

func (Service) GetValidator added in v0.82.0

func (s Service) GetValidator() govy.Validator[Service]

func (Service) GetVersion

func (s Service) GetVersion() manifest.Version

func (Service) SetManifestSource

func (s Service) SetManifestSource(src string) manifest.Object

func (Service) SetOrganization

func (s Service) SetOrganization(org string) manifest.Object

func (Service) SetProject

func (s Service) SetProject(project string) manifest.Object

func (Service) Validate

func (s Service) Validate() error

type Spec

type Spec struct {
	Description string `json:"description" validate:"description" example:"Bleeding edge web app"`
}

Spec holds detailed information specific to Service.

type Status

type Status struct {
	SloCount int `json:"sloCount"`
}

Status holds dynamic fields returned when the Service is fetched from Nobl9 platform. Status is not part of the static object definition.

Jump to

Keyboard shortcuts

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