storage

package
v0.0.0-...-823433a Latest Latest
Warning

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

Go to latest
Published: May 24, 2022 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var InvalidStorage = errors.New("storage not found")
View Source
var UnknownStorage = errors.New("storage isn't support yet")

Functions

This section is empty.

Types

type AnSensor

type AnSensor struct {
	SensorNumber uint8  `json:"sensor_number"`
	Value        uint32 `json:"value"`
}

type Connector

type Connector interface {
	// Init установка соединения с хранилищем
	Init(map[string]string) error

	// Close закрытие соединения с хранилищем
	Close() error
}

Connector интерфейс для подключения внешних хранилищ

type LiquidSensor

type LiquidSensor struct {
	SensorNumber uint8   `json:"sensor_number"`
	ModuleNumber uint16  `json:"module_number"`
	ErrorFlag    string  `json:"error_flag"`
	ValueUnit    string  `json:"value_unit"`
	ValueMm      uint32  `json:"value_mm"`
	ValueL       float64 `json:"value_l"`
}

type LocState

type LocState struct {
	Latitude     float64 `json:"lat"`
	Longitude    float64 `json:"lng"`
	Speed        uint16  `json:"speed"`
	NavigationDt string  `json:"navigation_dt"`
}

type LogConnector

type LogConnector struct{}

func (LogConnector) Close

func (c LogConnector) Close() error

func (LogConnector) Init

func (c LogConnector) Init(cfg map[string]string) error

func (LogConnector) Save

func (c LogConnector) Save(msg interface{ ToBytes() ([]byte, error) }) error
type NavRecord struct {
	ServerID            string         `json:"server_id"`
	IMEI                string         `json:"IMEI"`
	ClientID            uint32         `json:"client_id"`
	ReceivedDt          string         `json:"received_dt"`
	PacketID            uint32         `json:"packet_id"`
	NavigationTimestamp int64          `json:"navigation_unix_time"`
	AnSensors           []AnSensor     `json:"an_sensors"`
	LiquidSensors       []LiquidSensor `json:"liquid_sensors"`
	LocStates           []LocState     `json:"loc_states"`
	LocStatesCount      int32          `json:"loc_states_count"`
}
func (eep *NavRecord) ToBytes() ([]byte, error)

type Repository

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

Repository набор выходных хранилищ

func NewRepository

func NewRepository() *Repository

NewRepository создает пустой репозиторий

func (*Repository) AddStore

func (r *Repository) AddStore(s Saver)

AddStore добавляет хранилище для сохранения данных

func (*Repository) LoadStorages

func (r *Repository) LoadStorages(storages map[string]map[string]string) error

LoadStorages загружает хранилища из структуры конфига

func (*Repository) Save

func (r *Repository) Save(m interface{ ToBytes() ([]byte, error) }) error

Save сохраняет данные во все установленные хранилища

type Saver

type Saver interface {
	// Save сохранение в хранилище
	Save(interface{ ToBytes() ([]byte, error) }) error
}

Saver интерфейс для подключения внешних хранилищ

type Store

type Store interface {
	Connector
	Saver
}

Directories

Path Synopsis
store
nsq

Jump to

Keyboard shortcuts

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