services

package
v0.0.0-...-c2add7f Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2023 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Overview

Package services contains implementationm of business logic for different scenarios.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CalculateID

func CalculateID(name, kind string) string

CalculateID generate new metric ID.

Types

type HealthCheck

type HealthCheck interface {
	CheckStorage(ctx context.Context) error
}

type HealthCheckImpl

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

HealthCheckImpl implements general service healthcheck. Currently only database connection is verified.

func NewHealthCheck

func NewHealthCheck(dataStore storage.Storage) HealthCheckImpl

func (HealthCheckImpl) CheckStorage

func (h HealthCheckImpl) CheckStorage(ctx context.Context) error

CheckStorage verifies connection to the database. Fails if database storage is not configured.

type HealthCheckMock

type HealthCheckMock struct {
	mock.Mock
}

func (*HealthCheckMock) CheckStorage

func (m *HealthCheckMock) CheckStorage(ctx context.Context) error

type MetricsRecorder

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

MetricsRecorder implements business logic for metrics writing and reading scenarios.

func NewMetricsRecorder

func NewMetricsRecorder(dataStore storage.Storage) MetricsRecorder

NewMetricsRecorder creatse new NewMetricsRecorder instance with attached storage.

func (MetricsRecorder) Get

func (r MetricsRecorder) Get(ctx context.Context, kind, name string) (storage.Record, error)

Get returns stored metrics record.

func (MetricsRecorder) List

List retrieves all stored metrics.

func (MetricsRecorder) Push

Push records metric data.

func (MetricsRecorder) PushList

func (r MetricsRecorder) PushList(ctx context.Context, records []storage.Record) ([]storage.Record, error)

PushList records list of metrics data.

type Recorder

type Recorder interface {
	Push(ctx context.Context, record storage.Record) (storage.Record, error)
	PushList(ctx context.Context, records []storage.Record) ([]storage.Record, error)
	Get(ctx context.Context, kind, name string) (storage.Record, error)
	List(ctx context.Context) ([]storage.Record, error)
}

type RecorderMock

type RecorderMock struct {
	mock.Mock
}

func (*RecorderMock) Get

func (m *RecorderMock) Get(ctx context.Context, kind, name string) (storage.Record, error)

func (*RecorderMock) List

func (m *RecorderMock) List(ctx context.Context) ([]storage.Record, error)

func (*RecorderMock) Push

func (m *RecorderMock) Push(ctx context.Context, record storage.Record) (storage.Record, error)

func (*RecorderMock) PushList

func (m *RecorderMock) PushList(ctx context.Context, records []storage.Record) ([]storage.Record, error)

Jump to

Keyboard shortcuts

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