service

package
v0.0.0-...-5c36ebe Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2023 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const APIPrefix = "/api/gathering"

APIPrefix is the prefix used in the console-dot environment

View Source
const V1Prefix = "/v1"

V1Prefix is the version prefix used in the console-dot environment

Variables

This section is empty.

Functions

This section is empty.

Types

type ErrorResponse

type ErrorResponse struct {
	Error string `json:"error"`
}

ErrorResponse structure represents HTTP response with error message.

type GatheringRulesResponse

type GatheringRulesResponse struct {
	Version string      `json:"version"`
	Rules   interface{} `json:"rules"`
}

GatheringRulesResponse structure represents HTTP response with rules-related content.

type Handler

type Handler struct {
	// contains filtered or unexported fields
}

Handler structure represents HTTP request handler.

func NewHandler

func NewHandler(svc Interface) *Handler

NewHandler function constructs new HTTP request handler.

func (*Handler) Register

func (s *Handler) Register(r *mux.Router)

Register function registers new handler for given endpoint URL.

type Interface

type Interface interface {
	Rules() (*Rules, error)
}

Interface defines methods to be implemented by any rules provider

type Repository

type Repository struct {
	// contains filtered or unexported fields
}

Repository is definition of objects that implement the RepositoryInterface

func NewRepository

func NewRepository(s StorageInterface) *Repository

NewRepository constructs new instance of Repository

func (*Repository) Rules

func (r *Repository) Rules() (*Rules, error)

Rules method reads all and unmarshals all rules stored under given path

type RepositoryInterface

type RepositoryInterface interface {
	Rules() (*Rules, error)
}

RepositoryInterface defines methods to be implemented by any rules providers

type Rule

type Rule struct {
	Conditions         []interface{} `json:"conditions,omitempty"`
	GatheringFunctions interface{}   `json:"gathering_functions,omitempty"`
}

Rule data type definition based on original JSON schema

type Rules

type Rules struct {
	Items   []Rule `json:"rules,omitempty"`
	Version string `json:"version,omitempty"`
}

Rules data type definition based on original JSON schema

type Service

type Service struct {
	// contains filtered or unexported fields
}

Service data type represents the whole service for repository interface.

func New

func New(repo RepositoryInterface) *Service

New function constructs new service for given repository interface.

func (*Service) Rules

func (s *Service) Rules() (*Rules, error)

Rules method returns all rules provided by the service.

type Storage

type Storage struct {
	// contains filtered or unexported fields
}

Storage type represents container for resources.

func NewStorage

func NewStorage(cfg StorageConfig) *Storage

NewStorage constructs new storage object.

func (*Storage) Find

func (s *Storage) Find(path string) []byte

Find method tries to find resource with given name in the storage.

type StorageConfig

type StorageConfig struct {
	RulesPath string `mapstructure:"rules_path" toml:"rules_path"`
}

StorageConfig structure contains configuration for resource storage.

type StorageInterface

type StorageInterface interface {
	Find(res string) []byte
}

StorageInterface describe interface to be implemented by resource storage implementations.

Jump to

Keyboard shortcuts

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